public class JFunctorFactory extends Object
Created by Jeff Gaynor
on 2/27/18 at 9:07 AM
Constructor and Description |
---|
JFunctorFactory() |
JFunctorFactory(boolean verboseOn) |
Modifier and Type | Method and Description |
---|---|
protected void |
addArgs(JFunctor ff,
net.sf.json.JSONObject jsonObject) |
List<JFunctor> |
create(net.sf.json.JSONArray array)
This takes an JSONArray of JSONObjects and turns it into a list of
JFunctor s. |
JFunctor |
create(net.sf.json.JSONObject jsonObject)
This will create a single functor from the object.
|
JFunctor |
create(String rawJSON) |
LogicBlocks<? extends LogicBlock> |
createLogicBlock(net.sf.json.JSONObject jsonObject)
This creates a list of logic blocks from a JSONArray.
|
LogicBlocks |
createLogicBlocks(String rawJSON)
Convenience to create logic blocks from a string.
|
protected LogicBlock |
doLBArray(net.sf.json.JSONArray array) |
protected LogicBlock |
doLBObject(net.sf.json.JSONObject json) |
protected JMetaMetaFunctor |
figureOutFunctor(net.sf.json.JSONObject rawJson)
This figures out which functor to create based on the key of the raw JSON object.
|
JFunctor |
fromJSON(net.sf.json.JSONObject rawJson) |
protected net.sf.json.JSONArray |
getArray(net.sf.json.JSONObject jsonObject) |
Map<String,String> |
getEnvironment() |
Map<String,String> |
getReplacementTemplates()
Get all the tmeplates for all replacements.
|
protected boolean |
hasEnum(net.sf.json.JSONObject rawJson,
FunctorType type) |
boolean |
isFunctor(net.sf.json.JSONObject jsonObject) |
boolean |
isVerboseOn() |
JMetaMetaFunctor |
lookUpFunctor(FunctorType type) |
JMetaMetaFunctor |
lookUpFunctor(String name)
This does the actual work of looking up the functor and creating a new one.
|
protected String |
preprocess(String x)
This is invoked to allow for preprocessing each argument before it is added.
|
void |
setEnvironment(Map<String,String> environment) |
void |
setVerboseOn(boolean verboseOn) |
String |
toString() |
public JFunctorFactory()
public JFunctorFactory(boolean verboseOn)
public Map<String,String> getReplacementTemplates()
public boolean isVerboseOn()
public void setVerboseOn(boolean verboseOn)
public JFunctor create(net.sf.json.JSONObject jsonObject)
createLogicBlock(JSONObject)
method instead.jsonObject
- public LogicBlocks createLogicBlocks(String rawJSON)
rawJSON
- public LogicBlocks<? extends LogicBlock> createLogicBlock(net.sf.json.JSONObject jsonObject)
[{"$if":[..], "$then":[...], "$else":[...]}, {"$if":[..], "$then":[...], "$else":[...]},... ]Or a simple list of commands like
[{"$functor_1":[args]},{"$functor_2":[args]},...]which is converted to the logical block of
[{"$if":["$true"],"$then":[commands]}]I.e it is effectively always evaluated. A Third case that is handled is having these of the form
[{"$if":...},[COMMANDS]]Now, the full format is a functor of the form
{"connector":[array]}where connector is $or, $xor or $and. In the case of or or and, the entire set of blocks will evaluate and the final result will be available. In the case of xor, evaluation will cease when the first if block is found to be false. If there is simply an array and no connector, logical or is supplied as the default.
jsonObject
- protected LogicBlock doLBObject(net.sf.json.JSONObject json)
protected LogicBlock doLBArray(net.sf.json.JSONArray array)
public List<JFunctor> create(net.sf.json.JSONArray array)
JFunctor
s.array
- protected boolean hasEnum(net.sf.json.JSONObject rawJson, FunctorType type)
public JMetaMetaFunctor lookUpFunctor(FunctorType type)
public JMetaMetaFunctor lookUpFunctor(String name)
name
- protected JMetaMetaFunctor figureOutFunctor(net.sf.json.JSONObject rawJson)
rawJson
- public JFunctor fromJSON(net.sf.json.JSONObject rawJson)
protected String preprocess(String x)
x
- protected void addArgs(JFunctor ff, net.sf.json.JSONObject jsonObject)
protected net.sf.json.JSONArray getArray(net.sf.json.JSONObject jsonObject)
public boolean isFunctor(net.sf.json.JSONObject jsonObject)
Copyright © 2019. All Rights Reserved.