Class BaseConstructor

java.lang.Object
org.snakeyaml.engine.v2.constructor.BaseConstructor
Direct Known Subclasses:
StandardConstructor

public abstract class BaseConstructor extends Object
Base code
  • Field Details

  • Constructor Details

    • BaseConstructor

      public BaseConstructor(LoadSettings settings)
      Create
      Parameters:
      settings - - the configuration option
  • Method Details

    • constructSingleDocument

      public Object constructSingleDocument(Optional<Node> optionalNode)
      Ensure that the stream contains a single document and construct it
      Parameters:
      optionalNode - - composed Node
      Returns:
      constructed instance
    • construct

      protected Object construct(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
    • fillRecursive

      private void fillRecursive()
    • constructObject

      protected Object constructObject(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(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(Node node)
      Select ConstructNode inside the provided Node or the one associated with the Tag
      Parameters:
      node - Node to construct an instance from
      Returns:
      ConstructNode implementation for the specified node
    • constructScalar

      protected String constructScalar(ScalarNode node)
      Create String from the provided scalar node
      Parameters:
      node - - the source
      Returns:
      value of the scalar node
    • createEmptyListForNode

      protected List<Object> createEmptyListForNode(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(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(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(SequenceNode node)
      Create instance of List
      Parameters:
      node - - the source
      Returns:
      filled List
    • constructSequenceStep2

      protected void constructSequenceStep2(SequenceNode node, Collection<Object> collection)
      Fill the collection with the data from provided node
      Parameters:
      node - - the source
      collection - - the collection to fill
    • constructSet

      protected Set<Object> constructSet(MappingNode node)
      Create instance of Set from mapping node
      Parameters:
      node - - the source
      Returns:
      filled Set
    • constructMapping

      protected Map<Object,Object> constructMapping(MappingNode node)
      Create filled Map from the provided Node
      Parameters:
      node - - the source
      Returns:
      filled Map
    • constructMapping2ndStep

      protected void constructMapping2ndStep(MappingNode node, Map<Object,Object> mapping)
      Fill the mapping with the data from provided node
      Parameters:
      node - - the source
      mapping - - 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/value
      key - - the key to add to map
      value - - the value behind the key
    • constructSet2ndStep

      protected void constructSet2ndStep(MappingNode node, Set<Object> set)
      Fill the Map with the data from the node
      Parameters:
      node - - the source
      set - - 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 key
      key - - the item to add to the set