public abstract class BaseConstructor extends Object
Modifier and Type | Field and Description |
---|---|
protected Composer |
composer
No graph creator
|
protected LoaderOptions |
loadingConfig
options
|
protected static Object |
NOT_INSTANTIATED_OBJECT
An instance returned by newInstance methods when instantiation has not been performed.
|
protected Tag |
rootTag
the tag for the root node
|
protected Map<Class<? extends Object>,TypeDescription> |
typeDefinitions
Mapping from a class to its manager
|
protected Map<Tag,Class<? extends Object>> |
typeTags
register classes for tags
|
protected Map<NodeId,Construct> |
yamlClassConstructors
It maps the node kind to the the Construct implementation.
|
protected Map<Tag,Construct> |
yamlConstructors
It maps the (explicit or implicit) tag to the Construct implementation.
|
protected Map<String,Construct> |
yamlMultiConstructors
It maps the (explicit or implicit) tag to the Construct implementation.
|
Constructor and Description |
---|
BaseConstructor()
Deprecated.
use the options
|
BaseConstructor(LoaderOptions loadingConfig)
Create
|
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 Object |
constructArray(SequenceNode node)
Create array from sequence
|
protected Object |
constructArrayStep2(SequenceNode node,
Object array)
Fill array from node
|
protected Object |
constructDocument(Node node)
Construct complete YAML document.
|
protected Map<Object,Object> |
constructMapping(MappingNode node)
Create Map from mapping
|
protected void |
constructMapping2ndStep(MappingNode node,
Map<Object,Object> mapping)
Fill provided Map with constructed data
|
protected 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 scalar
|
protected List<? extends Object> |
constructSequence(SequenceNode node)
Create List and fill it with data
|
protected void |
constructSequenceStep2(SequenceNode node,
Collection<Object> collection)
Fill the provided collection with the data from the Node
|
protected Set<Object> |
constructSet(MappingNode node)
Create Set from mapping
|
protected Set<? extends Object> |
constructSet(SequenceNode node)
create Set from sequence
|
protected void |
constructSet2ndStep(MappingNode node,
Set<Object> set) |
protected Object |
createArray(Class<?> type,
int size) |
protected List<Object> |
createDefaultList(int initSize) |
protected Map<Object,Object> |
createDefaultMap(int initSize) |
protected Set<Object> |
createDefaultSet(int initSize) |
protected Object |
finalizeConstruction(Node node,
Object data) |
protected Construct |
getConstructor(Node node)
Get the constructor to construct the Node.
|
Object |
getData()
Construct and return the next document
|
PropertyUtils |
getPropertyUtils() |
Object |
getSingleData(Class<?> type)
Ensure that the stream contains a single document and construct it
|
boolean |
isAllowDuplicateKeys() |
boolean |
isEnumCaseSensitive() |
boolean |
isExplicitPropertyUtils() |
boolean |
isWrappedToRootException() |
protected 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) |
protected List<Object> |
newList(SequenceNode node) |
protected Map<Object,Object> |
newMap(MappingNode node) |
protected Set<Object> |
newSet(CollectionNode<?> node) |
protected void |
postponeMapFilling(Map<Object,Object> mapping,
Object key,
Object value) |
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) |
protected static final Object NOT_INSTANTIATED_OBJECT
protected final Map<NodeId,Construct> yamlClassConstructors
protected final Map<Tag,Construct> yamlConstructors
protected final Map<String,Construct> yamlMultiConstructors
protected Composer composer
protected Tag rootTag
protected final Map<Class<? extends Object>,TypeDescription> typeDefinitions
protected LoaderOptions loadingConfig
@Deprecated public BaseConstructor()
public BaseConstructor(LoaderOptions loadingConfig)
loadingConfig
- - optionspublic void setComposer(Composer composer)
public boolean checkData()
public Object getData() throws NoSuchElementException
NoSuchElementException
public Object getSingleData(Class<?> type)
type
- the class of the instance being createdComposerException
- in case there are more documents in the streamprotected final Object constructDocument(Node node)
node
- root Nodeprotected Object constructObject(Node node)
node
- Node to be constructedprotected Object constructObjectNoCheck(Node node)
node
- - the sourceprotected Construct getConstructor(Node node)
protected String constructScalar(ScalarNode node)
node
- - the sourceprotected Object newInstance(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 Set<Object> newSet(CollectionNode<?> node)
protected List<Object> newList(SequenceNode node)
protected Map<Object,Object> newMap(MappingNode node)
protected List<? extends Object> constructSequence(SequenceNode node)
node
- - the sourceprotected Set<? extends Object> constructSet(SequenceNode node)
node
- - sequenceprotected Object constructArray(SequenceNode node)
node
- - sequenceprotected void constructSequenceStep2(SequenceNode node, Collection<Object> collection)
node
- - the sourcecollection
- - data to fillprotected Object constructArrayStep2(SequenceNode node, Object array)
node
- - the sourcearray
- - the destinationprotected Set<Object> constructSet(MappingNode node)
node
- - mappingprotected Map<Object,Object> constructMapping(MappingNode node)
node
- - mappingprotected void constructMapping2ndStep(MappingNode node, Map<Object,Object> mapping)
node
- - sourcemapping
- - map to fillprotected void postponeMapFilling(Map<Object,Object> mapping, Object key, Object value)
protected void constructSet2ndStep(MappingNode node, Set<Object> set)
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)
Copyright © 2008–2022. All rights reserved.