Top Description Inners Fields Constructors Methods
org.yaml.snakeyaml.constructor

public abstract Class BaseConstructor

extends Object
Class Inheritance
Known Direct Subclasses
org.yaml.snakeyaml.constructor.SafeConstructor
Imports
java.lang.reflect.Array, .Modifier, java.util.ArrayList, .Collection, .EnumMap, .HashMap, .HashSet, .LinkedHashMap, .LinkedHashSet, .List, .Map, .NoSuchElementException, .Set, .SortedMap, .SortedSet, .TreeMap, .TreeSet, org.yaml.snakeyaml.LoaderOptions, .TypeDescription, org.yaml.snakeyaml.composer.Composer, .ComposerException, org.yaml.snakeyaml.error.YAMLException, org.yaml.snakeyaml.introspector.PropertyUtils, org.yaml.snakeyaml.nodes.CollectionNode, .MappingNode, .Node, .NodeId, .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
private boolean
protected Composer
composer

No graph creator

pack-priv final Map<Node, Object>
private boolean
private boolean
protected LoaderOptions
private final ArrayList<BaseConstructor.RecursiveTuple<Map<Object, Object>, BaseConstructor.RecursiveTuple<Object, Object>>>
protected static final Object
NOT_INSTANTIATED_OBJECT

An instance returned by newInstance methods when instantiation has not been performed.

private PropertyUtils
private final Set<Node>
protected Tag
rootTag

the tag for the root node

private final ArrayList<BaseConstructor.RecursiveTuple<Set<Object>, Object>>
protected final Map<Class<? extends Object>, TypeDescription>
typeDefinitions

Mapping from a class to its manager

protected final Map<Tag, Class<? extends Object>>
typeTags

register classes for tags

private boolean
protected final Map<NodeId, Construct>
yamlClassConstructors

It maps the node kind to the Construct implementation.

protected final Map<Tag, Construct>
yamlConstructors

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

protected final Map<String, Construct>
yamlMultiConstructors

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

Constructor Summary

AccessConstructor and Description
public
BaseConstructor(LoaderOptions
- options
loadingConfig
)

Create

Method Summary

Modifier and TypeMethod and Description
public TypeDescription

Returns:

the previous value associated with definition, or null if there was no mapping for definition.
addTypeDescription
(TypeDescription
to be added to the Constructor
definition
)

Make YAML aware how to parse a custom Class.

public boolean

Returns:

true when there are more YAML documents in the stream
checkData
()

Check if more documents available

protected Object

Returns:

constructed array
constructArray
(SequenceNode
- sequence
node
)

Create array from sequence

protected Object

Returns:

filled array
constructArrayStep2
(SequenceNode
- the source
node
,
Object
- the destination
array
)

Fill array from node

protected final Object

Returns:

Java instance
constructDocument
(Node
root Node
node
)

Construct complete YAML document.

protected Map<Object, Object>

Returns:

constructed Map
constructMapping
(MappingNode
- mapping
node
)

Create Map from mapping

protected void
constructMapping2ndStep(MappingNode
- source
node
,
Map<Object, Object>
- map to fill
mapping
)

Fill provided Map with constructed data

protected Object

Returns:

Java instance
constructObject
(Node
Node to be constructed
node
)

Construct object from the specified Node.

protected Object

Returns:

constructed instance
constructObjectNoCheck
(Node
- the source
node
)

Construct object from the specified Node without the check if it was already created.

protected String

Returns:

the data
constructScalar
(ScalarNode
- the source
node
)

Create string from scalar

protected List<? extends Object>

Returns:

filled List
constructSequence
(SequenceNode
- the source
node
)

Create List and fill it with data

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

Fill the provided collection with the data from the Node

protected Set<? extends Object>

Returns:

constructed Set
constructSet
(SequenceNode
- sequence
node
)

create Set from sequence

protected Set<Object>

Returns:

constructed Set
constructSet
(MappingNode
- mapping
node
)

Create Set from mapping

protected void
protected Object
createArray(Class<?> type, int size)

protected List<Object>
createDefaultList(int initSize)

protected Map<Object, Object>
createDefaultMap(int initSize)

protected Set<Object>
createDefaultSet(int initSize)

private void
fillRecursive()

Fill the recursive structures and clean the internal collections

protected Object
protected Construct

Returns:

Construct implementation for the specified node
getConstructor
(Node
Node to construct an instance from
node
)

Get the constructor to construct the Node.

public Object

Returns:

constructed instance
getData
()

Construct and return the next document

public LoaderOptions
public final PropertyUtils
public Object

Returns:

constructed instance
getSingleData
(Class<?>
the class of the instance being created
type
)

Ensure that the stream contains a single document and construct it

public boolean
public boolean
public final boolean
public boolean
protected Object
protected final Object
newInstance(Class<?> ancestor, Node node)

