Package org.qdl_lang.module
Class Module
- java.lang.Object
-
- org.qdl_lang.module.Module
-
- All Implemented Interfaces:
Serializable
,Cloneable
,XThing
- Direct Known Subclasses:
JavaModule
,QDLModule
public abstract class Module extends Object implements XThing, Serializable
Created by Jeff Gaynor
on 1/21/20 at 11:03 AM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description boolean
FDOC_CONVERT
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
deserializeFromJSON(net.sf.json.JSONObject json, SerializationState serializationState)
Deserializes a JSON object into the current module.void
fromJSON(net.sf.json.JSONArray array)
void
fromXML(XMLEventReader xer, edu.uiuc.ncsa.security.core.configuration.XProperties xp, QDLInterpreter qi)
void
fromXML(XMLEventReader xer, SerializationState SerializationState, boolean isTemplate)
Used in version 2,0 serializationString
getAlias()
abstract List<String>
getDocumentation()
UUID
getId()
int
getInheritMode()
XKey
getKey()
abstract List<String>
getListByTag()
protected List<String>
getListByTag(XMLEventReader xer, String tag)
Getting the documentation from the XML serialization 2.0.MTKey
getMTKey()
String
getName()
URI
getNamespace()
String
getParentInstanceAlias()
UUID
getParentInstanceID()
UUID
getParentTemplateID()
State
getState()
boolean
isExternal()
This returns true only if the module is from another language than a QDL module.boolean
isTemplate()
The system will mark loaded modules as template.boolean
isUsed()
If this was imported by the use command.abstract Module
newInstance(State state)
Modules are effectively templates.void
readExtraXMLAttributes(XMLEvent xe)
This is passed the current event and should only have calls to read the attributes.void
readExtraXMLElements(XMLEvent xe, XMLEventReader xer)
This passes in the current start event so you can add your own event loop and cases.net.sf.json.JSONObject
serializeToJSON(SerializationState serializationState)
The result of this is a json objectvoid
setAlias(String alias)
abstract void
setDocumentation(List<String> documentation)
void
setId(UUID id)
void
setInheritanceMode(int inheritMode)
void
setNamespace(URI namespace)
void
setParentInstanceAlias(String parentInstanceAlias)
void
setParentInstanceID(UUID parentInstanceID)
void
setParentTemplateID(UUID parentTemplateID)
void
setState(State state)
void
setTemplate(boolean template)
protected void
setupModule(Module module)
Called innewInstance(State)
to finish setting up the module for things like serialization.void
setUsed(boolean used)
net.sf.json.JSONArray
toJSON()
String
toString()
void
toXML(XMLStreamWriter xsw, String alias)
void
toXML(XMLStreamWriter xsw, String alias, boolean fullSerialization, SerializationState SerializationState)
void
toXML2(XMLStreamWriter xsw, String alias, boolean fullSerialization, SerializationState SerializationState)
void
writeExtraXMLAttributes(XMLStreamWriter xsw)
Add any attributes you want to the module tag (you must read them later).void
writeExtraXMLElements(XMLStreamWriter xsw)
Write extra elements.
-
-
-
Method Detail
-
getMTKey
public MTKey getMTKey()
-
isExternal
public boolean isExternal()
This returns true only if the module is from another language than a QDL module.- Returns:
-
isTemplate
public boolean isTemplate()
The system will mark loaded modules as template.- Returns:
-
setTemplate
public void setTemplate(boolean template)
-
getState
public State getState()
-
setState
public void setState(State state)
-
getAlias
public String getAlias()
-
setAlias
public void setAlias(String alias)
-
getNamespace
public URI getNamespace()
-
setNamespace
public void setNamespace(URI namespace)
-
toJSON
public net.sf.json.JSONArray toJSON()
-
fromJSON
public void fromJSON(net.sf.json.JSONArray array)
-
isUsed
public boolean isUsed()
If this was imported by the use command.- Returns:
-
setUsed
public void setUsed(boolean used)
-
newInstance
public abstract Module newInstance(State state)
Modules are effectively templates. This passes in the state of the parser at the point a new module is required and the contract is to create a new instance of this module with the state. Note that the state passed in may have nothing to do with the state here. You are creating a new module for the given state using this as a template.
All implementations should gracefully handle a null state with the assumption that the full state will be set later. This is because of bootstrapping networks of modules during deserialization.- Parameters:
state
-- Returns:
-
setupModule
protected void setupModule(Module module)
Called innewInstance(State)
to finish setting up the module for things like serialization. When you writenewInstance(State)
the very last thing you should do is invoke this on your new module.- Parameters:
module
-
-
toXML
public void toXML(XMLStreamWriter xsw, String alias) throws XMLStreamException
- Throws:
XMLStreamException
-
toXML2
public void toXML2(XMLStreamWriter xsw, String alias, boolean fullSerialization, SerializationState SerializationState) throws XMLStreamException
- Throws:
XMLStreamException
-
serializeToJSON
public net.sf.json.JSONObject serializeToJSON(SerializationState serializationState) throws Throwable
The result of this is a json object- Parameters:
serializationState
-- Returns:
- Throws:
Throwable
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject json, SerializationState serializationState) throws Throwable
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.- Parameters:
json
-serializationState
-- Throws:
Throwable
-
toXML
public void toXML(XMLStreamWriter xsw, String alias, boolean fullSerialization, SerializationState SerializationState) throws XMLStreamException
- Throws:
XMLStreamException
-
writeExtraXMLAttributes
public void writeExtraXMLAttributes(XMLStreamWriter xsw) throws XMLStreamException
Add any attributes you want to the module tag (you must read them later).- Parameters:
xsw
-- Throws:
XMLStreamException
-
writeExtraXMLElements
public void writeExtraXMLElements(XMLStreamWriter xsw) throws XMLStreamException
Write extra elements. You must control for the opening and closing tags. These are inserted right after the state element.- Parameters:
xsw
-- Throws:
XMLStreamException
-
fromXML
public void fromXML(XMLEventReader xer, SerializationState SerializationState, boolean isTemplate) throws XMLStreamException
Used in version 2,0 serialization- Parameters:
xer
-SerializationState
-isTemplate
-- Throws:
XMLStreamException
-
getListByTag
protected List<String> getListByTag(XMLEventReader xer, String tag) throws XMLStreamException
Getting the documentation from the XML serialization 2.0.- Parameters:
xer
-- Returns:
- Throws:
XMLStreamException
-
fromXML
public void fromXML(XMLEventReader xer, edu.uiuc.ncsa.security.core.configuration.XProperties xp, QDLInterpreter qi) throws XMLStreamException
- Throws:
XMLStreamException
-
readExtraXMLAttributes
public void readExtraXMLAttributes(XMLEvent xe) throws XMLStreamException
This is passed the current event and should only have calls to read the attributes.- Parameters:
xe
-- Throws:
XMLStreamException
-
readExtraXMLElements
public void readExtraXMLElements(XMLEvent xe, XMLEventReader xer) throws XMLStreamException
This passes in the current start event so you can add your own event loop and cases. Note you need have only a switch on the tag names you want.- Parameters:
xe
-xer
-- Throws:
XMLStreamException
-
getParentTemplateID
public UUID getParentTemplateID()
-
setParentTemplateID
public void setParentTemplateID(UUID parentTemplateID)
-
getParentInstanceID
public UUID getParentInstanceID()
-
setParentInstanceID
public void setParentInstanceID(UUID parentInstanceID)
-
getParentInstanceAlias
public String getParentInstanceAlias()
-
setParentInstanceAlias
public void setParentInstanceAlias(String parentInstanceAlias)
-
getId
public UUID getId()
-
setId
public void setId(UUID id)
-
getInheritMode
public int getInheritMode()
-
setInheritanceMode
public void setInheritanceMode(int inheritMode)
-
-