Class DrawflowGraphFormat

java.lang.Object
de.iip_ecosphere.platform.configuration.DrawflowGraphFormat
All Implemented Interfaces:
GraphFormat

public class DrawflowGraphFormat extends Object implements GraphFormat
Writes a graph in the "drawflow" format.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • DrawflowGraphFormat

      public DrawflowGraphFormat()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: GraphFormat
      Returns the name to address/access this format.
      Specified by:
      getName in interface GraphFormat
      Returns:
      the unique name
    • getFormatKind

      public String getFormatKind()
      Description copied from interface: GraphFormat
      Returns the kind of format produced.
      Specified by:
      getFormatKind in interface GraphFormat
      Returns:
      the format kind, e.g., XML, JSON, ...
    • toString

      public String toString(IvmlGraphMapper.IvmlGraph graph) throws ExecutionException
      Description copied from interface: GraphFormat
      Turns graph into this format.
      Specified by:
      toString in interface GraphFormat
      Parameters:
      graph - the graph, may be null
      Returns:
      the formatted graph, an empty graph if graph is null
      Throws:
      ExecutionException - if the translation fails
    • fromString

      public IvmlGraphMapper.IvmlGraph fromString(String graph, GraphFactory factory, DecisionVariableProvider varProvider) throws ExecutionException
      Description copied from interface: GraphFormat
      Parses graph from this format into an IVML graph structure.
      Specified by:
      fromString in interface GraphFormat
      Parameters:
      graph - the graph, may be null
      factory - a factory to be used to create graph instances
      varProvider - the provider allowing to access variables
      Returns:
      the IVML graph structure, an empty graph if graph is null
      Throws:
      ExecutionException - if the translation fails
    • getJson

      private static <T> T getJson(org.json.simple.JSONObject object, String field, Class<T> cls, Supplier<T> dflt, Function<Object,T> converter)
      Obtains a JSON object from object.
      Type Parameters:
      T - the type to be returned
      Parameters:
      object - the object to read from
      field - the field name to read from within object
      cls - the type as class
      dflt - the default value if field does not exist
      converter - optional converter if the found value is not compliant with cls, may be null
      Returns:
      returns the JSON object or, if not found, an empty JSON object
    • getJsonObject

      private static org.json.simple.JSONObject getJsonObject(org.json.simple.JSONObject object, String field)
      Obtains a JSON object from object.
      Parameters:
      object - the object to read from
      field - the field name
      Returns:
      returns the JSON object or, if not found, an empty JSON object
    • getJsonArray

      private static org.json.simple.JSONArray getJsonArray(org.json.simple.JSONObject object, String field)
      Obtains a JSON array from object.
      Parameters:
      object - the object to read from
      field - the field name
      Returns:
      returns the JSON array, or, if not found, an empty JSON array
    • getString

      private static String getString(org.json.simple.JSONObject object, String field, String dflt)
      Obtains a string from object.
      Parameters:
      object - the object to read from
      field - the field name
      dflt - the default value
      Returns:
      returns the string or, if not found, dflt
    • getInteger

      private static int getInteger(org.json.simple.JSONObject object, String field, int dflt)
      Obtains an int from object.
      Parameters:
      object - the object to read from
      field - the field name
      dflt - the default value
      Returns:
      returns the int value or, if not found, dflt