Package weka.knowledgeflow
Class JSONFlowUtils
- java.lang.Object
-
- weka.knowledgeflow.JSONFlowUtils
-
public class JSONFlowUtils extends java.lang.ObjectUtilities for building and saving flows from JSON data- Author:
- Mark Hall
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASSstatic java.lang.StringCONNECTIONSstatic java.lang.StringCOORDINATESstatic java.lang.StringENUM_HELPERstatic java.lang.StringFLOW_NAMEstatic java.lang.StringLOADERstatic java.lang.StringOPTIONHANDLERstatic java.lang.StringOPTIONSstatic java.lang.StringPROPERTIESstatic java.lang.StringSAVERstatic java.lang.StringSTEPS
-
Constructor Summary
Constructors Constructor Description JSONFlowUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringflowToJSON(Flow flow)Utility routine to serialize a supplied flow to a JSON stringstatic FlowJSONToFlow(java.lang.String flowJSON, boolean dontComplainAboutMissingConnections)Utility routine to deserialize a flow from the supplied JSON stringstatic voidmain(java.lang.String[] args)Main method for testing this classstatic FlowreadFlow(java.io.File file)Read a flow from the supplied filestatic FlowreadFlow(java.io.File file, boolean dontComplainAboutMissingConnections)Read a flow from the supplied filestatic FlowreadFlow(java.io.InputStream is)Read a Flow from the supplied input streamstatic FlowreadFlow(java.io.InputStream is, boolean dontComplainAboutMissingConnections)Read a Flow from the supplied input streamstatic FlowreadFlow(java.io.Reader sr)Read a flow from the supplied readerstatic FlowreadFlow(java.io.Reader sr, boolean dontComplainAboutMissingConnections)Read a flow from the supplied readerstatic voidwriteFlow(Flow flow, java.io.File file)Serializes the supplied flow to JSON and writes it out to the supplied filestatic voidwriteFlow(Flow flow, java.io.OutputStream os)Serializes the supplied flow to JSON and writes out using the supplied output streamstatic voidwriteFlow(Flow flow, java.io.Writer writer)Serializes the supplied flow to JSON and writes out using the supplied writer
-
-
-
Field Detail
-
FLOW_NAME
public static final java.lang.String FLOW_NAME
- See Also:
- Constant Field Values
-
STEPS
public static final java.lang.String STEPS
- See Also:
- Constant Field Values
-
OPTIONHANDLER
public static final java.lang.String OPTIONHANDLER
- See Also:
- Constant Field Values
-
OPTIONS
public static final java.lang.String OPTIONS
- See Also:
- Constant Field Values
-
LOADER
public static final java.lang.String LOADER
- See Also:
- Constant Field Values
-
SAVER
public static final java.lang.String SAVER
- See Also:
- Constant Field Values
-
ENUM_HELPER
public static final java.lang.String ENUM_HELPER
- See Also:
- Constant Field Values
-
CLASS
public static final java.lang.String CLASS
- See Also:
- Constant Field Values
-
PROPERTIES
public static final java.lang.String PROPERTIES
- See Also:
- Constant Field Values
-
CONNECTIONS
public static final java.lang.String CONNECTIONS
- See Also:
- Constant Field Values
-
COORDINATES
public static final java.lang.String COORDINATES
- See Also:
- Constant Field Values
-
-
Method Detail
-
writeFlow
public static void writeFlow(Flow flow, java.io.Writer writer) throws WekaException
Serializes the supplied flow to JSON and writes out using the supplied writer- Parameters:
flow- theFlowto serializewriter- theWriterto write to- Throws:
WekaException- if a problem occurs
-
writeFlow
public static void writeFlow(Flow flow, java.io.OutputStream os) throws WekaException
Serializes the supplied flow to JSON and writes out using the supplied output stream- Parameters:
flow- theFlowto serializeos- theOutputStreamto write to- Throws:
WekaException- if a problem occurs
-
writeFlow
public static void writeFlow(Flow flow, java.io.File file) throws WekaException
Serializes the supplied flow to JSON and writes it out to the supplied file- Parameters:
flow- theFlowto serializefile- theFileto write to- Throws:
WekaException- if a problem occurs
-
readFlow
public static Flow readFlow(java.io.File file) throws WekaException
Read a flow from the supplied file- Parameters:
file- the file to read from- Returns:
- the deserialized
Flow - Throws:
WekaException- if a problem occurs
-
readFlow
public static Flow readFlow(java.io.File file, boolean dontComplainAboutMissingConnections) throws WekaException
Read a flow from the supplied file- Parameters:
file- the file to read fromdontComplainAboutMissingConnections- true if no exceptions should be raised if connections are missing in the flow- Returns:
- the deserialized Flow
- Throws:
WekaException- if a problem occurs
-
readFlow
public static Flow readFlow(java.io.InputStream is) throws WekaException
Read a Flow from the supplied input stream- Parameters:
is- theInputStreamto read from- Returns:
- the deserialized flow
- Throws:
WekaException- if a problem occurs
-
readFlow
public static Flow readFlow(java.io.InputStream is, boolean dontComplainAboutMissingConnections) throws WekaException
Read a Flow from the supplied input stream- Parameters:
is- theInputStreamto read fromdontComplainAboutMissingConnections- true if no exception should be raised if there are missing connections- Returns:
- the deserialized flow
- Throws:
WekaException- if a problem occurs
-
readFlow
public static Flow readFlow(java.io.Reader sr) throws WekaException
Read a flow from the supplied reader- Parameters:
sr- the reader to read from- Returns:
- the deserialized flow
- Throws:
WekaException- if a problem occurs
-
readFlow
public static Flow readFlow(java.io.Reader sr, boolean dontComplainAboutMissingConnections) throws WekaException
Read a flow from the supplied reader- Parameters:
sr- the reader to read fromdontComplainAboutMissingConnections- true if no exception should be raised if there are missing connections- Returns:
- the deserialized flow
- Throws:
WekaException- if a problem occurs
-
JSONToFlow
public static Flow JSONToFlow(java.lang.String flowJSON, boolean dontComplainAboutMissingConnections) throws WekaException
Utility routine to deserialize a flow from the supplied JSON string- Parameters:
flowJSON- the string containing a flow in JSON formdontComplainAboutMissingConnections- to not raise any exceptions if there are missing connections in the flow- Returns:
- the deserialized flow
- Throws:
WekaException- if a problem occurs
-
flowToJSON
public static java.lang.String flowToJSON(Flow flow) throws WekaException
Utility routine to serialize a supplied flow to a JSON string- Parameters:
flow- the flow to serialize- Returns:
- a string containing the flow in JSON form
- Throws:
WekaException- if a problem occurs
-
main
public static void main(java.lang.String[] args)
Main method for testing this class- Parameters:
args- command line arguments
-
-