Top Description Fields Constructors Methods
org.snakeyaml.engine.v2.composer

public Class Composer

extends Object
implements Iterator<Node>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Imports
java.util.ArrayList, .Collections, .HashMap, .HashSet, .Iterator, .List, .Map, .Optional, .Set, org.snakeyaml.engine.v2.api.LoadSettings, org.snakeyaml.engine.v2.comments.CommentEventsCollector, .CommentLine, .CommentType, org.snakeyaml.engine.v2.common.Anchor, .FlowStyle, org.snakeyaml.engine.v2.events.AliasEvent, .Event, .MappingStartEvent, .NodeEvent, .ScalarEvent, .SequenceStartEvent, org.snakeyaml.engine.v2.exceptions.ComposerException, .Mark, .YamlEngineException, org.snakeyaml.engine.v2.nodes.MappingNode, .Node, .NodeTuple, .NodeType, .ScalarNode, .SequenceNode, .Tag, org.snakeyaml.engine.v2.parser.Parser, org.snakeyaml.engine.v2.resolver.ScalarResolver, org.snakeyaml.engine.v2.util.MergeUtils

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 Summary

Modifier and TypeField and Description
private final Map<Anchor, Node>
private final CommentEventsCollector
private final CommentEventsCollector
private final MergeUtils
private int
protected final Parser
parser

Event parser

private final Set<Node>
private final ScalarResolver
private final LoadSettings

Constructor Summary

AccessConstructor and Description
public
Composer(Parser
- the input
parser
,
LoadSettings
- configuration options
settings
)
Deprecated use the other constructor with LoadSettings first

public
Composer(LoadSettings
- configuration options
settings
,
Parser
- the input
parser
)

Create

Method Summary

Modifier and TypeMethod and Description
protected MappingNode
protected Node

Returns:

node
composeKeyNode
(MappingNode
- the source
node
)

To be able to override composeNode(node) which is a key

protected void
composeMappingChildren(List<NodeTuple>
- the list to be extended
children
,
MappingNode
- the child to the children
node
)

Add the provided Node to the children as the last child

protected Node

Returns:

Node
composeMappingNode
(Optional<Anchor>
- anchor if present
anchor
)

Create mapping Node

private Node
protected Node

Returns:

Node
composeScalarNode
(Optional<Anchor>
- anchor if present
anchor
,
List<CommentLine>
- comments before the Node
blockComments
)

Create ScalarNode

protected SequenceNode

Returns:

parsed Node
composeSequenceNode
(Optional<Anchor>
- anchor if present
anchor
)

Compose a sequence Node from the input starting with SequenceStartEvent

protected Node

Returns:

node
composeValueNode
(MappingNode
- the source
node
)

To be able to override composeNode(node) which is a value

public Optional<Node>

Returns:

The root node of the document or Optional.empty() if no document is available.
getSingleNode
()

Reads a document from a source that contains only one document.

public boolean

Returns:

true if there is at least one more document.
hasNext
()

Implements java.util.Iterator.hasNext.

Checks if further documents are available.

public Node

Returns:

The root node of the document or null if no more documents are available.
next
()

Implements java.util.Iterator.next.

Reads and composes the next document.

private void
registerAnchor(Anchor anchor, Node node)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

anchorsback to summary
private final Map<Anchor, Node> anchors
blockCommentsCollectorback to summary
private final CommentEventsCollector blockCommentsCollector
inlineCommentsCollectorback to summary
private final CommentEventsCollector inlineCommentsCollector
mergeUtilsback to summary
private final MergeUtils mergeUtils
nonScalarAliasesCountback to summary
private int nonScalarAliasesCount
parserback to summary
protected final Parser parser

Event parser

recursiveNodesback to summary
private final Set<Node> recursiveNodes
scalarResolverback to summary
private final ScalarResolver scalarResolver
settingsback to summary
private final LoadSettings settings

Constructor Detail

Composerback to summary
public Composer(Parser parser, LoadSettings settings)

Deprecated

use the other constructor with LoadSettings first

Parameters
parser:Parser

- the input

settings:LoadSettings

- configuration options

Annotations
@Deprecated
Composerback to summary
public Composer(LoadSettings settings, Parser parser)

Create

Parameters
settings:LoadSettings

- configuration options

parser:Parser

- the input

Method Detail

asMappingNodeback to summary
protected MappingNode asMappingNode(Node node)
composeKeyNodeback to summary
protected Node composeKeyNode(MappingNode node)

To be able to override composeNode(node) which is a key

Parameters
node:MappingNode

- the source

Returns:Node

node

composeMappingChildrenback to summary
protected void composeMappingChildren(List<NodeTuple> children, MappingNode node)

Add the provided Node to the children as the last child

Parameters
children:List<NodeTuple>

- the list to be extended

node:MappingNode

- the child to the children

composeMappingNodeback to summary
protected Node composeMappingNode(Optional<Anchor> anchor)

Create mapping Node

Parameters
anchor:Optional<Anchor>

- anchor if present

Returns:Node

Node

composeNodeback to summary
private Node composeNode(Optional<Node> parent)
composeScalarNodeback to summary
protected Node composeScalarNode(Optional<Anchor> anchor, List<CommentLine> blockComments)

Create ScalarNode

Parameters
anchor:Optional<Anchor>

- anchor if present

blockComments:List<CommentLine>

- comments before the Node

Returns:Node

Node

composeSequenceNodeback to summary
protected SequenceNode composeSequenceNode(Optional<Anchor> anchor)

Compose a sequence Node from the input starting with SequenceStartEvent

Parameters
anchor:Optional<Anchor>

- anchor if present

Returns:SequenceNode

parsed Node

composeValueNodeback to summary
protected Node composeValueNode(MappingNode node)

To be able to override composeNode(node) which is a value

Parameters
node:MappingNode

- the source

Returns:Node

node

getSingleNodeback to summary
public 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:Optional<Node>

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

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Checks if further documents are available.

Returns:boolean

true if there is at least one more document.

nextback to summary
public Node next()

Implements java.util.Iterator.next.

Reads and composes the next document.

Returns:Node

The root node of the document or null if no more documents are available.

registerAnchorback to summary
private void registerAnchor(Anchor anchor, Node node)