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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
flowToJSON
(Flow flow) Utility routine to serialize a supplied flow to a JSON stringstatic Flow
JSONToFlow
(String flowJSON, boolean dontComplainAboutMissingConnections) Utility routine to deserialize a flow from the supplied JSON stringstatic void
Main method for testing this classstatic Flow
Read a flow from the supplied filestatic Flow
Read a flow from the supplied filestatic Flow
readFlow
(InputStream is) Read a Flow from the supplied input streamstatic Flow
readFlow
(InputStream is, boolean dontComplainAboutMissingConnections) Read a Flow from the supplied input streamstatic Flow
Read a flow from the supplied readerstatic Flow
Read a flow from the supplied readerstatic void
Serializes the supplied flow to JSON and writes it out to the supplied filestatic void
writeFlow
(Flow flow, OutputStream os) Serializes the supplied flow to JSON and writes out using the supplied output streamstatic void
Serializes 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
- theFlow
to serializewriter
- theWriter
to 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
- theFlow
to serializeos
- theOutputStream
to 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
- theFlow
to serializefile
- theFile
to 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
- theInputStream
to 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
- theInputStream
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
-
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
-