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 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 Details

  • Constructor Details

    • TrackedNodeHandler

      public TrackedNodeHandler(ImmutableNode root, NodeHandler<ImmutableNode> handler)
      Creates a new instance of TrackedNodeHandler and initializes it with all required information.
      Parameters:
      root - the root node of the represented hierarchy
      handler - an underlying handler for delegation
  • Method Details

    • 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 the NodeHandler 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