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 Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<ImmutableNode.Builder> A stack for managing node builder instances.private ImmutableNode
The resulting root node. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the result of this builder: the root node of the interpolated nodes hierarchy.private void
handleLeafNode
(ImmutableNode node, NodeHandler<ImmutableNode> handler) Handles interpolation for a node with no children.interpolateAttributes
(ImmutableNode node, NodeHandler<ImmutableNode> handler) Returns a map with interpolated attributes of the passed in node.private boolean
interpolateAttributes
(ImmutableNode node, NodeHandler<ImmutableNode> handler, Map<String, Object> interpolatedAttributes) Populates a map with interpolated attributes of the passed in node.private boolean
isLeafNode
(ImmutableNode node, NodeHandler<ImmutableNode> handler) Returns a flag whether the given node is a leaf.private ImmutableNode.Builder
peek()
Returns the top-level element from the stack without removing it.private ImmutableNode.Builder
pop()
Pops the top-level element from the stack.private void
push
(ImmutableNode.Builder builder) Pushes a new builder on the stack.private void
Stores a processed node.private boolean
valueChanged
(Object interpolatedValue, Object value) Tests whether a value is changed because of interpolation.void
visitAfterChildren
(ImmutableNode node, NodeHandler<ImmutableNode> handler) Visits the specified node after after its children - if existing - have been processed.void
visitBeforeChildren
(ImmutableNode node, NodeHandler<ImmutableNode> handler) Visits the specified node before the children of this node - if existing - are processed.Methods inherited from class org.apache.commons.configuration2.tree.ConfigurationNodeVisitorAdapter
terminate
-
Field Details
-
builderStack
A stack for managing node builder instances. -
interpolatedRoot
The resulting root node.
-
-
Constructor Details
-
InterpolatedVisitor
public InterpolatedVisitor()Creates a new instance ofInterpolatedVisitor
.
-
-
Method Details
-
getInterpolatedRoot
Gets the result of this builder: the root node of the interpolated nodes hierarchy.- Returns:
- the resulting root node
-
handleLeafNode
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 processedhandler
- theNodeHandler
-
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 processedhandler
- theNodeHandler
- 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 processedhandler
- theNodeHandler
interpolatedAttributes
- a map for storing the results- Returns:
- a flag whether an attribute value was changed by interpolation
-
isLeafNode
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 questionhandler
- theNodeHandler
- Returns:
- a flag whether this is a leaf node
-
peek
Returns the top-level element from the stack without removing it.- Returns:
- the top-level element from the stack
-
pop
Pops the top-level element from the stack.- Returns:
- the element popped from the stack
-
push
Pushes a new builder on the stack.- Parameters:
builder
- the builder
-
storeInterpolatedNode
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
Tests whether a value is changed because of interpolation.- Parameters:
interpolatedValue
- the interpolated valuevalue
- the original value- Returns:
- a flag whether the value was changed
-
visitAfterChildren
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 interfaceConfigurationNodeVisitor<ImmutableNode>
- Overrides:
visitAfterChildren
in classConfigurationNodeVisitorAdapter<ImmutableNode>
- Parameters:
node
- the node to be visitedhandler
- theNodeHandler
-
visitBeforeChildren
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 interfaceConfigurationNodeVisitor<ImmutableNode>
- Overrides:
visitBeforeChildren
in classConfigurationNodeVisitorAdapter<ImmutableNode>
- Parameters:
node
- the node to be visitedhandler
- theNodeHandler
-