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 ImmutableNodeThe 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 voidhandleLeafNode(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 booleaninterpolateAttributes(ImmutableNode node, NodeHandler<ImmutableNode> handler, Map<String, Object> interpolatedAttributes) Populates a map with interpolated attributes of the passed in node.private booleanisLeafNode(ImmutableNode node, NodeHandler<ImmutableNode> handler) Returns a flag whether the given node is a leaf.private ImmutableNode.Builderpeek()Returns the top-level element from the stack without removing it.private ImmutableNode.Builderpop()Pops the top-level element from the stack.private voidpush(ImmutableNode.Builder builder) Pushes a new builder on the stack.private voidStores a processed node.private booleanvalueChanged(Object interpolatedValue, Object value) Tests whether a value is changed because of interpolation.voidvisitAfterChildren(ImmutableNode node, NodeHandler<ImmutableNode> handler) Visits the specified node after after its children - if existing - have been processed.voidvisitBeforeChildren(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- theNodeHandlerinterpolatedAttributes- 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:ConfigurationNodeVisitorAdapterVisits the specified node after after its children - if existing - have been processed. Empty dummy implementation of this interface method.- Specified by:
visitAfterChildrenin interfaceConfigurationNodeVisitor<ImmutableNode>- Overrides:
visitAfterChildrenin classConfigurationNodeVisitorAdapter<ImmutableNode>- Parameters:
node- the node to be visitedhandler- theNodeHandler
-
visitBeforeChildren
Description copied from class:ConfigurationNodeVisitorAdapterVisits the specified node before the children of this node - if existing - are processed. Empty dummy implementation of this interface method.- Specified by:
visitBeforeChildrenin interfaceConfigurationNodeVisitor<ImmutableNode>- Overrides:
visitBeforeChildrenin classConfigurationNodeVisitorAdapter<ImmutableNode>- Parameters:
node- the node to be visitedhandler- theNodeHandler
-