Package org.yaml.snakeyaml.constructor
Class BaseConstructor
java.lang.Object
org.yaml.snakeyaml.constructor.BaseConstructor
- Direct Known Subclasses:
SafeConstructor
Base code
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Composer
No graph creatorprotected LoaderOptions
optionsprotected static final Object
An instance returned by newInstance methods when instantiation has not been performed.protected Tag
the tag for the root nodeprotected final Map<Class<? extends Object>,
TypeDescription> Mapping from a class to its managerregister classes for tagsIt 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
ConstructorsConstructorDescriptionDeprecated.use the optionsBaseConstructor
(LoaderOptions loadingConfig) Create -
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) Create array from sequenceprotected Object
constructArrayStep2
(SequenceNode node, Object array) Fill array from nodeprotected final Object
constructDocument
(Node node) Construct complete YAML document.constructMapping
(MappingNode node) Create Map from mappingprotected void
constructMapping2ndStep
(MappingNode node, Map<Object, Object> mapping) Fill provided Map with constructed dataprotected Object
constructObject
(Node node) Construct object from the specified Node.protected Object
constructObjectNoCheck
(Node node) Construct object from the specified Node without the check if it was already created.protected String
constructScalar
(ScalarNode node) Create string from scalarCreate List and fill it with dataprotected void
constructSequenceStep2
(SequenceNode node, Collection<Object> collection) Fill the provided collection with the data from the NodeconstructSet
(MappingNode node) Create Set from mappingconstructSet
(SequenceNode node) create Set from sequenceprotected void
constructSet2ndStep
(MappingNode node, Set<Object> set) protected Object
createArray
(Class<?> type, int size) createDefaultList
(int initSize) createDefaultMap
(int initSize) createDefaultSet
(int initSize) protected 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
boolean
final boolean
boolean
protected final Object
newInstance
(Class<?> ancestor, Node node) protected Object
newInstance
(Class<?> ancestor, Node node, boolean tryDefault) Tries to create a new object for the node.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
setEnumCaseSensitive
(boolean enumCaseSensitive) void
setPropertyUtils
(PropertyUtils propertyUtils) void
setWrappedToRootException
(boolean wrappedToRootException)
-
Field Details
-
NOT_INSTANTIATED_OBJECT
An instance returned by newInstance methods when instantiation has not been performed. -
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
No graph creator -
rootTag
the tag for the root node -
typeDefinitions
Mapping from a class to its manager -
typeTags
register classes for tags -
loadingConfig
options
-
-
Constructor Details
-
BaseConstructor
Deprecated.use the optionsCreate -
BaseConstructor
Create- Parameters:
loadingConfig
- - options
-
-
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
-
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
Construct object from the specified Node without the check if it was already created.- Parameters:
node
- - the source- Returns:
- constructed instance
-
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
Create string from scalar- Parameters:
node
- - the source- Returns:
- the data
-
createDefaultList
-
createDefaultSet
-
createDefaultMap
-
createArray
-
finalizeConstruction
-
newInstance
-
newInstance
-
newInstance
Tries to create a new object for the node.- Parameters:
ancestor
- expected ancestor of thenode.getType()
node
- for which to create a corresponding java objecttryDefault
- should default constructor to be tried when there is no correspondingTypeDescription
orTypeDescription.newInstance(node)
returnsnull
.- 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
-
newSet
-
newList
-
newMap
-
constructSequence
Create List and fill it with data- Parameters:
node
- - the source- Returns:
- filled List
-
constructSet
create Set from sequence- Parameters:
node
- - sequence- Returns:
- constructed Set
-
constructArray
Create array from sequence- Parameters:
node
- - sequence- Returns:
- constructed array
-
constructSequenceStep2
Fill the provided collection with the data from the Node- Parameters:
node
- - the sourcecollection
- - data to fill
-
constructArrayStep2
Fill array from node- Parameters:
node
- - the sourcearray
- - the destination- Returns:
- filled array
-
constructSet
Create Set from mapping- Parameters:
node
- - mapping- Returns:
- constructed Set
-
constructMapping
Create Map from mapping- Parameters:
node
- - mapping- Returns:
- constructed Map
-
constructMapping2ndStep
Fill provided Map with constructed data- Parameters:
node
- - sourcemapping
- - map to fill
-
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) -
isEnumCaseSensitive
public boolean isEnumCaseSensitive() -
setEnumCaseSensitive
public void setEnumCaseSensitive(boolean enumCaseSensitive)
-