Package org.yaml.snakeyaml.constructor
Class BaseConstructor
java.lang.Object
org.yaml.snakeyaml.constructor.BaseConstructor
- Direct Known Subclasses:
SafeConstructor
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
protected Composer
private boolean
protected LoaderOptions
private final ArrayList<BaseConstructor.RecursiveTuple<Map<Object,
Object>, BaseConstructor.RecursiveTuple<Object, Object>>> private PropertyUtils
protected Tag
private final ArrayList<BaseConstructor.RecursiveTuple<Set<Object>,
Object>> protected final Map<Class<? extends Object>,
TypeDescription> private boolean
It maps the node kind to the the Construct implementation.It maps the (explicit or implicit) tag to the Construct implementation.It maps the (explicit or implicit) tag to the Construct implementation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTypeDescription
(TypeDescription definition) Make YAML aware how to parse a custom Class.boolean
Check if more documents availableprotected Object
constructArray
(SequenceNode node) protected Object
constructArrayStep2
(SequenceNode node, Object array) protected final Object
constructDocument
(Node node) Construct complete YAML document.constructMapping
(MappingNode node) protected void
constructMapping2ndStep
(MappingNode node, Map<Object, Object> mapping) protected Object
constructObject
(Node node) Construct object from the specified Node.protected Object
constructObjectNoCheck
(Node node) protected String
constructScalar
(ScalarNode node) protected void
constructSequenceStep2
(SequenceNode node, Collection<Object> collection) constructSet
(MappingNode node) constructSet
(SequenceNode node) protected void
constructSet2ndStep
(MappingNode node, Set<Object> set) protected Object
createArray
(Class<?> type, int size) createDefaultList
(int initSize) createDefaultMap
(int initSize) createDefaultSet
(int initSize) private void
Fill the recursive structures and clean the internal collectionsprotected Object
finalizeConstruction
(Node node, Object data) protected Construct
getConstructor
(Node node) Get the constructor to construct the Node.getData()
Construct and return the next documentfinal PropertyUtils
getSingleData
(Class<?> type) Ensure that the stream contains a single document and construct itboolean
final boolean
boolean
protected final Object
newInstance
(Class<?> ancestor, Node node) protected Object
newInstance
(Class<?> ancestor, Node node, boolean tryDefault) protected Object
newInstance
(Node node) newList
(SequenceNode node) newMap
(MappingNode node) newSet
(CollectionNode<?> node) protected void
protected void
postponeSetFilling
(Set<Object> set, Object key) void
setAllowDuplicateKeys
(boolean allowDuplicateKeys) void
setComposer
(Composer composer) void
setPropertyUtils
(PropertyUtils propertyUtils) void
setWrappedToRootException
(boolean wrappedToRootException)
-
Field Details
-
yamlClassConstructors
It maps the node kind to the the Construct implementation. When the runtime class is known then the implicit tag is ignored. -
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) -
yamlMultiConstructors
It maps the (explicit or implicit) tag to the Construct implementation. It is used when no exact match found. -
composer
-
constructedObjects
-
recursiveObjects
-
maps2fill
private final ArrayList<BaseConstructor.RecursiveTuple<Map<Object,Object>, maps2fillBaseConstructor.RecursiveTuple<Object, Object>>> -
sets2fill
-
rootTag
-
propertyUtils
-
explicitPropertyUtils
private boolean explicitPropertyUtils -
allowDuplicateKeys
private boolean allowDuplicateKeys -
wrappedToRootException
private boolean wrappedToRootException -
typeDefinitions
-
typeTags
-
loadingConfig
-
-
Constructor Details
-
BaseConstructor
public BaseConstructor() -
BaseConstructor
-
-
Method Details
-
setComposer
-
checkData
public boolean checkData()Check if more documents available- Returns:
- true when there are more YAML documents in the stream
-
getData
Construct and return the next document- Returns:
- constructed instance
- Throws:
NoSuchElementException
-
getSingleData
Ensure that the stream contains a single document and construct it- Parameters:
type
- the class of the instance being created- Returns:
- constructed instance
- Throws:
ComposerException
- in case there are more documents in the stream
-
constructDocument
Construct complete YAML document. Call the second step in case of recursive structures. At the end cleans all the state.- Parameters:
node
- root Node- Returns:
- Java instance
-
fillRecursive
private void fillRecursive()Fill the recursive structures and clean the internal collections -
constructObject
Construct object from the specified Node. Return existing instance if the node is already constructed.- Parameters:
node
- Node to be constructed- Returns:
- Java instance
-
constructObjectNoCheck
-
getConstructor
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. -
constructScalar
-
createDefaultList
-
createDefaultSet
-
createDefaultMap
-
createArray
-
finalizeConstruction
-
newInstance
-
newInstance
- Throws:
InstantiationException
-
newInstance
protected Object newInstance(Class<?> ancestor, Node node, boolean tryDefault) throws InstantiationException - Throws:
InstantiationException
-
newSet
-
newList
-
newMap
-
constructSequence
-
constructSet
-
constructArray
-
constructSequenceStep2
-
constructArrayStep2
-
constructSet
-
constructMapping
-
constructMapping2ndStep
-
postponeMapFilling
-
constructSet2ndStep
-
postponeSetFilling
-
setPropertyUtils
-
getPropertyUtils
-
addTypeDescription
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
- to be added to the Constructor- Returns:
- the previous value associated with
definition
, ornull
if there was no mapping fordefinition
.
-
isExplicitPropertyUtils
public final boolean isExplicitPropertyUtils() -
isAllowDuplicateKeys
public boolean isAllowDuplicateKeys() -
setAllowDuplicateKeys
public void setAllowDuplicateKeys(boolean allowDuplicateKeys) -
isWrappedToRootException
public boolean isWrappedToRootException() -
setWrappedToRootException
public void setWrappedToRootException(boolean wrappedToRootException)
-