Package org.qdl_lang.extensions
Class JavaModule
- java.lang.Object
-
- org.qdl_lang.module.Module
-
- org.qdl_lang.extensions.JavaModule
-
- All Implemented Interfaces:
Serializable
,Cloneable
,XThing
- Direct Known Subclasses:
CryptoModule
,EGModule
,QDLCLIToolsModule
,QDLConvertModule
,QDLDBModule
,QDLDynamoDBModule
,QDLHTTPModule
,QDLMailModule
,StatefulModule
public abstract class JavaModule extends Module
This will let you create your own extensions to QDL in Java. Simply implement the interfacesQDLFunction
for functions andQDLVariable
for variables, add the module and you can use it in QDL like any other module.Created by Jeff Gaynor
on 1/27/20 at 12:03 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<QDLFunction>
funcs
protected List<QDLVariable>
vars
-
Fields inherited from class org.qdl_lang.module.Module
FDOC_CONVERT
-
-
Constructor Summary
Constructors Modifier Constructor Description JavaModule()
Used byQDLLoader
JavaModule(URI uri)
protected
JavaModule(URI namespace, String alias)
Deprecated.alias is no longer needed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFunctions(List<QDLFunction> functions)
void
addVariables(List<QDLVariable> variables)
List<String>
createDefaultDocs()
Creates the documentation from the first of each line of every function.void
deserializeFromJSON(net.sf.json.JSONObject json, SerializationState serializationState)
Deserializes a JSON object into the current module.void
deserializeStates(net.sf.json.JSONObject jsonObject, SerializationState serializationState)
This should centralize deserializing the state for a Java module.String
getClassname()
List<String>
getDescription()
ThecreateDefaultDocs()
will create basic documentation for functions and such, and is called automatically during moduleinit(State)
, but the actual description of this module -- if any -- is done here.List<String>
getDocumentation()
List<String>
getListByTag()
String
getLoaderClassName()
QDLMetaModule
getMetaClass()
boolean
hasMetaClass()
void
init(State state)
This is critical in that it puts all the functions and variables (with their correct alias) in to the state for this module.void
init(State state, boolean doVariables)
boolean
isExternal()
This returns true only if the module is from another language than a QDL module.net.sf.json.JSONObject
serializeToJSON(SerializationState serializationState)
The result of this is a json objectvoid
setClassName(String className)
void
setDocumentation(List<String> documentation)
void
setLoaderClassName(String loaderClassName)
void
setMetaClass(QDLMetaModule metaClass)
String
toString()
void
writeExtraXMLAttributes(XMLStreamWriter xsw)
Add any attributes you want to the module tag (you must read them later).-
Methods inherited from class org.qdl_lang.module.Module
fromJSON, fromXML, fromXML, getAlias, getId, getInheritMode, getKey, getListByTag, getMTKey, getName, getNamespace, getParentInstanceAlias, getParentInstanceID, getParentTemplateID, getState, isTemplate, isUsed, newInstance, readExtraXMLAttributes, readExtraXMLElements, setAlias, setId, setInheritanceMode, setNamespace, setParentInstanceAlias, setParentInstanceID, setParentTemplateID, setState, setTemplate, setupModule, setUsed, toJSON, toXML, toXML, toXML2, writeExtraXMLElements
-
-
-
-
Field Detail
-
vars
protected List<QDLVariable> vars
-
funcs
protected List<QDLFunction> funcs
-
-
Constructor Detail
-
JavaModule
public JavaModule()
Used byQDLLoader
-
JavaModule
public JavaModule(URI uri)
-
JavaModule
protected JavaModule(URI namespace, String alias)
Deprecated.alias is no longer needed. Just use the namespace only constructorUsed by the factory methodModule.newInstance(State)
- Parameters:
namespace
-alias
-
-
-
Method Detail
-
isExternal
public boolean isExternal()
Description copied from class:Module
This returns true only if the module is from another language than a QDL module.- Overrides:
isExternal
in classModule
- Returns:
-
getClassname
public String getClassname()
-
setClassName
public void setClassName(String className)
-
getLoaderClassName
public String getLoaderClassName()
-
setLoaderClassName
public void setLoaderClassName(String loaderClassName)
-
addFunctions
public void addFunctions(List<QDLFunction> functions)
-
addVariables
public void addVariables(List<QDLVariable> variables)
-
init
public void init(State state)
This is critical in that it puts all the functions and variables (with their correct alias) in to the state for this module. Normally this is called when module_import is invoked on each module, so generally you do not need to call this ever. It is, however, what makes any module work.- Parameters:
state
-
-
init
public void init(State state, boolean doVariables)
-
writeExtraXMLAttributes
public void writeExtraXMLAttributes(XMLStreamWriter xsw) throws XMLStreamException
Description copied from class:Module
Add any attributes you want to the module tag (you must read them later).- Overrides:
writeExtraXMLAttributes
in classModule
- Throws:
XMLStreamException
-
serializeToJSON
public net.sf.json.JSONObject serializeToJSON(SerializationState serializationState) throws Throwable
Description copied from class:Module
The result of this is a json object- Overrides:
serializeToJSON
in classModule
- Returns:
- Throws:
Throwable
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject json, SerializationState serializationState) throws Throwable
Description copied from class:Module
Deserializes a JSON object into the current module. You must check the type in the json object o know which class (e.g.,JavaModule
to instantiate first.- Overrides:
deserializeFromJSON
in classModule
- Throws:
Throwable
-
deserializeStates
public void deserializeStates(net.sf.json.JSONObject jsonObject, SerializationState serializationState) throws Throwable
This should centralize deserializing the state for a Java module. Hence this is public and should be called whenever this as needed.- Parameters:
jsonObject
-serializationState
-- Throws:
Throwable
-
createDefaultDocs
public List<String> createDefaultDocs()
Creates the documentation from the first of each line of every function. Use this or override as needed.- Returns:
-
getDescription
public List<String> getDescription()
ThecreateDefaultDocs()
will create basic documentation for functions and such, and is called automatically during moduleinit(State)
, but the actual description of this module -- if any -- is done here. Override and return your description.- Returns:
-
getListByTag
public List<String> getListByTag()
- Specified by:
getListByTag
in classModule
-
setDocumentation
public void setDocumentation(List<String> documentation)
- Specified by:
setDocumentation
in classModule
-
getDocumentation
public List<String> getDocumentation()
- Specified by:
getDocumentation
in classModule
-
getMetaClass
public QDLMetaModule getMetaClass()
-
setMetaClass
public void setMetaClass(QDLMetaModule metaClass)
-
hasMetaClass
public boolean hasMetaClass()
-
-