Class NodeTracker.TrackedNodeData
- java.lang.Object
-
- org.apache.commons.configuration2.tree.NodeTracker.TrackedNodeData
-
- Enclosing class:
- NodeTracker
private static final class NodeTracker.TrackedNodeData extends java.lang.Object
A simple data class holding information about a tracked node.
-
-
Field Summary
Fields Modifier and Type Field Description private InMemoryNodeModel
detachedModel
A node model to be used when the tracked node is detached.private ImmutableNode
node
The current instance of the tracked node.private int
observerCount
The number of observers of this tracked node.
-
Constructor Summary
Constructors Modifier Constructor Description TrackedNodeData(ImmutableNode nd)
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeTracker.TrackedNodeData
detach(ImmutableNode newNode)
Returns an instance with the detached flag set to true.InMemoryNodeModel
getDetachedModel()
Gets the node model to be used in detached mode.ImmutableNode
getNode()
Gets the tracked node.boolean
isDetached()
Returns a flag whether the represented tracked node is detached.NodeTracker.TrackedNodeData
observerAdded()
Another observer was added for this tracked node.NodeTracker.TrackedNodeData
observerRemoved()
An observer for this tracked node was removed.NodeTracker.TrackedNodeData
updateNode(ImmutableNode newNode)
Updates the node reference.
-
-
-
Field Detail
-
node
private final ImmutableNode node
The current instance of the tracked node.
-
observerCount
private final int observerCount
The number of observers of this tracked node.
-
detachedModel
private final InMemoryNodeModel detachedModel
A node model to be used when the tracked node is detached.
-
-
Constructor Detail
-
TrackedNodeData
public TrackedNodeData(ImmutableNode nd)
Creates a new instance ofTrackedNodeData
and initializes it with the current reference to the tracked node.- Parameters:
nd
- the tracked node
-
TrackedNodeData
private TrackedNodeData(ImmutableNode nd, int obsCount, InMemoryNodeModel detachedNodeModel)
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 Detail
-
detach
public NodeTracker.TrackedNodeData detach(ImmutableNode newNode)
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
public InMemoryNodeModel 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
public ImmutableNode 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
public NodeTracker.TrackedNodeData 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
public NodeTracker.TrackedNodeData 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
public NodeTracker.TrackedNodeData updateNode(ImmutableNode newNode)
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
-
-