Package org.qdl_lang.extensions
Class JavaModule
- java.lang.Object
-
- org.qdl_lang.expressions.module.Module
-
- org.qdl_lang.extensions.JavaModule
-
- All Implemented Interfaces:
Serializable,Cloneable,XThing
- Direct Known Subclasses:
CryptoModule,EGModule,QDL509Module,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 interfacesQDLFunctionfor functions andQDLVariablefor 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>funcsprotected List<QDLVariable>vars-
Fields inherited from class org.qdl_lang.expressions.module.Module
FDOC_CONVERT
-
-
Constructor Summary
Constructors Modifier Constructor Description JavaModule()Used byQDLLoaderJavaModule(URI uri)protectedJavaModule(URI namespace, String alias)Deprecated.alias is no longer needed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFunctions(List<QDLFunction> functions)voidaddVariables(List<QDLVariable> variables)List<String>createDefaultDocs()Creates the documentation from the first of each line of every function.voiddeserializeFromJSON(net.sf.json.JSONObject json, SerializationState serializationState)Deserializes a JSON object into the current module.voiddeserializeStates(net.sf.json.JSONObject jsonObject, SerializationState serializationState)This should centralize deserializing the state for a Java module.StringgetClassname()List<String>getDocumentation()List<String>getListByTag()StringgetLoaderClassName()QDLMetaModulegetMetaClass()booleanhasMetaClass()voidinit(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.voidinit(State state, boolean doVariables)booleanisExternal()This returns true only if the module is from another language than a QDL module.net.sf.json.JSONObjectserializeToJSON(SerializationState serializationState)The result of this is a json objectvoidsetClassName(String className)voidsetDocumentation(List<String> documentation)voidsetLoaderClassName(String loaderClassName)voidsetMetaClass(QDLMetaModule metaClass)StringtoString()voidwriteExtraXMLAttributes(XMLStreamWriter xsw)Add any attributes you want to the module tag (you must read them later).-
Methods inherited from class org.qdl_lang.expressions.module.Module
fromJSON, fromXML, fromXML, getAlias, getDescription, getId, getInheritMode, getKey, getListByTag, getMTKey, getName, getNamespace, getParentInstanceAlias, getParentInstanceID, getParentTemplateID, getState, isTemplate, isUsed, newInstance, readExtraXMLAttributes, readExtraXMLElements, setAlias, setDescription, 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:ModuleThis returns true only if the module is from another language than a QDL module.- Overrides:
isExternalin 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:ModuleAdd any attributes you want to the module tag (you must read them later).- Overrides:
writeExtraXMLAttributesin classModule- Throws:
XMLStreamException
-
serializeToJSON
public net.sf.json.JSONObject serializeToJSON(SerializationState serializationState) throws Throwable
Description copied from class:ModuleThe result of this is a json object- Overrides:
serializeToJSONin classModule- Returns:
- Throws:
Throwable
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject json, SerializationState serializationState) throws ThrowableDescription copied from class:ModuleDeserializes a JSON object into the current module. You must check the type in the json object o know which class (e.g.,JavaModuleto instantiate first.- Overrides:
deserializeFromJSONin classModule- Throws:
Throwable
-
deserializeStates
public void deserializeStates(net.sf.json.JSONObject jsonObject, SerializationState serializationState) throws ThrowableThis 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.- Specified by:
createDefaultDocsin classModule- Returns:
-
getListByTag
public List<String> getListByTag()
- Specified by:
getListByTagin classModule
-
setDocumentation
public void setDocumentation(List<String> documentation)
- Specified by:
setDocumentationin classModule
-
getDocumentation
public List<String> getDocumentation()
- Specified by:
getDocumentationin classModule
-
getMetaClass
public QDLMetaModule getMetaClass()
-
setMetaClass
public void setMetaClass(QDLMetaModule metaClass)
-
hasMetaClass
public boolean hasMetaClass()
-
-