weka.knowledgeflow

## Class JSONFlowUtils

- java.lang.Object
- - weka.knowledgeflow.JSONFlowUtils

-     public class JSONFlowUtils
      extends java.lang.Object

  Utilities for building and saving flows from JSON data
  Author:
    Mark Hall

- - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `JSONFlowUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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
    `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
    `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

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

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

- - ### 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

  - ### Constructor Detail

    - #### JSONFlowUtils

          public JSONFlowUtils()

  - ### 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` - the `Flow` to serialize
        `writer` - the `Writer` to 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` - the `Flow` to serialize
        `os` - the `OutputStream` to 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` - the `Flow` to serialize
        `file` - the `File` to 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 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(java.io.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(java.io.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(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 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(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 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 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