Class BaseConstructor
java.lang.Object
org.yaml.snakeyaml.constructor.BaseConstructor
- Direct Known Subclasses:
SafeConstructor
Base code
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ComposerNo graph creatorprotected LoaderOptionsoptionsprotected static final ObjectAn instance returned by newInstance methods when instantiation has not been performed.protected Tagthe 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 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.booleanCheck if more documents availableprotected ObjectconstructArray(SequenceNode node) Create array from sequenceprotected ObjectconstructArrayStep2(SequenceNode node, Object array) Fill array from nodeprotected final ObjectconstructDocument(Node node) Construct complete YAML document.constructMapping(MappingNode node) Create Map from mappingprotected voidconstructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) Fill provided Map with constructed dataprotected ObjectconstructObject(Node node) Construct object from the specified Node.protected ObjectconstructObjectNoCheck(Node node) Construct object from the specified Node without the check if it was already created.protected StringconstructScalar(ScalarNode node) Create string from scalarCreate List and fill it with dataprotected voidconstructSequenceStep2(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 voidconstructSet2ndStep(MappingNode node, Set<Object> set) protected ObjectcreateArray(Class<?> type, int size) createDefaultList(int initSize) createDefaultMap(int initSize) createDefaultSet(int initSize) protected ObjectfinalizeConstruction(Node node, Object data) protected ConstructgetConstructor(Node node) Get the constructor to construct the Node.getData()Construct and return the next documentfinal PropertyUtilsgetSingleData(Class<?> type) Ensure that the stream contains a single document and construct itbooleanbooleanfinal booleanbooleanprotected final ObjectnewInstance(Class<?> ancestor, Node node) protected ObjectnewInstance(Class<?> ancestor, Node node, boolean tryDefault) Tries to create a new object for the node.protected ObjectnewInstance(Node node) newList(SequenceNode node) newMap(MappingNode node) newSet(CollectionNode<?> node) protected voidprotected voidpostponeSetFilling(Set<Object> set, Object key) voidsetAllowDuplicateKeys(boolean allowDuplicateKeys) voidsetComposer(Composer composer) voidsetEnumCaseSensitive(boolean enumCaseSensitive) voidsetPropertyUtils(PropertyUtils propertyUtils) voidsetWrappedToRootException(boolean wrappedToRootException)
-
Field Details
-
NOT_INSTANTIATED_OBJECT
An instance returned by newInstance methods when instantiation has not been performed. -
yamlClassConstructors
-
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) -
yamlMultiConstructors
-
composer
No graph creator -
rootTag
the tag for the root node -
typeDefinitions
Mapping from a class to its manager -
typeTags
-
loadingConfig
options
-
-
Constructor Details
-
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
-
constructObject
-
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
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 correspondingTypeDescriptionorTypeDescription.newInstance(node)returnsnull.- Returns:
- - a new object created for
node.getType()by using corresponding TypeDescription.newInstance or default constructor. -NOT_INSTANTIATED_OBJECTin 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, ornullif 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) -
getLoadingConfig
-