public class JSONFlowUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS |
static java.lang.String |
CONNECTIONS |
static java.lang.String |
COORDINATES |
static java.lang.String |
ENUM_HELPER |
static java.lang.String |
FLOW_NAME |
static java.lang.String |
LOADER |
static java.lang.String |
OPTIONHANDLER |
static java.lang.String |
OPTIONS |
static java.lang.String |
PROPERTIES |
static java.lang.String |
SAVER |
static java.lang.String |
STEPS |
| Constructor and Description |
|---|
JSONFlowUtils() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addEnum(java.lang.String propName,
java.lang.Enum ee,
JSONNode json)
Add an enum to the JSON
|
protected static void |
addLoader(java.lang.String propName,
Loader loader,
JSONNode json)
Add a
weka.core.converters.Loader to the JSON |
protected static void |
addNameValue(java.lang.StringBuilder b,
java.lang.String name,
java.lang.String value,
boolean comma)
Add a name,value pair to the JSON
|
protected static void |
addOptionHandler(java.lang.String propName,
OptionHandler handler,
JSONNode json)
Add an
OptionHandler spec to the JSON |
protected static void |
addSaver(java.lang.String propName,
Saver saver,
JSONNode json)
Add a
weka.core.converters.Saver to the JSON |
protected static void |
addStepJSONtoFlowArray(JSONNode stepArray,
StepManagerImpl stepManager)
Add a step to the JSON
|
protected static java.io.File |
checkForFileProp(java.lang.Object theValue,
java.beans.PropertyDescriptor propD)
Checks a property to see if it is tagged with the FilePropertyMetadata
class.
|
static java.lang.String |
flowToJSON(Flow flow)
Utility routine to serialize a supplied flow to a JSON string
|
static Flow |
JSONToFlow(java.lang.String flowJSON,
boolean dontComplainAboutMissingConnections)
Utility routine to deserialize a flow from the supplied JSON string
|
static void |
main(java.lang.String[] args)
Main method for testing this class
|
protected static void |
readConnectionsForStep(JSONNode step,
Flow flow)
Read step connections from the supplied JSON node
|
protected static void |
readConnectionsForStep(JSONNode step,
Flow flow,
boolean dontComplainAboutMissingConnections)
Read step connections from the supplied JSON node
|
static Flow |
readFlow(java.io.File file)
Read a flow from the supplied file
|
static Flow |
readFlow(java.io.File file,
boolean dontComplainAboutMissingConnections)
Read a flow from the supplied file
|
static Flow |
readFlow(java.io.InputStream is)
Read a Flow from the supplied input stream
|
static Flow |
readFlow(java.io.InputStream is,
boolean dontComplainAboutMissingConnections)
Read a Flow from the supplied input stream
|
static Flow |
readFlow(java.io.Reader sr)
Read a flow from the supplied reader
|
static Flow |
readFlow(java.io.Reader sr,
boolean dontComplainAboutMissingConnections)
Read a flow from the supplied reader
|
protected static void |
readStep(JSONNode stepNode,
Flow flow)
Read a
Step from the supplied JSON node |
protected static java.lang.Object |
readStepObjectProperty(JSONNode propNode)
Read a step property object from the current JSON node.
|
protected static java.lang.Object |
readStepPropertyEnum(JSONNode enumNode)
Read an enum from the current JSON node
|
protected static Loader |
readStepPropertyLoader(JSONNode loaderNode)
Read a
weka.core.converters.Loader from the current JSON node |
protected static OptionHandler |
readStepPropertyOptionHandler(JSONNode optionHNode)
Read an
OptionHandler from the current JSON node |
protected static Saver |
readStepPropertySaver(JSONNode saverNode)
Read a
weka.core.converters.Saver from the current JSON node |
static void |
writeFlow(Flow flow,
java.io.File file)
Serializes the supplied flow to JSON and writes it out to the supplied file
|
static void |
writeFlow(Flow flow,
java.io.OutputStream os)
Serializes the supplied flow to JSON and writes out using the supplied
output stream
|
static void |
writeFlow(Flow flow,
java.io.Writer writer)
Serializes the supplied flow to JSON and writes out using the supplied
writer
|
public static final java.lang.String FLOW_NAME
public static final java.lang.String STEPS
public static final java.lang.String OPTIONHANDLER
public static final java.lang.String OPTIONS
public static final java.lang.String LOADER
public static final java.lang.String SAVER
public static final java.lang.String ENUM_HELPER
public static final java.lang.String CLASS
public static final java.lang.String PROPERTIES
public static final java.lang.String CONNECTIONS
public static final java.lang.String COORDINATES
protected static void addNameValue(java.lang.StringBuilder b,
java.lang.String name,
java.lang.String value,
boolean comma)
b - the StringBuilder to add the pair toname - the namevalue - the associated valuecomma - if true postfix a commaprotected static void addOptionHandler(java.lang.String propName,
OptionHandler handler,
JSONNode json)
OptionHandler spec to the JSONpropName - the name to associate with the option handlerhandler - the option handlerjson - the current to add toprotected static void addEnum(java.lang.String propName,
java.lang.Enum ee,
JSONNode json)
propName - the name to associate the enum withee - the enum to addjson - the current JSONNode to add toprotected static void addSaver(java.lang.String propName,
Saver saver,
JSONNode json)
weka.core.converters.Saver to the JSONpropName - the name to associate the saver withsaver - the saver to addjson - the current JSONNode to add toprotected static void addLoader(java.lang.String propName,
Loader loader,
JSONNode json)
weka.core.converters.Loader to the JSONpropName - the name to associate the loader withloader - the loader to addjson - the curren JSONNode to add toprotected static void addStepJSONtoFlowArray(JSONNode stepArray, StepManagerImpl stepManager) throws WekaException
stepArray - the JSONNode to add the step tostepManager - the StepManager of the step to addWekaException - if a problem occursprotected static Loader readStepPropertyLoader(JSONNode loaderNode) throws WekaException
weka.core.converters.Loader from the current JSON nodeloaderNode - the JSONNode to read the loader fromWekaException - if a problem occursprotected static Saver readStepPropertySaver(JSONNode saverNode) throws WekaException
weka.core.converters.Saver from the current JSON nodesaverNode - the JSONNode to read fromWekaException - if a problem occursprotected static OptionHandler readStepPropertyOptionHandler(JSONNode optionHNode) throws WekaException
OptionHandler from the current JSON nodeoptionHNode - the JSONNode to read fromWekaException - if a problem occursprotected static java.lang.Object readStepPropertyEnum(JSONNode enumNode) throws WekaException
enumNode - the JSONNode to read fromWekaException - if a problem occursprotected static java.lang.Object readStepObjectProperty(JSONNode propNode) throws java.lang.Exception
propNode - the JSONNode to read fromjava.lang.Exception - if a problem occursprotected static java.io.File checkForFileProp(java.lang.Object theValue,
java.beans.PropertyDescriptor propD)
theValue - the value of the propertypropD - the PropertyDescriptor for the propertyprotected static void readStep(JSONNode stepNode, Flow flow) throws WekaException
Step from the supplied JSON nodestepNode - the JSONNode to read fromflow - the Flow to add the read step toWekaException - if a problem occursprotected static void readConnectionsForStep(JSONNode step, Flow flow) throws WekaException
step - the JSONNode to read fromflow - the flow being constructedWekaException - if a problem occursprotected static void readConnectionsForStep(JSONNode step, Flow flow, boolean dontComplainAboutMissingConnections) throws WekaException
step - the JSONNode to read fromflow - the flow being constructeddontComplainAboutMissingConnections - true if no exception should be
raised if the step named in a connection is not present in the
flowWekaException - if a problem occurspublic static void writeFlow(Flow flow, java.io.Writer writer) throws WekaException
flow - the Flow to serializewriter - the Writer to write toWekaException - if a problem occurspublic static void writeFlow(Flow flow, java.io.OutputStream os) throws WekaException
flow - the Flow to serializeos - the OutputStream to write toWekaException - if a problem occurspublic static void writeFlow(Flow flow, java.io.File file) throws WekaException
flow - the Flow to serializefile - the File to write toWekaException - if a problem occurspublic static Flow readFlow(java.io.File file) throws WekaException
file - the file to read fromFlowWekaException - if a problem occurspublic static Flow readFlow(java.io.File file, boolean dontComplainAboutMissingConnections) throws WekaException
file - the file to read fromdontComplainAboutMissingConnections - true if no exceptions should be
raised if connections are missing in the flowWekaException - if a problem occurspublic static Flow readFlow(java.io.InputStream is) throws WekaException
is - the InputStream to read fromWekaException - if a problem occurspublic static Flow readFlow(java.io.InputStream is, boolean dontComplainAboutMissingConnections) throws WekaException
is - the InputStream to read fromdontComplainAboutMissingConnections - true if no exception should be
raised if there are missing connectionsWekaException - if a problem occurspublic static Flow readFlow(java.io.Reader sr) throws WekaException
sr - the reader to read fromWekaException - if a problem occurspublic static Flow readFlow(java.io.Reader sr, boolean dontComplainAboutMissingConnections) throws WekaException
sr - the reader to read fromdontComplainAboutMissingConnections - true if no exception should be
raised if there are missing connectionsWekaException - if a problem occurspublic static Flow JSONToFlow(java.lang.String flowJSON, boolean dontComplainAboutMissingConnections) throws WekaException
flowJSON - the string containing a flow in JSON formdontComplainAboutMissingConnections - to not raise any exceptions if
there are missing connections in the flowWekaException - if a problem occurspublic static java.lang.String flowToJSON(Flow flow) throws WekaException
flow - the flow to serializeWekaException - if a problem occurspublic static void main(java.lang.String[] args)
args - command line arguments