Top Description Inners Fields Constructors Methods
org.snakeyaml.engine.v2.constructor

public abstract Class BaseConstructor

extends Object
Class Inheritance
Known Direct Subclasses
org.snakeyaml.engine.v2.constructor.StandardConstructor
Imports
java.util.ArrayList, .Collection, .HashMap, .HashSet, .List, .Map, .Objects, .Optional, .Set, org.snakeyaml.engine.v2.api.ConstructNode, .LoadSettings, org.snakeyaml.engine.v2.exceptions.ConstructorException, .YamlEngineException, org.snakeyaml.engine.v2.nodes.MappingNode, .Node, .NodeTuple, .ScalarNode, .SequenceNode, .Tag

Base code

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
pack-priv final Map<Node, Object>
private final ArrayList<BaseConstructor.RecursiveTuple<Map<Object, Object>, BaseConstructor.RecursiveTuple<Object, Object>>>
private final Set<Node>
private final ArrayList<BaseConstructor.RecursiveTuple<Set<Object>, Object>>
protected LoadSettings
settings

keep the settings

protected final Map<Tag, ConstructNode>
tagConstructors

It maps the (explicit or implicit) tag to the Construct implementation.

Constructor Summary

AccessConstructor and Description
public
BaseConstructor(LoadSettings
- the configuration option
settings
)

Create

Method Summary

Modifier and TypeMethod and Description
protected Object

Returns:

Java instance
construct
(Node
root Node
node
)

Construct complete YAML document.

protected Map<Object, Object>

Returns:

filled Map
constructMapping
(MappingNode
- the source
node
)

Create filled Map from the provided Node

protected void
constructMapping2ndStep(MappingNode
- the source
node
,
Map<Object, Object>
- empty map to be filled
mapping
)

Fill the mapping with the data from provided node

protected Object

Returns:

Java instance
constructObject
(Node
Node to be constructed
node
)

Construct object from the specified Node.

protected Object

Returns:

instantiated object
constructObjectNoCheck
(Node
- the source
node
)

Construct object from the specified Node.

protected String

Returns:

value of the scalar node
constructScalar
(ScalarNode
- the source
node
)

Create String from the provided scalar node

protected List<Object>

Returns:

filled List
constructSequence
(SequenceNode
- the source
node
)

Create instance of List

protected void
constructSequenceStep2(SequenceNode
- the source
node
,
Collection<Object>
- the collection to fill
collection
)

Fill the collection with the data from provided node

protected Set<Object>

Returns:

filled Set
constructSet
(MappingNode
- the source
node
)

Create instance of Set from mapping node

protected void
constructSet2ndStep(MappingNode
- the source
node
,
Set<Object>
- empty set to fill
set
)

Fill the Map with the data from the node

public Object

Returns:

constructed instance
constructSingleDocument
(Optional<Node>
- composed Node
optionalNode
)

Ensure that the stream contains a single document and construct it

protected List<Object>

Returns:

empty List to fill
createEmptyListForNode
(SequenceNode
- the node to fill the List
node
)

Create List implementation.

protected Map<Object, Object>

Returns:

empty Map to fill
createEmptyMapFor
(MappingNode
- the node to fill the Map
node
)

Create Map implementation.

protected Set<Object>

Returns:

empty Set to fill
createEmptySetForNode
(MappingNode
- the node to fill the Set
node
)

Create Set implementation.

private void
protected Optional<ConstructNode>

Returns:

ConstructNode implementation for the specified node
findConstructorFor
(Node
Node to construct an instance from
node
)

Select ConstructNode inside the provided Node or the one associated with the Tag

protected void
postponeMapFilling(Map<Object, Object>
- the mapping to add key/value
mapping
,
Object
- the key to add to map
key
,
Object
- the value behind the key
value
)

if keyObject is created it 2 steps we should postpone putting it in map because it may have different hash after initialization compared to clean just created one.

protected void
postponeSetFilling(Set<Object>
- the set to add the key
set
,
Object
- the item to add to the set
key
)

if keyObject is created it 2 steps we should postpone putting it into the set because it may have different hash after initialization compared to clean just created one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constructedObjectsback to summary
pack-priv final Map<Node, Object> constructedObjects
maps2fillback to summary
private final ArrayList<BaseConstructor.RecursiveTuple<Map<Object, Object>, BaseConstructor.RecursiveTuple<Object, Object>>> maps2fill
recursiveObjectsback to summary
private final Set<Node> recursiveObjects
sets2fillback to summary
private final ArrayList<BaseConstructor.RecursiveTuple<Set<Object>, Object>> sets2fill
settingsback to summary
protected LoadSettings settings

keep the settings

tagConstructorsback to summary
protected final Map<Tag, ConstructNode> tagConstructors

It maps the (explicit or implicit) tag to the Construct implementation.

Constructor Detail

BaseConstructorback to summary
public BaseConstructor(LoadSettings settings)

Create

Parameters
settings:LoadSettings

- the configuration option

Method Detail

constructback to summary
protected Object construct(Node node)

