public abstract class BaseConstructor
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
BaseConstructor.RecursiveTuple<T,K> |
Modifier and Type | Field and Description |
---|---|
private boolean |
allowDuplicateKeys |
protected Composer |
composer |
(package private) java.util.Map<Node,java.lang.Object> |
constructedObjects |
private boolean |
enumCaseSensitive |
private boolean |
explicitPropertyUtils |
protected LoaderOptions |
loadingConfig |
private java.util.ArrayList<BaseConstructor.RecursiveTuple<java.util.Map<java.lang.Object,java.lang.Object>,BaseConstructor.RecursiveTuple<java.lang.Object,java.lang.Object>>> |
maps2fill |
protected static java.lang.Object |
NOT_INSTANTIATED_OBJECT
An instance returned by newInstance methods when instantiation has not been performed.
|
private PropertyUtils |
propertyUtils |
private java.util.Set<Node> |
recursiveObjects |
protected Tag |
rootTag |
private java.util.ArrayList<BaseConstructor.RecursiveTuple<java.util.Set<java.lang.Object>,java.lang.Object>> |
sets2fill |
protected java.util.Map<java.lang.Class<? extends java.lang.Object>,TypeDescription> |
typeDefinitions |
protected java.util.Map<Tag,java.lang.Class<? extends java.lang.Object>> |
typeTags |
private boolean |
wrappedToRootException |
protected java.util.Map<NodeId,Construct> |
yamlClassConstructors
It maps the node kind to the the Construct implementation.
|
protected java.util.Map<Tag,Construct> |
yamlConstructors
It maps the (explicit or implicit) tag to the Construct implementation.
|
protected java.util.Map<java.lang.String,Construct> |
yamlMultiConstructors
It maps the (explicit or implicit) tag to the Construct implementation.
|
Constructor and Description |
---|
BaseConstructor() |
BaseConstructor(LoaderOptions loadingConfig) |
Modifier and Type | Method and Description |
---|---|
TypeDescription |
addTypeDescription(TypeDescription definition)
Make YAML aware how to parse a custom Class.
|
boolean |
checkData()
Check if more documents available
|
protected java.lang.Object |
constructArray(SequenceNode node) |
protected java.lang.Object |
constructArrayStep2(SequenceNode node,
java.lang.Object array) |
protected java.lang.Object |
constructDocument(Node node)
Construct complete YAML document.
|
protected java.util.Map<java.lang.Object,java.lang.Object> |
constructMapping(MappingNode node) |
protected void |
constructMapping2ndStep(MappingNode node,
java.util.Map<java.lang.Object,java.lang.Object> mapping) |
protected java.lang.Object |
constructObject(Node node)
Construct object from the specified Node.
|
protected java.lang.Object |
constructObjectNoCheck(Node node) |
protected java.lang.String |
constructScalar(ScalarNode node) |
protected java.util.List<? extends java.lang.Object> |
constructSequence(SequenceNode node) |
protected void |
constructSequenceStep2(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 void |
constructSet2ndStep(MappingNode node,
java.util.Set<java.lang.Object> set) |
protected java.lang.Object |
createArray(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) |
private void |
fillRecursive()
Fill the recursive structures and clean the internal collections
|
protected java.lang.Object |
finalizeConstruction(Node node,
java.lang.Object data) |
protected Construct |
getConstructor(Node node)
Get the constructor to construct the Node.
|
java.lang.Object |
getData()
Construct and return the next document
|
PropertyUtils |
getPropertyUtils() |
java.lang.Object |
getSingleData(java.lang.Class<?> type)
Ensure that the stream contains a single document and construct it
|
boolean |
isAllowDuplicateKeys() |
boolean |
isEnumCaseSensitive() |
boolean |
isExplicitPropertyUtils() |
boolean |
isWrappedToRootException() |
protected java.lang.Object |
newInstance(java.lang.Class<?> ancestor,
Node node) |
protected java.lang.Object |
newInstance(java.lang.Class<?> ancestor,
Node node,
boolean tryDefault)
Tries to create a new object for the node.
|
protected java.lang.Object |
newInstance(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 void |
postponeMapFilling(java.util.Map<java.lang.Object,java.lang.Object> mapping,
java.lang.Object key,
java.lang.Object value) |
protected void |
postponeSetFilling(java.util.Set<java.lang.Object> set,
java.lang.Object key) |
void |
setAllowDuplicateKeys(boolean allowDuplicateKeys) |
void |
setComposer(Composer composer) |
void |
setEnumCaseSensitive(boolean enumCaseSensitive) |
void |
setPropertyUtils(PropertyUtils propertyUtils) |
void |
setWrappedToRootException(boolean wrappedToRootException) |
protected static final java.lang.Object NOT_INSTANTIATED_OBJECT
protected final java.util.Map<NodeId,Construct> yamlClassConstructors
protected final java.util.Map<Tag,Construct> yamlConstructors
protected final java.util.Map<java.lang.String,Construct> yamlMultiConstructors
protected Composer composer
final java.util.Map<Node,java.lang.Object> constructedObjects
private final java.util.Set<Node> recursiveObjects
private final java.util.ArrayList<BaseConstructor.RecursiveTuple<java.util.Map<java.lang.Object,java.lang.Object>,BaseConstructor.RecursiveTuple<java.lang.Object,java.lang.Object>>> maps2fill
private final java.util.ArrayList<BaseConstructor.RecursiveTuple<java.util.Set<java.lang.Object>,java.lang.Object>> sets2fill
protected Tag rootTag
private PropertyUtils propertyUtils
private boolean explicitPropertyUtils
private boolean allowDuplicateKeys
private boolean wrappedToRootException
private boolean enumCaseSensitive
protected final java.util.Map<java.lang.Class<? extends java.lang.Object>,TypeDescription> typeDefinitions
protected final java.util.Map<Tag,java.lang.Class<? extends java.lang.Object>> typeTags
protected LoaderOptions loadingConfig
public BaseConstructor()
public BaseConstructor(LoaderOptions loadingConfig)
public void setComposer(Composer composer)
public boolean checkData()
public java.lang.Object getData() throws java.util.NoSuchElementException
java.util.NoSuchElementException
public java.lang.Object getSingleData(java.lang.Class<?> type)
type
- the class of the instance being createdComposerException
- in case there are more documents in the streamprotected final java.lang.Object constructDocument(Node node)
node
- root Nodeprivate void fillRecursive()
protected java.lang.Object constructObject(Node node)
node
- Node to be constructedprotected java.lang.Object constructObjectNoCheck(Node node)
protected Construct getConstructor(Node node)
protected java.lang.String constructScalar(ScalarNode node)
protected java.util.List<java.lang.Object> createDefaultList(int initSize)
protected java.util.Set<java.lang.Object> createDefaultSet(int initSize)
protected java.util.Map<java.lang.Object,java.lang.Object> createDefaultMap(int initSize)
protected java.lang.Object createArray(java.lang.Class<?> type, int size)
protected java.lang.Object finalizeConstruction(Node node, java.lang.Object data)
protected java.lang.Object newInstance(Node node)
protected final java.lang.Object newInstance(java.lang.Class<?> ancestor, Node node)
protected java.lang.Object newInstance(java.lang.Class<?> ancestor, Node node, boolean tryDefault)
ancestor
- expected ancestor of the node.getType()
node
- for which to create a corresponding java objecttryDefault
- should default constructor to be tried when there is no corresponding
TypeDescription
or TypeDescription.newInstance(node)
returns
null
.node.getType()
by using corresponding
TypeDescription.newInstance or default constructor. - NOT_INSTANTIATED_OBJECT
in case no object has been createdprotected java.util.Set<java.lang.Object> newSet(CollectionNode<?> 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.List<? extends java.lang.Object> constructSequence(SequenceNode node)
protected java.util.Set<? extends java.lang.Object> constructSet(SequenceNode node)
protected java.lang.Object constructArray(SequenceNode node)
protected void constructSequenceStep2(SequenceNode node, java.util.Collection<java.lang.Object> collection)
protected java.lang.Object constructArrayStep2(SequenceNode node, java.lang.Object array)
protected java.util.Set<java.lang.Object> constructSet(MappingNode node)
protected java.util.Map<java.lang.Object,java.lang.Object> constructMapping(MappingNode node)
protected void constructMapping2ndStep(MappingNode node, java.util.Map<java.lang.Object,java.lang.Object> mapping)
protected void postponeMapFilling(java.util.Map<java.lang.Object,java.lang.Object> mapping, java.lang.Object key, java.lang.Object value)
protected void constructSet2ndStep(MappingNode node, java.util.Set<java.lang.Object> set)
protected void postponeSetFilling(java.util.Set<java.lang.Object> set, java.lang.Object key)
public void setPropertyUtils(PropertyUtils propertyUtils)
public final PropertyUtils getPropertyUtils()
public TypeDescription addTypeDescription(TypeDescription definition)
definition
- to be added to the Constructordefinition
, or null
if
there was no mapping for definition
.public final boolean isExplicitPropertyUtils()
public boolean isAllowDuplicateKeys()
public void setAllowDuplicateKeys(boolean allowDuplicateKeys)
public boolean isWrappedToRootException()
public void setWrappedToRootException(boolean wrappedToRootException)
public boolean isEnumCaseSensitive()
public void setEnumCaseSensitive(boolean enumCaseSensitive)