Class DrawflowGraphFormat
- java.lang.Object
-
- de.iip_ecosphere.platform.configuration.DrawflowGraphFormat
-
- All Implemented Interfaces:
GraphFormat
public class DrawflowGraphFormat extends java.lang.Object implements GraphFormat
Writes a graph in the "drawflow" format.- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDrawflowGraphFormat.GraphReaderImplements a graph reader.private static classDrawflowGraphFormat.GraphWriterInstance to map and write a graph.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAME
-
Constructor Summary
Constructors Constructor Description DrawflowGraphFormat()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IvmlGraphMapper.IvmlGraphfromString(java.lang.String graph, GraphFactory factory, DecisionVariableProvider varProvider)Parsesgraphfrom this format into an IVML graph structure.java.lang.StringgetFormatKind()Returns the kind of format produced.private static intgetInteger(org.json.simple.JSONObject object, java.lang.String field, int dflt)Obtains an int fromobject.private static <T> TgetJson(org.json.simple.JSONObject object, java.lang.String field, java.lang.Class<T> cls, java.util.function.Supplier<T> dflt, java.util.function.Function<java.lang.Object,T> converter)Obtains a JSON object fromobject.private static org.json.simple.JSONArraygetJsonArray(org.json.simple.JSONObject object, java.lang.String field)Obtains a JSON array fromobject.private static org.json.simple.JSONObjectgetJsonObject(org.json.simple.JSONObject object, java.lang.String field)Obtains a JSON object fromobject.java.lang.StringgetName()Returns the name to address/access this format.private static java.lang.StringgetString(org.json.simple.JSONObject object, java.lang.String field, java.lang.String dflt)Obtains a string fromobject.java.lang.StringtoString(IvmlGraphMapper.IvmlGraph graph)Turnsgraphinto this format.
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:GraphFormatReturns the name to address/access this format.- Specified by:
getNamein interfaceGraphFormat- Returns:
- the unique name
-
getFormatKind
public java.lang.String getFormatKind()
Description copied from interface:GraphFormatReturns the kind of format produced.- Specified by:
getFormatKindin interfaceGraphFormat- Returns:
- the format kind, e.g., XML, JSON, ...
-
toString
public java.lang.String toString(IvmlGraphMapper.IvmlGraph graph) throws java.util.concurrent.ExecutionException
Description copied from interface:GraphFormatTurnsgraphinto this format.- Specified by:
toStringin interfaceGraphFormat- Parameters:
graph- the graph, may be null- Returns:
- the formatted graph, an empty graph if
graphis null - Throws:
java.util.concurrent.ExecutionException- if the translation fails
-
fromString
public IvmlGraphMapper.IvmlGraph fromString(java.lang.String graph, GraphFactory factory, DecisionVariableProvider varProvider) throws java.util.concurrent.ExecutionException
Description copied from interface:GraphFormatParsesgraphfrom this format into an IVML graph structure.- Specified by:
fromStringin interfaceGraphFormat- Parameters:
graph- the graph, may be nullfactory- a factory to be used to create graph instancesvarProvider- the provider allowing to access variables- Returns:
- the IVML graph structure, an empty graph if
graphis null - Throws:
java.util.concurrent.ExecutionException- if the translation fails
-
getJson
private static <T> T getJson(org.json.simple.JSONObject object, java.lang.String field, java.lang.Class<T> cls, java.util.function.Supplier<T> dflt, java.util.function.Function<java.lang.Object,T> converter)Obtains a JSON object fromobject.- Type Parameters:
T- the type to be returned- Parameters:
object- the object to read fromfield- the field name to read from withinobjectcls- the type as classdflt- the default value iffielddoes not existconverter- optional converter if the found value is not compliant withcls, 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, java.lang.String field)Obtains a JSON object fromobject.- Parameters:
object- the object to read fromfield- 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, java.lang.String field)Obtains a JSON array fromobject.- Parameters:
object- the object to read fromfield- the field name- Returns:
- returns the JSON array, or, if not found, an empty JSON array
-
getString
private static java.lang.String getString(org.json.simple.JSONObject object, java.lang.String field, java.lang.String dflt)Obtains a string fromobject.- Parameters:
object- the object to read fromfield- the field namedflt- the default value- Returns:
- returns the string or, if not found,
dflt
-
getInteger
private static int getInteger(org.json.simple.JSONObject object, java.lang.String field, int dflt)Obtains an int fromobject.- Parameters:
object- the object to read fromfield- the field namedflt- the default value- Returns:
- returns the int value or, if not found,
dflt
-
-