protected Object

Returns:

- a new object created for node.getType() by using corresponding TypeDescription.newInstance or default constructor. - NOT_INSTANTIATED_OBJECT in case no object has been created
newInstance
(Class<?>
expected ancestor of the node.getType()
ancestor
,
Node
for which to create a corresponding java object
node
,
boolean
should default constructor to be tried when there is no corresponding TypeDescription or TypeDescription.newInstance(node) returns null.
tryDefault
)

Tries to create a new object for the node.

protected List<Object>
protected Map<Object, Object>
protected Set<Object>
protected void
protected void
public void
setAllowDuplicateKeys(boolean allowDuplicateKeys)

public void
public void
setEnumCaseSensitive(boolean enumCaseSensitive)

public void
public void
setWrappedToRootException(boolean wrappedToRootException)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowDuplicateKeysback to summary
private boolean allowDuplicateKeys
composerback to summary
protected Composer composer

No graph creator

constructedObjectsback to summary
pack-priv final Map<Node, Object> constructedObjects
enumCaseSensitiveback to summary
private boolean enumCaseSensitive
explicitPropertyUtilsback to summary
private boolean explicitPropertyUtils
loadingConfigback to summary
protected LoaderOptions loadingConfig

options

maps2fillback to summary
private final ArrayList<BaseConstructor.RecursiveTuple<Map<Object, Object>, BaseConstructor.RecursiveTuple<Object, Object>>> maps2fill
NOT_INSTANTIATED_OBJECTback to summary
protected static final Object NOT_INSTANTIATED_OBJECT

An instance returned by newInstance methods when instantiation has not been performed.

propertyUtilsback to summary
private PropertyUtils propertyUtils
recursiveObjectsback to summary
private final Set<Node> recursiveObjects
rootTagback to summary
protected Tag rootTag

the tag for the root node

sets2fillback to summary
private final ArrayList<BaseConstructor.RecursiveTuple<Set<Object>, Object>> sets2fill
typeDefinitionsback to summary
protected final Map<Class<? extends Object>, TypeDescription> typeDefinitions

Mapping from a class to its manager

typeTagsback to summary
protected final Map<Tag, Class<? extends Object>> typeTags

register classes for tags

wrappedToRootExceptionback to summary
private boolean wrappedToRootException
yamlClassConstructorsback to summary
protected final Map<NodeId, Construct> yamlClassConstructors

It maps the node kind to the Construct implementation. When the runtime class is known then the implicit tag is ignored.

yamlConstructorsback to summary
protected final Map<Tag, Construct> yamlConstructors

It maps the (explicit or implicit) tag to the Construct implementation. It is used: 1) explicit tag - if present. 2) implicit tag - when the runtime class of the instance is unknown (the node has the Object.class) 3) when nothing else is found the Construct for the key 'null' is chosen (which is ConstructYamlObject)

yamlMultiConstructorsback to summary
protected final Map<String, Construct> yamlMultiConstructors

It maps the (explicit or implicit) tag to the Construct implementation. It is used when no exact match found. The key in the Map is checked if it starts the class name

Constructor Detail

BaseConstructorback to summary
public BaseConstructor(LoaderOptions loadingConfig)

Create

Parameters
loadingConfig:LoaderOptions

- options

Method Detail

addTypeDescriptionback to summary
public TypeDescription addTypeDescription(TypeDescription definition)

Make YAML aware how to parse a custom Class. If there is no root Class assigned in constructor then the 'root' property of this definition is respected.

Parameters
definition:TypeDescription

to be added to the Constructor

Returns:TypeDescription

the previous value associated with definition, or null if there was no mapping for definition.

checkDataback to summary
public boolean checkData()

Check if more documents available

Returns:boolean

true when there are more YAML documents in the stream

constructArrayback to summary
protected Object constructArray(SequenceNode node)

Create array from sequence

Parameters
node:SequenceNode

- sequence

Returns:Object

constructed array

constructArrayStep2back to summary
protected Object constructArrayStep2(SequenceNode node, Object array)

Fill array from node

Parameters
node:SequenceNode

- the source

array:Object

- the destination

Returns:Object

filled array

