Package org.yaml.snakeyaml.constructor
Class BaseConstructor
java.lang.Object
org.yaml.snakeyaml.constructor.BaseConstructor
- Direct Known Subclasses:
SafeConstructor
public abstract class BaseConstructor
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description protected Composercomposerprotected LoaderOptionsloadingConfigprotected TagrootTagprotected java.util.Map<java.lang.Class<? extends java.lang.Object>,TypeDescription>typeDefinitionsprotected java.util.Map<Tag,java.lang.Class<? extends java.lang.Object>>typeTagsprotected java.util.Map<NodeId,Construct>yamlClassConstructorsIt maps the node kind to the the Construct implementation.protected java.util.Map<Tag,Construct>yamlConstructorsIt maps the (explicit or implicit) tag to the Construct implementation.protected java.util.Map<java.lang.String,Construct>yamlMultiConstructorsIt maps the (explicit or implicit) tag to the Construct implementation. -
Constructor Summary
Constructors Constructor Description BaseConstructor()BaseConstructor(LoaderOptions loadingConfig) -
Method Summary
Modifier and Type Method Description TypeDescriptionaddTypeDescription(TypeDescription definition)Make YAML aware how to parse a custom Class.booleancheckData()Check if more documents availableprotected java.lang.ObjectconstructArray(SequenceNode node)protected java.lang.ObjectconstructArrayStep2(SequenceNode node, java.lang.Object array)protected java.lang.ObjectconstructDocument(Node node)Construct complete YAML document.protected java.util.Map<java.lang.Object,java.lang.Object>constructMapping(MappingNode node)protected voidconstructMapping2ndStep(MappingNode node, java.util.Map<java.lang.Object,java.lang.Object> mapping)protected java.lang.ObjectconstructObject(Node node)Construct object from the specified Node.protected java.lang.ObjectconstructObjectNoCheck(Node node)protected java.lang.StringconstructScalar(ScalarNode node)protected java.util.List<? extends java.lang.Object>constructSequence(SequenceNode node)protected voidconstructSequenceStep2(SequenceNode node, java.util.Collection<java.lang.Object> collection)protected java.util.Set<java.lang.Object>constructSet(MappingNode node)protected java.util.Set<? extends java.lang.Object>constructSet(SequenceNode node)protected voidconstructSet2ndStep(MappingNode node, java.util.Set<java.lang.Object> set)protected java.lang.ObjectcreateArray(java.lang.Class<?> type, int size)protected java.util.List<java.lang.Object>createDefaultList(int initSize)protected java.util.Map<java.lang.Object,java.lang.Object>createDefaultMap(int initSize)protected java.util.Set<java.lang.Object>createDefaultSet(int initSize)protected java.lang.ObjectfinalizeConstruction(Node node, java.lang.Object data)protected ConstructgetConstructor(Node node)Get the constructor to construct the Node.java.lang.ObjectgetData()Construct and return the next documentPropertyUtilsgetPropertyUtils()java.lang.ObjectgetSingleData(java.lang.Class<?> type)Ensure that the stream contains a single document and construct itbooleanisAllowDuplicateKeys()booleanisExplicitPropertyUtils()booleanisWrappedToRootException()protected java.lang.ObjectnewInstance(java.lang.Class<?> ancestor, Node node)protected java.lang.ObjectnewInstance(java.lang.Class<?> ancestor, Node node, boolean tryDefault)protected java.lang.ObjectnewInstance(Node node)protected java.util.List<java.lang.Object>newList(SequenceNode node)protected java.util.Map<java.lang.Object,java.lang.Object>newMap(MappingNode node)protected java.util.Set<java.lang.Object>newSet(CollectionNode<?> node)protected voidpostponeMapFilling(java.util.Map<java.lang.Object,java.lang.Object> mapping, java.lang.Object key, java.lang.Object value)protected voidpostponeSetFilling(java.util.Set<java.lang.Object> set, java.lang.Object key)voidsetAllowDuplicateKeys(boolean allowDuplicateKeys)voidsetComposer(Composer composer)voidsetPropertyUtils(PropertyUtils propertyUtils)voidsetWrappedToRootException(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
-
rootTag
-
typeDefinitions
protected final java.util.Map<java.lang.Class<? extends java.lang.Object>,TypeDescription> 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
public java.lang.Object getData() throws java.util.NoSuchElementExceptionConstruct and return the next document- Returns:
- constructed instance
- Throws:
java.util.NoSuchElementException
-
getSingleData
public java.lang.Object getSingleData(java.lang.Class<?> type)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
-
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
protected java.util.List<java.lang.Object> createDefaultList(int initSize) -
createDefaultSet
protected java.util.Set<java.lang.Object> createDefaultSet(int initSize) -
createDefaultMap
protected java.util.Map<java.lang.Object,java.lang.Object> createDefaultMap(int initSize) -
createArray
protected java.lang.Object createArray(java.lang.Class<?> type, int size) -
finalizeConstruction
-
newInstance
-
newInstance
protected final java.lang.Object newInstance(java.lang.Class<?> ancestor, Node node) throws java.lang.InstantiationException- Throws:
java.lang.InstantiationException
-
newInstance
protected java.lang.Object newInstance(java.lang.Class<?> ancestor, Node node, boolean tryDefault) throws java.lang.InstantiationException- Throws:
java.lang.InstantiationException
-
newSet
-
newList
-
newMap
-
constructSequence
-
constructSet
-
constructArray
-
constructSequenceStep2
protected void constructSequenceStep2(SequenceNode node, java.util.Collection<java.lang.Object> collection) -
constructArrayStep2
-
constructSet
-
constructMapping
-
constructMapping2ndStep
protected void constructMapping2ndStep(MappingNode node, java.util.Map<java.lang.Object,java.lang.Object> mapping) -
postponeMapFilling
protected void postponeMapFilling(java.util.Map<java.lang.Object,java.lang.Object> mapping, java.lang.Object key, java.lang.Object value) -
constructSet2ndStep
-
postponeSetFilling
protected void postponeSetFilling(java.util.Set<java.lang.Object> set, java.lang.Object key) -
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, or null if there was no mapping for definition.
-
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)
-