Class GraphDotProductionWriter

    • Method Detail

      • markEndOfLine

        public final void markEndOfLine()
        Queues a line break for the next time a production is written.
      • outputLineBreakIfRequested

        public final void outputLineBreakIfRequested​(int indentDeltaDirection)
                                              throws IOException
        Writes a new line, if queued by markEndOfLine(), decreases or increases the indent if requested, and writes the indent for the new indent level.
        Parameters:
        indentDeltaDirection - Negative to decrease the indent, positive to increase the indent, zero to keep the indent.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAssignment

        public final void writeProductionAssignment​(CharSequence name,
                                                    Object value)
                                             throws IOException
        Writes an assignment production.
         ID '=' ID
         
        Parameters:
        name - Name of the property.
        value - Value of the property.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAssignment

        public final void writeProductionAssignment​(Map.Entry<? extends CharSequence,​? extends Object> keyValuePair)
                                             throws IOException
        Writes an assignment production.
         ID '=' ID
         
        Parameters:
        keyValuePair - Name and value to write.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAssignmentStatement

        public final void writeProductionAssignmentStatement​(CharSequence name,
                                                             Object value)
                                                      throws IOException
        Writes an assignment statement production.
         ID '=' ID;
         
        Parameters:
        name - Name of the property, must not be null nor empty.
        value - Value of the property, converted to a char sequence.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAssignmentStatement

        public final void writeProductionAssignmentStatement​(Map.Entry<? extends CharSequence,​? extends Object> keyValuePair)
                                                      throws IOException
        Writes an assignment statement production.
         ID '=' ID;
         
        Parameters:
        keyValuePair - Name and value to write.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAttributeList

        public final void writeProductionAttributeList​(Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                throws IOException
        Writes a list of attributes.
         attr_list  : '[' [ a_list ] ']' [ attr_list ]
         a_list     : ID '=' ID [ (';' | ',') ] [ a_list ]
         
        Parameters:
        attributes - Attributes to write.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAttributeStatement

        public final void writeProductionAttributeStatement​(EAttributeStatementType type,
                                                            Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                     throws IOException
        Writes an attribute statement.
         attr_stmt : ('graph'| 'node' | 'edge' ) attr_list
         
        Parameters:
        type - Type of the attribute statement.
        attributes - Attributes to set.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAttributeStatementEdge

        public final void writeProductionAttributeStatementEdge​(Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                         throws IOException
        Writes an edge attribute statement. Sets the default attributes that apply to all following edges.
         attr_stmt : 'edge' attr_list
         
        Parameters:
        attributes - Attributes to set.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAttributeStatementGraph

        public final void writeProductionAttributeStatementGraph​(Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                          throws IOException
        Writes a graph attribute statement. Sets the default attributes that apply to all following graphs.
         attr_stmt : 'graph' attr_list
         
        Parameters:
        attributes - Attributes to set.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionAttributeStatementNode

        public final void writeProductionAttributeStatementNode​(Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                         throws IOException
        Writes a node attribute statement. Sets the default attributes that apply to all following nodes.
         attr_stmt : 'node' attr_list
         
        Parameters:
        attributes - Attributes to set.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatement

        public final void writeProductionEdgeStatement​(EEdgeType edgeOp,
                                                       CharSequence sourceNodeId,
                                                       CharSequence sourcePortId,
                                                       ECompassPointType sourceCompassPoint,
                                                       CharSequence targetNodeId,
                                                       CharSequence targetPortId,
                                                       ECompassPointType targetCompassPoint,
                                                       Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                throws IOException
        Write an edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : edgeop (node_id | subgraph) [ edgeRHS ]
         edgeop : '->' | '--'
         
        Parameters:
        edgeOp - Type of the edge operation.
        sourceNodeId - ID of the source node, the start of the edge.
        sourcePortId - Optional ID of the source port.
        sourceCompassPoint - Optional ID of the source compass point.
        targetNodeId - ID of the target node, the end of the edge.
        targetPortId - Optional ID of the target port.
        targetCompassPoint - Optional ID of the target compass point.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatement

        public final <W extends GraphDotTokenWriter> void writeProductionEdgeStatement​(EEdgeType edgeOp,
                                                                                       com.helger.commons.callback.IThrowingRunnable<IOException> sourceNode,
                                                                                       com.helger.commons.callback.IThrowingRunnable<IOException> targetNode,
                                                                                       Iterable<? extends com.helger.commons.callback.IThrowingRunnable<IOException>> moreNodes,
                                                                                       Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                                                throws IOException
        Write an edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : edgeop (node_id | subgraph) [ edgeRHS ]
         edgeop : '->' | '--'
         
        Parameters:
        edgeOp - Type of the edge operation.
        sourceNode - Writer for the source node, the start of the edge.
        targetNode - Writer for the target node, the end of the edge.
        moreNodes - Additional nodes to which to draw an edge.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementDirected

        public final void writeProductionEdgeStatementDirected​(CharSequence sourceNodeId,
                                                               CharSequence targetNodeId)
                                                        throws IOException
        Write a directed edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '->' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        sourceNodeId - ID of the source node, the start of the edge.
        targetNodeId - ID of the target node, the end of the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementDirected

        public final void writeProductionEdgeStatementDirected​(CharSequence sourceNodeId,
                                                               CharSequence sourcePortId,
                                                               ECompassPointType sourceCompassPoint,
                                                               CharSequence targetNodeId,
                                                               CharSequence targetPortId,
                                                               ECompassPointType targetCompassPoint,
                                                               Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                        throws IOException
        Write a directed edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '->' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        sourceNodeId - ID of the source node, the start of the edge.
        sourcePortId - Optional ID of the source port.
        sourceCompassPoint - Optional ID of the source compass point.
        targetNodeId - ID of the target node, the end of the edge.
        targetPortId - Optional ID of the target port.
        targetCompassPoint - Optional ID of the target compass point.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementDirected

        public final void writeProductionEdgeStatementDirected​(CharSequence sourceNodeId,
                                                               CharSequence targetNodeId,
                                                               Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                        throws IOException
        Write a directed edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '->' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        sourceNodeId - ID of the source node, the start of the edge.
        targetNodeId - ID of the target node, the end of the edge.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementDirected

        public final void writeProductionEdgeStatementDirected​(List<? extends CharSequence> nodeIds,
                                                               Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                        throws IOException
        Write a directed edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '->' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        nodeIds - ID of the node between which to draw edges. Must contain at least 2 items.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementUndirected

        public final void writeProductionEdgeStatementUndirected​(CharSequence sourceNodeId,
                                                                 CharSequence targetNodeId)
                                                          throws IOException
        Write an undirected edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '--' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        sourceNodeId - ID of the source node, the start of the edge.
        targetNodeId - ID of the target node, the end of the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementUndirected

        public final void writeProductionEdgeStatementUndirected​(CharSequence sourceNodeId,
                                                                 CharSequence sourcePortId,
                                                                 ECompassPointType sourceCompassPoint,
                                                                 CharSequence targetNodeId,
                                                                 CharSequence targetPortId,
                                                                 ECompassPointType targetCompassPoint,
                                                                 Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                          throws IOException
        Write an undirected edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '--' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        sourceNodeId - ID of the source node, the start of the edge.
        sourcePortId - Optional ID of the source port.
        sourceCompassPoint - Optional ID of the source compass point.
        targetNodeId - ID of the target node, the end of the edge.
        targetPortId - Optional ID of the target port.
        targetCompassPoint - Optional ID of the target compass point.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementUndirected

        public final void writeProductionEdgeStatementUndirected​(CharSequence sourceNodeId,
                                                                 CharSequence targetNodeId,
                                                                 Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                          throws IOException
        Write an undirected edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '--' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        sourceNodeId - ID of the source node, the start of the edge.
        targetNodeId - ID of the target node, the end of the edge.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEdgeStatementUndirected

        public final void writeProductionEdgeStatementUndirected​(List<? extends CharSequence> nodeIds,
                                                                 Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                          throws IOException
        Write an udirected edge statement.
         edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
         edgeRHS : '--' (node_id | subgraph) [ edgeRHS ]
         
        Parameters:
        nodeIds - ID of the node between which to draw edges. Must contain at least 2 items.
        attributes - Optional attributes for the edge.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEndBlock

        public final void writeProductionEndBlock()
                                           throws IOException
        Write a closing brace that was opened with writeProductionOpenBlock(), decrements the indent, and queues a line break for the next time a production is written.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionEndBlockExpression

        public final void writeProductionEndBlockExpression()
                                                     throws IOException
        Write a closing brace that was opened with writeProductionOpenBlock() and decrements the indent.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionGraphHeader

        public final void writeProductionGraphHeader​(EGraphType type,
                                                     CharSequence id,
                                                     boolean strict)
                                              throws IOException
        Write the header of a graph.
         graph        : graph_header graph_body
         graph_header : [ strict ] (graph | digraph) [ ID ]
         graph_body   : '{' stmt_list '}'
         
        Parameters:
        type - Type of the graph.
        id - ID of the graph.
        strict - Whether to use strict mode.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionGraphHeaderDirected

        public final void writeProductionGraphHeaderDirected​(CharSequence id)
                                                      throws IOException
        Writes the header of a directed graph.
         graph        : graph_header graph_body
         graph_header : [ 'strict' ] 'digraph' [ ID ]
         graph_body   : '{' stmt_list '}'
         
        Parameters:
        id - ID of the directed graph.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionGraphHeaderDirected

        public final void writeProductionGraphHeaderDirected​(CharSequence id,
                                                             boolean strict)
                                                      throws IOException
        Writes the header of a directed graph.
         graph        : graph_header graph_body
         graph_header : [ 'strict' ] 'digraph' [ ID ]
         graph_body   : '{' stmt_list '}'
         
        Parameters:
        id - ID of the directed graph.
        strict - Whether to use strict mode.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionGraphHeaderUndirected

        public final void writeProductionGraphHeaderUndirected​(CharSequence id)
                                                        throws IOException
        Writes the header of an undirected graph.
         graph        : graph_header graph_body
         graph_header : [ 'strict' ] 'graph' [ ID ]
         graph_body   : '{' stmt_list '}'
         
        Parameters:
        id - ID of the undirected graph.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionGraphHeaderUndirected

        public final void writeProductionGraphHeaderUndirected​(CharSequence id,
                                                               boolean strict)
                                                        throws IOException
        Writes the header of an undirected graph.
         graph        : graph_header graph_body
         graph_header : [ 'strict' ] 'graph' [ ID ]
         graph_body   : '{' stmt_list '}'
         
        Parameters:
        id - ID of the undirected graph.
        strict - Whether to use strict mode.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionNodeId

        public final void writeProductionNodeId​(CharSequence nodeId,
                                                CharSequence port,
                                                ECompassPointType compassPoint)
                                         throws IOException
        Writes an expression for a node ID with an optional port or compass point.
         node_id    : ID [ port ]
         port       : ( ':' ID [ ':' compass_pt ] ) | ( ':' compass_pt )
         compass_pt : ( 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_' )
         
        Parameters:
        nodeId - Node ID to write.
        port - Port to write, may be null.
        compassPoint - Compass point to write, may be null.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionNodeStatement

        public final void writeProductionNodeStatement​(CharSequence nodeId)
                                                throws IOException
        Writes a node statement.
         node_stmt  : node_id [ attr_list ]
         node_id    : ID [ port ]
         port       : ( ':' ID [ ':' compass_pt ] ) | ( ':' compass_pt )
         compass_pt : ( 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_' )
         
        Parameters:
        nodeId - ID of the node.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionNodeStatement

        public final void writeProductionNodeStatement​(CharSequence nodeId,
                                                       CharSequence port,
                                                       ECompassPointType compassPoint)
                                                throws IOException
        Writes a node statement.
         node_stmt  : node_id [ attr_list ]
         node_id    : ID [ port ]
         port       : ( ':' ID [ ':' compass_pt ] ) | ( ':' compass_pt )
         compass_pt : ( 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_' )
         
        Parameters:
        nodeId - ID of the node.
        port - Port of the node.
        compassPoint - Compass point of the node.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionNodeStatement

        public final void writeProductionNodeStatement​(CharSequence nodeId,
                                                       CharSequence port,
                                                       ECompassPointType compassPoint,
                                                       Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                throws IOException
        Writes a node statement.
         node_stmt  : node_id [ attr_list ]
         node_id    : ID [ port ]
         port       : ( ':' ID [ ':' compass_pt ] ) | ( ':' compass_pt )
         compass_pt : ( 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_' )
         
        Parameters:
        nodeId - ID of the node.
        port - Port of the node.
        compassPoint - Compass point of the node.
        attributes - Optional attributes for the node.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionNodeStatement

        public final void writeProductionNodeStatement​(CharSequence nodeId,
                                                       Iterator<? extends Map.Entry<? extends CharSequence,​Object>> attributes)
                                                throws IOException
        Writes a node statement.
         node_stmt  : node_id [ attr_list ]
         node_id    : ID [ port ]
         port       : ( ':' ID [ ':' compass_pt ] ) | ( ':' compass_pt )
         compass_pt : ( 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_' )
         
        Parameters:
        nodeId - ID of the node.
        attributes - Optional attributes for the node.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionOpenBlock

        public final void writeProductionOpenBlock()
                                            throws IOException
        Write an opening brace, increases the indent, and queues a line break for the next time a production is written.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionPort

        public void writeProductionPort​(CharSequence portId,
                                        ECompassPointType compassPoint)
                                 throws IOException
        Writes a port and compass point expression.
          port       : ( ID [ ':' compass_pt ] ) | ( compass_pt )
          compass_pt : ( 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_' )
         
        Parameters:
        portId - ID of the port.
        compassPoint - Direction of the port.
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionSubGraphHeader

        public final void writeProductionSubGraphHeader()
                                                 throws IOException
        Writes the header of a sub graph.
         subgraph        : subgraph_header subgraph_body
         subgraph_header : [ subgraph [ ID ] ]
         subgraph_body   : '{' stmt_list '}'
         
        Throws:
        IOException - When content could not be written to the writer.
      • writeProductionSubGraphHeader

        public final void writeProductionSubGraphHeader​(CharSequence id)
                                                 throws IOException
        Writes the header of a sub graph.
         subgraph        : subgraph_header subgraph_body
         subgraph_header : [ subgraph [ ID ] ]
         subgraph_body   : '{' stmt_list '}'
         
        Parameters:
        id - Optional ID of the sub graph graph.
        Throws:
        IOException - When content could not be written to the writer.
      • forWriter

        public static GraphDotProductionWriter forWriter​(Writer writer)
        Creates a new dot graph production writer. The content is written to the given writer.
        Parameters:
        writer - Writer to which to write the output.
        Returns:
        A new graph dot production writer.
      • forWriter

        public static GraphDotProductionWriter forWriter​(Writer writer,
                                                         CharSequence indentChar)
        Creates a new dot graph production writer. The content is written to the given writer.
        Parameters:
        writer - Writer to which to write the output.
        indentChar - Char sequence to use for indenting.
        Returns:
        A new graph dot production writer.