Class BaseHierarchicalConfiguration.InterpolatedVisitor

java.lang.Object
org.apache.commons.configuration2.tree.ConfigurationNodeVisitorAdapter<ImmutableNode>
org.apache.commons.configuration2.BaseHierarchicalConfiguration.InterpolatedVisitor
All Implemented Interfaces:
ConfigurationNodeVisitor<ImmutableNode>
Enclosing class:
BaseHierarchicalConfiguration

private final class BaseHierarchicalConfiguration.InterpolatedVisitor extends ConfigurationNodeVisitorAdapter<ImmutableNode>
A specialized visitor implementation which constructs the root node of a configuration with all variables replaced by their interpolated values.
  • Field Details

    • builderStack

      private final List<ImmutableNode.Builder> builderStack
      A stack for managing node builder instances.
    • interpolatedRoot

      private ImmutableNode interpolatedRoot
      The resulting root node.
  • Constructor Details

    • InterpolatedVisitor

      public InterpolatedVisitor()
      Creates a new instance of InterpolatedVisitor.
  • Method Details

    • getInterpolatedRoot

      public ImmutableNode getInterpolatedRoot()
      Gets the result of this builder: the root node of the interpolated nodes hierarchy.
      Returns:
      the resulting root node
    • handleLeafNode

      private void handleLeafNode(ImmutableNode node, NodeHandler<ImmutableNode> handler)
      Handles interpolation for a node with no children. If interpolation does not change this node, it is copied as is to the resulting structure. Otherwise, a new node is created with the interpolated values.
      Parameters:
      node - the current node to be processed
      handler - the NodeHandler
    • interpolateAttributes

      private Map<String,Object> interpolateAttributes(ImmutableNode node, NodeHandler<ImmutableNode> handler)
      Returns a map with interpolated attributes of the passed in node.
      Parameters:
      node - the current node to be processed
      handler - the NodeHandler
      Returns:
      the map with interpolated attributes
    • interpolateAttributes

      private boolean interpolateAttributes(ImmutableNode node, NodeHandler<ImmutableNode> handler, Map<String,Object> interpolatedAttributes)
      Populates a map with interpolated attributes of the passed in node.
      Parameters:
      node - the current node to be processed
      handler - the NodeHandler
      interpolatedAttributes - a map for storing the results
      Returns:
      a flag whether an attribute value was changed by interpolation
    • isLeafNode

      private boolean isLeafNode(ImmutableNode node, NodeHandler<ImmutableNode> handler)
      Returns a flag whether the given node is a leaf. This is the case if it does not have children.
      Parameters:
      node - the node in question
      handler - the NodeHandler
      Returns:
      a flag whether this is a leaf node
    • peek

      private ImmutableNode.Builder peek()
      Returns the top-level element from the stack without removing it.
      Returns:
      the top-level element from the stack
    • pop

      private ImmutableNode.Builder pop()
      Pops the top-level element from the stack.
      Returns:
      the element popped from the stack
    • push

      private void push(ImmutableNode.Builder builder)
      Pushes a new builder on the stack.
      Parameters:
      builder - the builder
    • storeInterpolatedNode

      private void storeInterpolatedNode(ImmutableNode node)
      Stores a processed node. Per default, the node is added to the current builder on the stack. If no such builder exists, this is the result node.
      Parameters:
      node - the node to be stored
    • valueChanged

      private boolean valueChanged(Object interpolatedValue, Object value)
      Tests whether a value is changed because of interpolation.
      Parameters:
      interpolatedValue - the interpolated value
      value - the original value
      Returns:
      a flag whether the value was changed
    • visitAfterChildren

      public void visitAfterChildren(ImmutableNode node, NodeHandler<ImmutableNode> handler)
      Description copied from class: ConfigurationNodeVisitorAdapter
      Visits the specified node after after its children - if existing - have been processed. Empty dummy implementation of this interface method.
      Specified by:
      visitAfterChildren in interface ConfigurationNodeVisitor<ImmutableNode>
      Overrides:
      visitAfterChildren in class ConfigurationNodeVisitorAdapter<ImmutableNode>
      Parameters:
      node - the node to be visited
      handler - the NodeHandler
    • visitBeforeChildren

      public void visitBeforeChildren(ImmutableNode node, NodeHandler<ImmutableNode> handler)
      Description copied from class: ConfigurationNodeVisitorAdapter
      Visits the specified node before the children of this node - if existing - are processed. Empty dummy implementation of this interface method.
      Specified by:
      visitBeforeChildren in interface ConfigurationNodeVisitor<ImmutableNode>
      Overrides:
      visitBeforeChildren in class ConfigurationNodeVisitorAdapter<ImmutableNode>
      Parameters:
      node - the node to be visited
      handler - the NodeHandler