constructDocumentback to summary
protected final Object constructDocument(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 Map from mapping

Parameters
node:MappingNode

- mapping

Returns:Map<Object, Object>

constructed Map

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

Fill provided Map with constructed data

Parameters
node:MappingNode

- source

mapping:Map<Object, Object>

- map to fill

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 without the check if it was already created.

Parameters
node:Node

- the source

Returns:Object

constructed instance

constructScalarback to summary
protected String constructScalar(ScalarNode node)

Create string from scalar

Parameters
node:ScalarNode

- the source

Returns:String

the data

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

Create List and fill it with data

Parameters
node:SequenceNode

- the source

Returns:List<? extends Object>

filled List

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

Fill the provided collection with the data from the Node

Parameters
node:SequenceNode

- the source

collection:Collection<Object>

- data to fill

constructSetback to summary
protected Set<? extends Object> constructSet(SequenceNode node)

create Set from sequence

Parameters
node:SequenceNode

- sequence

Returns:Set<? extends Object>

constructed Set

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

Create Set from mapping

Parameters
node:MappingNode

- mapping

Returns:Set<Object>

constructed Set

constructSet2ndStepback to summary
protected void constructSet2ndStep(MappingNode node, Set<Object> set)
createArrayback to summary
protected Object createArray(Class<?> type, int size)
createDefaultListback to summary
protected List<Object> createDefaultList(int initSize)
createDefaultMapback to summary
protected Map<Object, Object> createDefaultMap(int initSize)
createDefaultSetback to summary
protected Set<Object> createDefaultSet(int initSize)
fillRecursiveback to summary
private void fillRecursive()

Fill the recursive structures and clean the internal collections

finalizeConstructionback to summary
protected Object finalizeConstruction(Node node, Object data)
getConstructorback to summary
protected Construct getConstructor(Node node)

Get the constructor to construct the Node. For implicit tags if the runtime class is known a dedicated Construct implementation is used. Otherwise, the constructor is chosen by the tag.

Parameters
node:Node

Node to construct an instance from

Returns:Construct

Construct implementation for the specified node

getDataback to summary
public Object getData() throws NoSuchElementException

Construct and return the next document

Returns:Object

constructed instance

getLoadingConfigback to summary
public LoaderOptions getLoadingConfig()
getPropertyUtilsback to summary
public final PropertyUtils getPropertyUtils()
getSingleDataback to summary
public Object getSingleData(Class<?> type)

Ensure that the stream contains a single document and construct it

Parameters
type:Class<?>

the class of the instance being created

Returns:Object

constructed instance

Exceptions
ComposerException:
in case there are more documents in the stream
isAllowDuplicateKeysback to summary
public boolean isAllowDuplicateKeys()
isEnumCaseSensitiveback to summary
public boolean isEnumCaseSensitive()
isExplicitPropertyUtilsback to summary
public final boolean isExplicitPropertyUtils()
isWrappedToRootExceptionback to summary
public boolean isWrappedToRootException()
newInstanceback to summary
protected Object newInstance(Node node)
newInstanceback to summary
protected final Object newInstance(Class<?> ancestor, Node node)
newInstanceback to summary
protected Object newInstance(Class<?> ancestor, Node node, boolean tryDefault)

Tries to create a new object for the node.

Parameters
ancestor:Class<?>

expected ancestor of the node.getType()

node:Node

for which to create a corresponding java object

tryDefault:boolean

should default constructor to be tried when there is no corresponding TypeDescription or TypeDescription.newInstance(node) returns null.

Returns:Object

- a new object created for node.getType() by using corresponding TypeDescription.newInstance or default constructor. - NOT_INSTANTIATED_OBJECT in case no object has been created

newListback to summary
protected List<Object> newList(SequenceNode node)
Annotations
@SuppressWarnings:unchecked
newMapback to summary
protected Map<Object, Object> newMap(MappingNode node)
Annotations
@SuppressWarnings:unchecked
newSetback to summary
protected Set<Object> newSet(CollectionNode<?> node)
Annotations
@SuppressWarnings:unchecked
postponeMapFillingback to summary
protected void postponeMapFilling(Map<Object, Object> mapping, Object key, Object value)
postponeSetFillingback to summary
protected void postponeSetFilling(Set<Object> set, Object key)
setAllowDuplicateKeysback to summary
public void setAllowDuplicateKeys(boolean allowDuplicateKeys)
setComposerback to summary
public void setComposer(Composer composer)
setEnumCaseSensitiveback to summary
public void setEnumCaseSensitive(boolean enumCaseSensitive)
setPropertyUtilsback to summary
public void setPropertyUtils(PropertyUtils propertyUtils)
setWrappedToRootExceptionback to summary
public void setWrappedToRootException(boolean wrappedToRootException)
org.yaml.snakeyaml.constructor back to summary

private Class BaseConstructor.RecursiveTuple<T, K>

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

Field Summary

Modifier and TypeField and Description
private final T
private final K

Constructor Summary

AccessConstructor and Description
public
RecursiveTuple(T _1, K _2)

Method Summary

Modifier and TypeMethod and Description
public T
_1()

public K
_2()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_1back to summary
private final T _1
_2back to summary
private final K _2

Constructor Detail

RecursiveTupleback to summary
public RecursiveTuple(T _1, K _2)

Method Detail

_1back to summary
public T _1()
_2back to summary
public K _2()