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 booleanprotected Composerprivate booleanprivate booleanprotected LoaderOptionsprivate final ArrayList<BaseConstructor.RecursiveTuple<Map<Object,Object>, BaseConstructor.RecursiveTuple<Object, Object>>> protected static final ObjectAn instance returned by newInstance methods when instantiation has not been performed.private PropertyUtilsprotected Tagprivate final ArrayList<BaseConstructor.RecursiveTuple<Set<Object>,Object>> protected final Map<Class<? extends Object>,TypeDescription> private booleanIt 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.booleanCheck if more documents availableprotected ObjectconstructArray(SequenceNode node) protected ObjectconstructArrayStep2(SequenceNode node, Object array) protected final ObjectconstructDocument(Node node) Construct complete YAML document.constructMapping(MappingNode node) protected voidconstructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) protected ObjectconstructObject(Node node) Construct object from the specified Node.protected ObjectconstructObjectNoCheck(Node node) protected StringconstructScalar(ScalarNode node) protected voidconstructSequenceStep2(SequenceNode node, Collection<Object> collection) constructSet(MappingNode node) constructSet(SequenceNode node) protected voidconstructSet2ndStep(MappingNode node, Set<Object> set) protected ObjectcreateArray(Class<?> type, int size) createDefaultList(int initSize) createDefaultMap(int initSize) createDefaultSet(int initSize) private voidFill the recursive structures and clean the internal collectionsprotected 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
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 -
enumCaseSensitive
private boolean enumCaseSensitive -
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
-
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
-
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, 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)
-