Class TrackedNodeHandler
- java.lang.Object
-
- org.apache.commons.configuration2.tree.AbstractImmutableNodeHandler
-
- org.apache.commons.configuration2.tree.TrackedNodeHandler
-
- All Implemented Interfaces:
NodeHandler<ImmutableNode>
final class TrackedNodeHandler extends AbstractImmutableNodeHandler
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 underlyingNodeHandler
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
Fields Modifier and Type Field Description private NodeHandler<ImmutableNode>
parentHandler
The handler for querying the parent mapping.private ImmutableNode
rootNode
The root node.
-
Constructor Summary
Constructors Constructor Description TrackedNodeHandler(ImmutableNode root, NodeHandler<ImmutableNode> handler)
Creates a new instance ofTrackedNodeHandler
and initializes it with all required information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableNode
getParent(ImmutableNode node)
Gets the parent of the specified node.NodeHandler<ImmutableNode>
getParentHandler()
Gets the parent handler.ImmutableNode
getRootNode()
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 Detail
-
rootNode
private final ImmutableNode rootNode
The root node.
-
parentHandler
private final NodeHandler<ImmutableNode> parentHandler
The handler for querying the parent mapping.
-
-
Constructor Detail
-
TrackedNodeHandler
public TrackedNodeHandler(ImmutableNode root, NodeHandler<ImmutableNode> handler)
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 Detail
-
getParent
public ImmutableNode getParent(ImmutableNode node)
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
-
getParentHandler
public NodeHandler<ImmutableNode> getParentHandler()
Gets the parent handler. This is theNodeHandler
which is consulted for determining a node's parent node.- Returns:
- the parent
NodeHandler
-
getRootNode
public ImmutableNode getRootNode()
Gets the root node of the underlying hierarchy. This implementation returns the root node passed at construction time.- Returns:
- the current root node
-
-