Package weka.knowledgeflow
Class JSONFlowUtils
java.lang.Object
weka.knowledgeflow.JSONFlowUtils
Utilities for building and saving flows from JSON data
- Author:
- Mark Hall
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringflowToJSON(Flow flow) Utility routine to serialize a supplied flow to a JSON stringstatic FlowJSONToFlow(String flowJSON, boolean dontComplainAboutMissingConnections) Utility routine to deserialize a flow from the supplied JSON stringstatic voidMain method for testing this classstatic FlowRead a flow from the supplied filestatic FlowRead a flow from the supplied filestatic FlowreadFlow(InputStream is) Read a Flow from the supplied input streamstatic FlowreadFlow(InputStream is, boolean dontComplainAboutMissingConnections) Read a Flow from the supplied input streamstatic FlowRead a flow from the supplied readerstatic FlowRead a flow from the supplied readerstatic voidSerializes the supplied flow to JSON and writes it out to the supplied filestatic voidwriteFlow(Flow flow, OutputStream os) Serializes the supplied flow to JSON and writes out using the supplied output streamstatic voidSerializes the supplied flow to JSON and writes out using the supplied writer
-
Field Details
-
FLOW_NAME
- See Also:
-
STEPS
- See Also:
-
OPTIONHANDLER
- See Also:
-
OPTIONS
- See Also:
-
LOADER
- See Also:
-
SAVER
- See Also:
-
ENUM_HELPER
- See Also:
-
CLASS
- See Also:
-
PROPERTIES
- See Also:
-
CONNECTIONS
- See Also:
-
COORDINATES
- See Also:
-
-
Constructor Details
-
JSONFlowUtils
public JSONFlowUtils()
-
-
Method Details
-
writeFlow
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
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
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
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(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
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(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
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(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(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
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
Main method for testing this class- Parameters:
args- command line arguments
-