Class Composer

  • All Implemented Interfaces:
    Iterator<org.snakeyaml.engine.v2.nodes.Node>

    public class Composer
    extends Object
    implements Iterator<org.snakeyaml.engine.v2.nodes.Node>
    Creates a node graph from parser events.

    Corresponds to the 'Composer' step as described in chapter 3.1.2 of the YAML Specification.

    It implements Iterator to get the stream of Nodes from the input.
    • Field Detail

      • parser

        protected final Parser parser
        Event parser
    • Constructor Detail

      • Composer

        @Deprecated
        public Composer​(Parser parser,
                        LoadSettings settings)
        Deprecated.
        use the other constructor with LoadSettings first
        Parameters:
        parser - - the input
        settings - - configuration options
      • Composer

        public Composer​(LoadSettings settings,
                        Parser parser)
        Create
        Parameters:
        settings - - configuration options
        parser - - the input
    • Method Detail

      • hasNext

        public boolean hasNext()
        Checks if further documents are available.
        Specified by:
        hasNext in interface Iterator<org.snakeyaml.engine.v2.nodes.Node>
        Returns:
        true if there is at least one more document.
      • getSingleNode

        public Optional<org.snakeyaml.engine.v2.nodes.Node> getSingleNode()
        Reads a document from a source that contains only one document.

        If the stream contains more than one document an exception is thrown.

        Returns:
        The root node of the document or Optional.empty() if no document is available.
      • next

        public org.snakeyaml.engine.v2.nodes.Node next()
        Reads and composes the next document.
        Specified by:
        next in interface Iterator<org.snakeyaml.engine.v2.nodes.Node>
        Returns:
        The root node of the document or null if no more documents are available.
      • composeScalarNode

        protected org.snakeyaml.engine.v2.nodes.Node composeScalarNode​(Optional<Anchor> anchor,
                                                                       List<CommentLine> blockComments)
        Create ScalarNode
        Parameters:
        anchor - - anchor if present
        blockComments - - comments before the Node
        Returns:
        Node
      • composeSequenceNode

        protected org.snakeyaml.engine.v2.nodes.SequenceNode composeSequenceNode​(Optional<Anchor> anchor)
        Compose a sequence Node from the input starting with SequenceStartEvent
        Parameters:
        anchor - - anchor if present
        Returns:
        parsed Node
      • composeMappingNode

        protected org.snakeyaml.engine.v2.nodes.Node composeMappingNode​(Optional<Anchor> anchor)
        Create mapping Node
        Parameters:
        anchor - - anchor if present
        Returns:
        Node
      • composeMappingChildren

        protected void composeMappingChildren​(List<org.snakeyaml.engine.v2.nodes.NodeTuple> children,
                                              org.snakeyaml.engine.v2.nodes.MappingNode node)
        Add the provided Node to the children as the last child
        Parameters:
        children - - the list to be extended
        node - - the child to the children
      • composeKeyNode

        protected org.snakeyaml.engine.v2.nodes.Node composeKeyNode​(org.snakeyaml.engine.v2.nodes.MappingNode node)
        To be able to override composeNode(node) which is a key
        Parameters:
        node - - the source
        Returns:
        node
      • composeValueNode

        protected org.snakeyaml.engine.v2.nodes.Node composeValueNode​(org.snakeyaml.engine.v2.nodes.MappingNode node)
        To be able to override composeNode(node) which is a value
        Parameters:
        node - - the source
        Returns:
        node