Package org.snakeyaml.engine.v2.composer
Class Composer
- java.lang.Object
-
- org.snakeyaml.engine.v2.composer.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 implementsIteratorto get the stream ofNodes from the input.
-
-
Constructor Summary
Constructors Constructor Description Composer(LoadSettings settings, Parser parser)CreateComposer(Parser parser, LoadSettings settings)Deprecated.use the other constructor with LoadSettings first
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.snakeyaml.engine.v2.nodes.NodecomposeKeyNode(org.snakeyaml.engine.v2.nodes.MappingNode node)To be able to override composeNode(node) which is a keyprotected voidcomposeMappingChildren(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 childprotected org.snakeyaml.engine.v2.nodes.NodecomposeMappingNode(Optional<Anchor> anchor)Create mapping Nodeprotected org.snakeyaml.engine.v2.nodes.NodecomposeScalarNode(Optional<Anchor> anchor, List<CommentLine> blockComments)Create ScalarNodeprotected org.snakeyaml.engine.v2.nodes.SequenceNodecomposeSequenceNode(Optional<Anchor> anchor)Compose a sequence Node from the input starting with SequenceStartEventprotected org.snakeyaml.engine.v2.nodes.NodecomposeValueNode(org.snakeyaml.engine.v2.nodes.MappingNode node)To be able to override composeNode(node) which is a valueOptional<org.snakeyaml.engine.v2.nodes.Node>getSingleNode()Reads a document from a source that contains only one document.booleanhasNext()Checks if further documents are available.org.snakeyaml.engine.v2.nodes.Nodenext()Reads and composes the next document.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
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 inputsettings- - configuration options
-
Composer
public Composer(LoadSettings settings, Parser parser)
Create- Parameters:
settings- - configuration optionsparser- - the input
-
-
Method Detail
-
hasNext
public boolean hasNext()
Checks if further documents are available.
-
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.
-
composeScalarNode
protected org.snakeyaml.engine.v2.nodes.Node composeScalarNode(Optional<Anchor> anchor, List<CommentLine> blockComments)
Create ScalarNode- Parameters:
anchor- - anchor if presentblockComments- - 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 extendednode- - 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
-
-