Package org.apache.commons.configuration
Class HierarchicalConfiguration.BuilderVisitor
- java.lang.Object
-
- org.apache.commons.configuration.HierarchicalConfiguration.NodeVisitor
-
- org.apache.commons.configuration.HierarchicalConfiguration.BuilderVisitor
-
- Enclosing class:
- HierarchicalConfiguration
protected abstract static class HierarchicalConfiguration.BuilderVisitor extends HierarchicalConfiguration.NodeVisitor
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 java.lang.Object
insert(HierarchicalConfiguration.Node newNode, HierarchicalConfiguration.Node parent, HierarchicalConfiguration.Node sibling1, HierarchicalConfiguration.Node sibling2)
Inserts a new node into the structure constructed by this builder.void
visitBeforeChildren(HierarchicalConfiguration.Node node, ConfigurationKey key)
Visits the specified node before its children have been traversed.-
Methods inherited from class org.apache.commons.configuration.HierarchicalConfiguration.NodeVisitor
terminate, visitAfterChildren
-
-
-
-
Constructor Detail
-
BuilderVisitor
protected BuilderVisitor()
-
-
Method Detail
-
visitBeforeChildren
public void visitBeforeChildren(HierarchicalConfiguration.Node node, ConfigurationKey key)
Visits the specified node before its children have been traversed.- Overrides:
visitBeforeChildren
in classHierarchicalConfiguration.NodeVisitor
- Parameters:
node
- the node to visitkey
- the current key
-
insert
protected abstract java.lang.Object insert(HierarchicalConfiguration.Node newNode, HierarchicalConfiguration.Node parent, HierarchicalConfiguration.Node sibling1, HierarchicalConfiguration.Node sibling2)
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. The return value is interpreted as the new reference of the affectedNode
object; if it is not null , it is passed to the node'ssetReference()
method.- 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 node- Returns:
- the reference object for the node to be inserted
-
-