Construct complete YAML document. Call the second step in case of recursive structures. At the end cleans all the state.

Parameters
node:Node

root Node

Returns:Object

Java instance

constructMappingback to summary
protected Map<Object, Object> constructMapping(MappingNode node)

Create filled Map from the provided Node

Parameters
node:MappingNode

- the source

Returns:Map<Object, Object>

filled Map

constructMapping2ndStepback to summary
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping)

Fill the mapping with the data from provided node

Parameters
node:MappingNode

- the source

mapping:Map<Object, Object>

- empty map to be filled

constructObjectback to summary
protected Object constructObject(Node node)

Construct object from the specified Node. Return existing instance if the node is already constructed.

Parameters
node:Node

Node to be constructed

Returns:Object

Java instance

constructObjectNoCheckback to summary
protected Object constructObjectNoCheck(Node node)

Construct object from the specified Node. It does not check if existing instance the node is already constructed.

Parameters
node:Node

- the source

Returns:Object

instantiated object

constructScalarback to summary
protected String constructScalar(ScalarNode node)

Create String from the provided scalar node

Parameters
node:ScalarNode

- the source

Returns:String

value of the scalar node

constructSequenceback to summary
protected List<Object> constructSequence(SequenceNode node)

Create instance of List

Parameters
node:SequenceNode

- the source

Returns:List<Object>

filled List

constructSequenceStep2back to summary
protected void constructSequenceStep2(SequenceNode node, Collection<Object> collection)

Fill the collection with the data from provided node

Parameters
node:SequenceNode

- the source

collection:Collection<Object>

- the collection to fill

constructSetback to summary
protected Set<Object> constructSet(MappingNode node)

Create instance of Set from mapping node

Parameters
node:MappingNode

- the source

Returns:Set<Object>

filled Set

constructSet2ndStepback to summary
protected void constructSet2ndStep(MappingNode node, Set<Object> set)

Fill the Map with the data from the node

Parameters
node:MappingNode

- the source

set:Set<Object>

- empty set to fill

constructSingleDocumentback to summary
public Object constructSingleDocument(Optional<Node> optionalNode)

Ensure that the stream contains a single document and construct it

Parameters
optionalNode:Optional<Node>

- composed Node

Returns:Object

constructed instance

createEmptyListForNodeback to summary
protected List<Object> createEmptyListForNode(SequenceNode node)

Create List implementation. By default, it returns the value configured in the settings in getDefaultList(). Any custom List implementation can be provided.

Parameters
node:SequenceNode

- the node to fill the List

Returns:List<Object>

empty List to fill

createEmptyMapForback to summary
protected Map<Object, Object> createEmptyMapFor(MappingNode node)

Create Map implementation. By default, it returns the value configured in the settings in getDefaultMap(). Any custom Map implementation can be provided.

Parameters
node:MappingNode

- the node to fill the Map

Returns:Map<Object, Object>

empty Map to fill

createEmptySetForNodeback to summary
protected Set<Object> createEmptySetForNode(MappingNode node)

Create Set implementation. By default, it returns the value configured in the settings in getDefaultSet(). Any custom Set implementation can be provided.

Parameters
node:MappingNode

- the node to fill the Set

Returns:Set<Object>

empty Set to fill

fillRecursiveback to summary
private void fillRecursive()
findConstructorForback to summary
protected Optional<ConstructNode> findConstructorFor(Node node)

Select ConstructNode inside the provided Node or the one associated with the Tag

Parameters
node:Node

Node to construct an instance from

Returns:Optional<ConstructNode>

ConstructNode implementation for the specified node

postponeMapFillingback to summary
protected void postponeMapFilling(Map<Object, Object> mapping, Object key, Object value)

if keyObject is created it 2 steps we should postpone putting it in map because it may have different hash after initialization compared to clean just created one. And map of course does not observe key hashCode changes.

Parameters
mapping:Map<Object, Object>

- the mapping to add key/value

key:Object

- the key to add to map

value:Object

- the value behind the key

postponeSetFillingback to summary
protected void postponeSetFilling(Set<Object> set, Object key)

if keyObject is created it 2 steps we should postpone putting it into the set because it may have different hash after initialization compared to clean just created one. And set of course does not observe value hashCode changes.

Parameters
set:Set<Object>

- the set to add the key

key:Object

- the item to add to the set

org.snakeyaml.engine.v2.constructor back to summary

private Class BaseConstructor.RecursiveTuple<T, K>

extends Object
Class Inheritance
  • java.lang.Object
  • org.snakeyaml.engine.v2.constructor.BaseConstructor.RecursiveTuple

Field Summary

Modifier and TypeField and Description
private final T
private final K

Constructor Summary

AccessConstructor and Description
public
RecursiveTuple(T value1, K value2)

Method Summary

Modifier and TypeMethod and Description
public T
public K
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

value1back to summary
private final T value1
value2back to summary
private final K value2

Constructor Detail

RecursiveTupleback to summary
public RecursiveTuple(T value1, K value2)

Method Detail

getValue1back to summary
public T getValue1()
getValue2back to summary
public K getValue2()