Package org.qdl_lang.util
Class ModuleUtils
- java.lang.Object
-
- org.qdl_lang.util.ModuleUtils
-
- All Implemented Interfaces:
Serializable
public class ModuleUtils extends Object implements Serializable
Created by Jeff Gaynor
on 11/21/23 at 7:55 AM- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ModuleUtils()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyState(Module module, net.sf.json.JSONObject serializedState)
For modules only.QDLStem
convertArgsToStem(Polyad polyad, Object arg, State state, String component)
Converts a couple of different arguments to the form [[a0{,b0}],[a1{,b1}],...,[an{,bn}] or (if a single argument that is a stem) can pass back:Module
deserializeFromJSON(State state, net.sf.json.JSONObject json, boolean useModule, SerializationState serializationState)
Module
deserializeFromJSON(State state, net.sf.json.JSONObject json, SerializationState serializationState)
This starts the load from the JSON since which type of module to instantiate is needed, so the right module has to exist beforeModule.deserializeFromJSON(JSONObject, SerializationState)
can be called.void
deserializeUsedModules(State state, net.sf.json.JSONArray jsonArray, SerializationState serializationState)
List<String>
doJavaModuleLoad(State state, String resourceName, JavaModuleConfig javaModuleConfig)
Load a single java module, returning a null if it failed or the FQ name if it worked.List<String>
doQDLModuleLoad(State state, String resourceName)
Load the module(s) in a single resource.protected net.sf.json.JSONArray
getStack(net.sf.json.JSONObject state, String tag)
net.sf.json.JSONArray
serializeUsedModules(State state, SerializationState serializationState)
void
updateSerializedState(net.sf.json.JSONObject jsonObject, State state, SerializationState serializationState)
There are two steps to deserialzing a workspace.void
updateUsedModuleState(net.sf.json.JSONObject jsonObject, State state, SerializationState serializationState)
-
-
-
Method Detail
-
convertArgsToStem
public QDLStem convertArgsToStem(Polyad polyad, Object arg, State state, String component)
Converts a couple of different arguments to the form [[a0{,b0}],[a1{,b1}],...,[an{,bn}] or (if a single argument that is a stem) can pass back:{key0:[[a0{,b0}], key1:[a1{,b1}],...}
where the bk are optional. All ak, bk are strings. a,b -> [[a,b]] (pair of arguments, function is dyadic [a,b] ->[[a,b]] (simple list, convert to nested list [a0,a1,...] -> [[a0],[a1],...] allow for scalars Use in both module import and load for consistent arguments
- Parameters:
polyad
-state
-component
-- Returns:
-
doJavaModuleLoad
public List<String> doJavaModuleLoad(State state, String resourceName, JavaModuleConfig javaModuleConfig)
Load a single java module, returning a null if it failed or the FQ name if it worked.- Parameters:
state
-resourceName
-
-
doQDLModuleLoad
public List<String> doQDLModuleLoad(State state, String resourceName)
Load the module(s) in a single resource.- Parameters:
state
-resourceName
-- Returns:
-
deserializeFromJSON
public Module deserializeFromJSON(State state, net.sf.json.JSONObject json, SerializationState serializationState) throws Throwable
This starts the load from the JSON since which type of module to instantiate is needed, so the right module has to exist beforeModule.deserializeFromJSON(JSONObject, SerializationState)
can be called.- Parameters:
state
-json
-- Returns:
- Throws:
Throwable
-
deserializeFromJSON
public Module deserializeFromJSON(State state, net.sf.json.JSONObject json, boolean useModule, SerializationState serializationState) throws Throwable
- Parameters:
state
-json
-useModule
- if this module is used (i.e. imported to current scope) vs. importedserializationState
-- Returns:
- Throws:
Throwable
-
updateUsedModuleState
public void updateUsedModuleState(net.sf.json.JSONObject jsonObject, State state, SerializationState serializationState) throws Throwable
- Throws:
Throwable
-
updateSerializedState
public void updateSerializedState(net.sf.json.JSONObject jsonObject, State state, SerializationState serializationState) throws Throwable
There are two steps to deserialzing a workspace. First, run the QDL which sets up the (arbitrarily complex) network of objects. Then make a second pass with any state objects that have been updated.- Parameters:
jsonObject
-serializationState
-- Throws:
Throwable
-
serializeUsedModules
public net.sf.json.JSONArray serializeUsedModules(State state, SerializationState serializationState) throws Throwable
- Throws:
Throwable
-
deserializeUsedModules
public void deserializeUsedModules(State state, net.sf.json.JSONArray jsonArray, SerializationState serializationState) throws Throwable
- Throws:
Throwable
-
getStack
protected net.sf.json.JSONArray getStack(net.sf.json.JSONObject state, String tag)
-
applyState
protected void applyState(Module module, net.sf.json.JSONObject serializedState)
For modules only. Applies the serialized module state. If the module was created with the shared state, then only the local tables are updated.- Parameters:
module
-serializedState
-
-
-