Class BaseConstructor
- java.lang.Object
-
- org.snakeyaml.engine.v2.constructor.BaseConstructor
-
- Direct Known Subclasses:
StandardConstructor
public abstract class BaseConstructor extends Object
Base code
-
-
Field Summary
Fields Modifier and Type Field Description protected LoadSettingssettingskeep the settingsprotected Map<org.snakeyaml.engine.v2.nodes.Tag,ConstructNode>tagConstructorsIt maps the (explicit or implicit) tag to the Construct implementation.
-
Constructor Summary
Constructors Constructor Description BaseConstructor(LoadSettings settings)Create
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Objectconstruct(org.snakeyaml.engine.v2.nodes.Node node)Construct complete YAML document.protected Map<Object,Object>constructMapping(org.snakeyaml.engine.v2.nodes.MappingNode node)Create filled Map from the provided Nodeprotected voidconstructMapping2ndStep(org.snakeyaml.engine.v2.nodes.MappingNode node, Map<Object,Object> mapping)Fill the mapping with the data from provided nodeprotected ObjectconstructObject(org.snakeyaml.engine.v2.nodes.Node node)Construct object from the specified Node.protected ObjectconstructObjectNoCheck(org.snakeyaml.engine.v2.nodes.Node node)Construct object from the specified Node.protected StringconstructScalar(org.snakeyaml.engine.v2.nodes.ScalarNode node)Create String from the provided scalar nodeprotected List<Object>constructSequence(org.snakeyaml.engine.v2.nodes.SequenceNode node)Create instance of Listprotected voidconstructSequenceStep2(org.snakeyaml.engine.v2.nodes.SequenceNode node, Collection<Object> collection)Fill the collection with the data from provided nodeprotected Set<Object>constructSet(org.snakeyaml.engine.v2.nodes.MappingNode node)Create instance of Set from mapping nodeprotected voidconstructSet2ndStep(org.snakeyaml.engine.v2.nodes.MappingNode node, Set<Object> set)Fill the Map with the data from the nodeObjectconstructSingleDocument(Optional<org.snakeyaml.engine.v2.nodes.Node> optionalNode)Ensure that the stream contains a single document and construct itprotected List<Object>createEmptyListForNode(org.snakeyaml.engine.v2.nodes.SequenceNode node)Create List implementation.protected Map<Object,Object>createEmptyMapFor(org.snakeyaml.engine.v2.nodes.MappingNode node)Create Map implementation.protected Set<Object>createEmptySetForNode(org.snakeyaml.engine.v2.nodes.MappingNode node)Create Set implementation.protected Optional<ConstructNode>findConstructorFor(org.snakeyaml.engine.v2.nodes.Node node)protected voidpostponeMapFilling(Map<Object,Object> mapping, Object key, Object value)if keyObject is created it 2 steps we should postpone putting it in map because it may have different hash after initialization compared to clean just created one.protected voidpostponeSetFilling(Set<Object> set, Object key)if keyObject is created it 2 steps we should postpone putting it into the set because it may have different hash after initialization compared to clean just created one.
-
-
-
Field Detail
-
tagConstructors
protected final Map<org.snakeyaml.engine.v2.nodes.Tag,ConstructNode> tagConstructors
It maps the (explicit or implicit) tag to the Construct implementation.
-
settings
protected LoadSettings settings
keep the settings
-
-
Constructor Detail
-
BaseConstructor
public BaseConstructor(LoadSettings settings)
Create- Parameters:
settings- - the configuration option
-
-
Method Detail
-
constructSingleDocument
public Object constructSingleDocument(Optional<org.snakeyaml.engine.v2.nodes.Node> optionalNode)
Ensure that the stream contains a single document and construct it- Parameters:
optionalNode- - composed Node- Returns:
- constructed instance
-
construct
protected Object construct(org.snakeyaml.engine.v2.nodes.Node node)
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
protected Object constructObject(org.snakeyaml.engine.v2.nodes.Node node)
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
protected Object constructObjectNoCheck(org.snakeyaml.engine.v2.nodes.Node node)
Construct object from the specified Node. It does not check if existing instance the node is already constructed.- Parameters:
node- - the source- Returns:
- instantiated object
-
findConstructorFor
protected Optional<ConstructNode> findConstructorFor(org.snakeyaml.engine.v2.nodes.Node node)
- Parameters:
node-Nodeto construct an instance from- Returns:
ConstructNodeimplementation for the specified node
-
constructScalar
protected String constructScalar(org.snakeyaml.engine.v2.nodes.ScalarNode node)
Create String from the provided scalar node- Parameters:
node- - the source- Returns:
- value of the scalar node
-
createEmptyListForNode
protected List<Object> createEmptyListForNode(org.snakeyaml.engine.v2.nodes.SequenceNode node)
Create List implementation. By default, it returns the value configured in the settings in getDefaultList(). Any custom List implementation can be provided.- Parameters:
node- - the node to fill the List- Returns:
- empty List to fill
-
createEmptySetForNode
protected Set<Object> createEmptySetForNode(org.snakeyaml.engine.v2.nodes.MappingNode node)
Create Set implementation. By default, it returns the value configured in the settings in getDefaultSet(). Any custom Set implementation can be provided.- Parameters:
node- - the node to fill the Set- Returns:
- empty Set to fill
-
createEmptyMapFor
protected Map<Object,Object> createEmptyMapFor(org.snakeyaml.engine.v2.nodes.MappingNode node)
Create Map implementation. By default, it returns the value configured in the settings in getDefaultMap(). Any custom Map implementation can be provided.- Parameters:
node- - the node to fill the Map- Returns:
- empty Map to fill
-
constructSequence
protected List<Object> constructSequence(org.snakeyaml.engine.v2.nodes.SequenceNode node)
Create instance of List- Parameters:
node- - the source- Returns:
- filled List
-
constructSequenceStep2
protected void constructSequenceStep2(org.snakeyaml.engine.v2.nodes.SequenceNode node, Collection<Object> collection)Fill the collection with the data from provided node- Parameters:
node- - the sourcecollection- - the collection to fill
-
constructSet
protected Set<Object> constructSet(org.snakeyaml.engine.v2.nodes.MappingNode node)
Create instance of Set from mapping node- Parameters:
node- - the source- Returns:
- filled Set
-
constructMapping
protected Map<Object,Object> constructMapping(org.snakeyaml.engine.v2.nodes.MappingNode node)
Create filled Map from the provided Node- Parameters:
node- - the source- Returns:
- filled Map
-
constructMapping2ndStep
protected void constructMapping2ndStep(org.snakeyaml.engine.v2.nodes.MappingNode node, Map<Object,Object> mapping)Fill the mapping with the data from provided node- Parameters:
node- - the sourcemapping- - empty map to be filled
-
postponeMapFilling
protected void postponeMapFilling(Map<Object,Object> mapping, Object key, Object value)
if keyObject is created it 2 steps we should postpone putting it in map because it may have different hash after initialization compared to clean just created one. And map of course does not observe key hashCode changes.- Parameters:
mapping- - the mapping to add key/valuekey- - the key to add to mapvalue- - the value behind the key
-
constructSet2ndStep
protected void constructSet2ndStep(org.snakeyaml.engine.v2.nodes.MappingNode node, Set<Object> set)Fill the Map with the data from the node- Parameters:
node- - the sourceset- - empty set to fill
-
postponeSetFilling
protected void postponeSetFilling(Set<Object> set, Object key)
if keyObject is created it 2 steps we should postpone putting it into the set because it may have different hash after initialization compared to clean just created one. And set of course does not observe value hashCode changes.- Parameters:
set- - the set to add the keykey- - the item to add to the set
-
-