Class BaseHierarchicalConfiguration.BuilderVisitor
- java.lang.Object
-
- org.apache.commons.configuration2.tree.ConfigurationNodeVisitorAdapter<ImmutableNode>
-
- org.apache.commons.configuration2.BaseHierarchicalConfiguration.BuilderVisitor
-
- All Implemented Interfaces:
ConfigurationNodeVisitor<ImmutableNode>
- Direct Known Subclasses:
XMLConfiguration.XMLBuilderVisitor
- Enclosing class:
- BaseHierarchicalConfiguration
protected abstract static class BaseHierarchicalConfiguration.BuilderVisitor extends ConfigurationNodeVisitorAdapter<ImmutableNode>
A specialized visitor base class that can be used for storing the tree of configuration nodes. The basic idea is that each node can be associated with a reference object. This reference object has a concrete meaning in a derived class, e.g. an entry in a JNDI context or an XML element. When the configuration tree is set up, theload()
method is responsible for setting the reference objects. When the configuration tree is later modified, new nodes do not have a defined reference object. This visitor class processes all nodes and finds the ones without a defined reference object. For those nodes theinsert()
method is called, which must be defined in concrete sub classes. This method can perform all steps to integrate the new node into the original structure.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BuilderVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
insert(ImmutableNode newNode, ImmutableNode parent, ImmutableNode sibling1, ImmutableNode sibling2, ReferenceNodeHandler refHandler)
Inserts a new node into the structure constructed by this builder.private void
insertNewChildNodes(ImmutableNode node, ReferenceNodeHandler refHandler)
Inserts new children that have been added to the specified node.protected abstract void
update(ImmutableNode node, java.lang.Object reference, ReferenceNodeHandler refHandler)
Updates a node that already existed in the original hierarchy.private void
updateNode(ImmutableNode node, ReferenceNodeHandler refHandler)
Updates the value of a node.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, visitAfterChildren
-
-
-
-
Method Detail
-
insert
protected abstract void insert(ImmutableNode newNode, ImmutableNode parent, ImmutableNode sibling1, ImmutableNode sibling2, ReferenceNodeHandler refHandler)
Inserts a new node into the structure constructed by this builder. This method is called for each node that has been added to the configuration tree after the configuration has been loaded from its source. These new nodes have to be inserted into the original structure. The passed in nodes define the position of the node to be inserted: its parent and the siblings between to insert.- Parameters:
newNode
- the node to be insertedparent
- the parent nodesibling1
- the sibling after which the node is to be inserted; can be null if the new node is going to be the first child nodesibling2
- the sibling before which the node is to be inserted; can be null if the new node is going to be the last child noderefHandler
- theReferenceNodeHandler
-
insertNewChildNodes
private void insertNewChildNodes(ImmutableNode node, ReferenceNodeHandler refHandler)
Inserts new children that have been added to the specified node.- Parameters:
node
- the current node to be processedrefHandler
- theReferenceNodeHandler
-
update
protected abstract void update(ImmutableNode node, java.lang.Object reference, ReferenceNodeHandler refHandler)
Updates a node that already existed in the original hierarchy. This method is called for each node that has an assigned reference object. A concrete implementation should update the reference according to the node's current value.- Parameters:
node
- the current node to be processedreference
- the reference object for this noderefHandler
- theReferenceNodeHandler
-
updateNode
private void updateNode(ImmutableNode node, ReferenceNodeHandler refHandler)
Updates the value of a node. If this node is associated with a reference object, theupdate()
method is called.- Parameters:
node
- the current node to be processedrefHandler
- theReferenceNodeHandler
-
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 interfaceConfigurationNodeVisitor<ImmutableNode>
- Overrides:
visitBeforeChildren
in classConfigurationNodeVisitorAdapter<ImmutableNode>
- Parameters:
node
- the node to be visitedhandler
- theNodeHandler
-
-