Class JSONFlowUtils


  • public class JSONFlowUtils
    extends java.lang.Object
    Utilities for building and saving flows from JSON data
    Author:
    Mark Hall
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONFlowUtils()  
    • Method Summary

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