Package org.snakeyaml.engine.v2.composer
Class Composer
- java.lang.Object
-
- org.snakeyaml.engine.v2.composer.Composer
-
- All Implemented Interfaces:
java.util.Iterator<Node>
public class Composer extends java.lang.Object implements java.util.Iterator<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 implementsIterator
to get the stream ofNode
s from the input.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Anchor,Node>
anchors
private CommentEventsCollector
blockCommentsCollector
private CommentEventsCollector
inlineCommentsCollector
private int
nonScalarAliasesCount
protected Parser
parser
Event parserprivate java.util.Set<Node>
recursiveNodes
private ScalarResolver
scalarResolver
private LoadSettings
settings
-
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 Node
composeKeyNode(MappingNode node)
To be able to override composeNode(node) which is a keyprotected void
composeMappingChildren(java.util.List<NodeTuple> children, MappingNode node)
Add the provided Node to the children as the last childprotected Node
composeMappingNode(java.util.Optional<Anchor> anchor)
Create mapping Nodeprivate Node
composeNode(java.util.Optional<Node> parent)
protected Node
composeScalarNode(java.util.Optional<Anchor> anchor, java.util.List<CommentLine> blockComments)
Create ScalarNodeprotected SequenceNode
composeSequenceNode(java.util.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 valuejava.util.Optional<Node>
getSingleNode()
Reads a document from a source that contains only one document.boolean
hasNext()
Checks if further documents are available.Node
next()
Reads and composes the next document.private void
registerAnchor(Anchor anchor, Node node)
-
-
-
Field Detail
-
parser
protected final Parser parser
Event parser
-
scalarResolver
private final ScalarResolver scalarResolver
-
recursiveNodes
private final java.util.Set<Node> recursiveNodes
-
settings
private final LoadSettings settings
-
blockCommentsCollector
private final CommentEventsCollector blockCommentsCollector
-
inlineCommentsCollector
private final CommentEventsCollector inlineCommentsCollector
-
nonScalarAliasesCount
private int nonScalarAliasesCount
-
-
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.- Specified by:
hasNext
in interfacejava.util.Iterator<Node>
- Returns:
true
if there is at least one more document.
-
getSingleNode
public java.util.Optional<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 Node next()
Reads and composes the next document.- Specified by:
next
in interfacejava.util.Iterator<Node>
- Returns:
- The root node of the document or
null
if no more documents are available.
-
composeScalarNode
protected Node composeScalarNode(java.util.Optional<Anchor> anchor, java.util.List<CommentLine> blockComments)
Create ScalarNode- Parameters:
anchor
- - anchor if presentblockComments
- - comments before the Node- Returns:
- Node
-
composeSequenceNode
protected SequenceNode composeSequenceNode(java.util.Optional<Anchor> anchor)
Compose a sequence Node from the input starting with SequenceStartEvent- Parameters:
anchor
- - anchor if present- Returns:
- parsed Node
-
composeMappingNode
protected Node composeMappingNode(java.util.Optional<Anchor> anchor)
Create mapping Node- Parameters:
anchor
- - anchor if present- Returns:
- Node
-
composeMappingChildren
protected void composeMappingChildren(java.util.List<NodeTuple> children, 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 Node composeKeyNode(MappingNode node)
To be able to override composeNode(node) which is a key- Parameters:
node
- - the source- Returns:
- node
-
composeValueNode
protected Node composeValueNode(MappingNode node)
To be able to override composeNode(node) which is a value- Parameters:
node
- - the source- Returns:
- node
-
-