Class NodeTracker.TrackedNodeData
java.lang.Object
org.apache.commons.configuration2.tree.NodeTracker.TrackedNodeData
- Enclosing class:
NodeTracker
A simple data class holding information about a tracked node.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InMemoryNodeModel
A node model to be used when the tracked node is detached.private final ImmutableNode
The current instance of the tracked node.private final int
The number of observers of this tracked node. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new instance ofTrackedNodeData
and initializes it with the current reference to the tracked node.private
TrackedNodeData
(ImmutableNode nd, int obsCount, InMemoryNodeModel detachedNodeModel) Creates a new instance ofTrackedNodeData
and initializes its properties. -
Method Summary
Modifier and TypeMethodDescriptiondetach
(ImmutableNode newNode) Returns an instance with the detached flag set to true.Gets the node model to be used in detached mode.getNode()
Gets the tracked node.boolean
Returns a flag whether the represented tracked node is detached.Another observer was added for this tracked node.An observer for this tracked node was removed.updateNode
(ImmutableNode newNode) Updates the node reference.
-
Field Details
-
node
The current instance of the tracked node. -
observerCount
private final int observerCountThe number of observers of this tracked node. -
detachedModel
A node model to be used when the tracked node is detached.
-
-
Constructor Details
-
TrackedNodeData
Creates a new instance ofTrackedNodeData
and initializes it with the current reference to the tracked node.- Parameters:
nd
- the tracked node
-
TrackedNodeData
Creates a new instance ofTrackedNodeData
and initializes its properties.- Parameters:
nd
- the tracked nodeobsCount
- the observer countdetachedNodeModel
- a model to be used in detached mode
-
-
Method Details
-
detach
Returns an instance with the detached flag set to true. This method is called if the selector of a tracked node does not match a single node any more. It is possible to pass in a new node instance which becomes the current tracked node. If this is null, the previous node instance is used.- Parameters:
newNode
- the new tracked node instance (may be null)- Returns:
- the updated instance
-
getDetachedModel
Gets the node model to be used in detached mode. This is null if the represented tracked node is not detached.- Returns:
- the node model in detached mode
-
getNode
Gets the tracked node.- Returns:
- the tracked node
-
isDetached
public boolean isDetached()Returns a flag whether the represented tracked node is detached.- Returns:
- the detached flag
-
observerAdded
Another observer was added for this tracked node. This method returns a new instance with an adjusted observer count.- Returns:
- the updated instance
-
observerRemoved
An observer for this tracked node was removed. This method returns a new instance with an adjusted observer count. If there are no more observers, result is null. This means that this node is no longer tracked and can be released.- Returns:
- the updated instance or null
-
updateNode
Updates the node reference. This method is called after an update of the underlying node structure if the tracked node was replaced by another instance.- Parameters:
newNode
- the new tracked node instance- Returns:
- the updated instance
-