Package org.snakeyaml.engine.v2.composer
Class Composer
java.lang.Object
org.snakeyaml.engine.v2.composer.Composer
Creates a node graph from parser events.
Corresponds to the 'Composer' step as described in chapter 3.1.2 of the YAML Specification.
It implementsIterator
to get the stream of Node
s from the input.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CommentEventsCollector
private final CommentEventsCollector
private int
protected final Parser
Event parserprivate final ScalarResolver
private final LoadSettings
-
Constructor Summary
ConstructorsConstructorDescriptionComposer
(LoadSettings settings, Parser parser) CreateComposer
(Parser parser, LoadSettings settings) Deprecated.use the other constructor with LoadSettings first -
Method Summary
Modifier and TypeMethodDescriptionprotected Node
composeKeyNode
(MappingNode node) To be able to override composeNode(node) which is a keyprotected void
composeMappingChildren
(List<NodeTuple> children, MappingNode node) Add the provided Node to the children as the last childprotected Node
composeMappingNode
(Optional<Anchor> anchor) Create mapping Nodeprivate Node
composeNode
(Optional<Node> parent) protected Node
composeScalarNode
(Optional<Anchor> anchor, List<CommentLine> blockComments) Create ScalarNodeprotected SequenceNode
composeSequenceNode
(Optional<Anchor> anchor) Compose a sequence Node from the input starting with SequenceStartEventprotected Node
composeValueNode
(MappingNode node) To be able to override composeNode(node) which is a valueReads a document from a source that contains only one document.boolean
hasNext()
Checks if further documents are available.next()
Reads and composes the next document.private void
registerAnchor
(Anchor anchor, Node node) 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 Details
-
parser
Event parser -
scalarResolver
-
anchors
-
recursiveNodes
-
settings
-
blockCommentsCollector
-
inlineCommentsCollector
-
nonScalarAliasesCount
private int nonScalarAliasesCount
-
-
Constructor Details
-
Composer
Deprecated.use the other constructor with LoadSettings first- Parameters:
parser
- - the inputsettings
- - configuration options
-
Composer
Create- Parameters:
settings
- - configuration optionsparser
- - the input
-
-
Method Details
-
hasNext
public boolean hasNext()Checks if further documents are available. -
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
Reads and composes the next document. -
composeNode
-
registerAnchor
-
composeScalarNode
Create ScalarNode- Parameters:
anchor
- - anchor if presentblockComments
- - comments before the Node- Returns:
- Node
-
composeSequenceNode
Compose a sequence Node from the input starting with SequenceStartEvent- Parameters:
anchor
- - anchor if present- Returns:
- parsed Node
-
composeMappingNode
Create mapping Node- Parameters:
anchor
- - anchor if present- Returns:
- Node
-
composeMappingChildren
Add the provided Node to the children as the last child- Parameters:
children
- - the list to be extendednode
- - the child to the children
-
composeKeyNode
To be able to override composeNode(node) which is a key- Parameters:
node
- - the source- Returns:
- node
-
composeValueNode
To be able to override composeNode(node) which is a value- Parameters:
node
- - the source- Returns:
- node
-