Package weka.knowledgeflow

# Class JSONFlowUtils

java.lang.Object
weka.knowledgeflow.JSONFlowUtils

public class JSONFlowUtils extends Object
Utilities for building and saving flows from JSON data

Author:
  Mark Hall

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CLASS`
  `static final String`
  `CONNECTIONS`
  `static final String`
  `COORDINATES`
  `static final String`
  `ENUM_HELPER`
  `static final String`
  `FLOW_NAME`
  `static final String`
  `LOADER`
  `static final String`
  `OPTIONHANDLER`
  `static final String`
  `OPTIONS`
  `static final String`
  `PROPERTIES`
  `static final String`
  `SAVER`
  `static final String`
  `STEPS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JSONFlowUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `flowToJSON(Flow flow)`
  Utility routine to serialize a supplied flow to a JSON string
  `static Flow`
  `JSONToFlow(String flowJSON, boolean dontComplainAboutMissingConnections)`
  Utility routine to deserialize a flow from the supplied JSON string
  `static void`
  `main(String[] args)`
  Main method for testing this class
  `static Flow`
  `readFlow(File file)`
  Read a flow from the supplied file
  `static Flow`
  `readFlow(File file, boolean dontComplainAboutMissingConnections)`
  Read a flow from the supplied file
  `static Flow`
  `readFlow(InputStream is)`
  Read a Flow from the supplied input stream
  `static Flow`
  `readFlow(InputStream is, boolean dontComplainAboutMissingConnections)`
  Read a Flow from the supplied input stream
  `static Flow`
  `readFlow(Reader sr)`
  Read a flow from the supplied reader
  `static Flow`
  `readFlow(Reader sr, boolean dontComplainAboutMissingConnections)`
  Read a flow from the supplied reader
  `static void`
  `writeFlow(Flow flow, File file)`
  Serializes the supplied flow to JSON and writes it out to the supplied file
  `static void`
  `writeFlow(Flow flow, OutputStream os)`
  Serializes the supplied flow to JSON and writes out using the supplied output stream
  `static void`
  `writeFlow(Flow flow, Writer writer)`
  Serializes the supplied flow to JSON and writes out using the supplied writer

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### FLOW_NAME

    public static final String FLOW_NAME
    See Also:
      - Constant Field Values

  - ### STEPS

    public static final String STEPS
    See Also:
      - Constant Field Values

  - ### OPTIONHANDLER

    public static final String OPTIONHANDLER
    See Also:
      - Constant Field Values

  - ### OPTIONS

    public static final String OPTIONS
    See Also:
      - Constant Field Values

  - ### LOADER

    public static final String LOADER
    See Also:
      - Constant Field Values

  - ### SAVER

    public static final String SAVER
    See Also:
      - Constant Field Values

  - ### ENUM_HELPER

    public static final String ENUM_HELPER
    See Also:
      - Constant Field Values

  - ### CLASS

    public static final String CLASS
    See Also:
      - Constant Field Values

  - ### PROPERTIES

    public static final String PROPERTIES
    See Also:
      - Constant Field Values

  - ### CONNECTIONS

    public static final String CONNECTIONS
    See Also:
      - Constant Field Values

  - ### COORDINATES

    public static final String COORDINATES
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### JSONFlowUtils

    public JSONFlowUtils()

- ## Method Details

  - ### writeFlow

    public static void writeFlow(Flow flow, Writer writer) throws WekaException
    Serializes the supplied flow to JSON and writes out using the supplied writer
    Parameters:
      `flow` - the `Flow` to serialize
      `writer` - the `Writer` to write to
    Throws:
      `WekaException` - if a problem occurs

  - ### writeFlow

    public static void writeFlow(Flow flow, OutputStream os) throws WekaException
    Serializes the supplied flow to JSON and writes out using the supplied output stream
    Parameters:
      `flow` - the `Flow` to serialize
      `os` - the `OutputStream` to write to
    Throws:
      `WekaException` - if a problem occurs

  - ### writeFlow

    public static void writeFlow(Flow flow, File file) throws WekaException
    Serializes the supplied flow to JSON and writes it out to the supplied file
    Parameters:
      `flow` - the `Flow` to serialize
      `file` - the `File` to write to
    Throws:
      `WekaException` - if a problem occurs

  - ### readFlow

    public static Flow readFlow(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(File file, boolean dontComplainAboutMissingConnections) throws WekaException
    Read a flow from the supplied file
    Parameters:
      `file` - the file to read from
      `dontComplainAboutMissingConnections` - 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(InputStream is) throws WekaException
    Read a Flow from the supplied input stream
    Parameters:
      `is` - the `InputStream` 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` - the `InputStream` to read from
      `dontComplainAboutMissingConnections` - 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(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(Reader sr, boolean dontComplainAboutMissingConnections) throws WekaException
    Read a flow from the supplied reader
    Parameters:
      `sr` - the reader to read from
      `dontComplainAboutMissingConnections` - 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 form
      `dontComplainAboutMissingConnections` - 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 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(String[] args)
    Main method for testing this class
    Parameters:
      `args` - command line arguments