Class TrackedNodeHandler
- All Implemented Interfaces:
NodeHandler<ImmutableNode>
A special NodeHandler
implementation for tracked nodes.
While basic access to a tracked node works in the same way as for usual immutable nodes, there are differences for other operations. For instance, the root node of the hierarchy is always the tracked node itself. Also the parent mapping requires some special attention: as long as the node is not detached, the parent mapping of the model to which the node belongs can be used.
This class inherits the major part of the NodeHandler
implementation from its base class. In order to
implement the parent mapping, an underlying NodeHandler
object has to be passed at construction time which
contains this information; requests for a node's parent are delegated to this handler. Further, the root node has to
be provided explicitly.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NodeHandler<ImmutableNode>
The handler for querying the parent mapping.private final ImmutableNode
The root node. -
Constructor Summary
ConstructorsConstructorDescriptionTrackedNodeHandler
(ImmutableNode root, NodeHandler<ImmutableNode> handler) Creates a new instance ofTrackedNodeHandler
and initializes it with all required information. -
Method Summary
Modifier and TypeMethodDescriptiongetParent
(ImmutableNode node) Gets the parent of the specified node.Gets the parent handler.Gets the root node of the underlying hierarchy.Methods inherited from class org.apache.commons.configuration2.tree.AbstractImmutableNodeHandler
checkIfNodeDefined, getAttributes, getAttributeValue, getChild, getChildren, getChildren, getChildrenCount, getMatchingChildren, getMatchingChildrenCount, getValue, hasAttributes, indexOfChild, isDefined, nodeName
-
Field Details
-
rootNode
The root node. -
parentHandler
The handler for querying the parent mapping.
-
-
Constructor Details
-
TrackedNodeHandler
Creates a new instance ofTrackedNodeHandler
and initializes it with all required information.- Parameters:
root
- the root node of the represented hierarchyhandler
- an underlying handler for delegation
-
-
Method Details
-
getParentHandler
Gets the parent handler. This is theNodeHandler
which is consulted for determining a node's parent node.- Returns:
- the parent
NodeHandler
-
getParent
Gets the parent of the specified node. This implementation delegates to the handler with the parent mapping.- Parameters:
node
- the node- Returns:
- the parent node
-
getRootNode
Gets the root node of the underlying hierarchy. This implementation returns the root node passed at construction time.- Returns:
- the current root node
-