Class ModelTransaction.Operations
- java.lang.Object
-
- org.apache.commons.configuration2.tree.ModelTransaction.Operations
-
- Enclosing class:
- ModelTransaction
private final class ModelTransaction.Operations extends java.lang.Object
A helper class which collects multiple update operations to be executed on a single node.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<ImmutableNode>
addedNodesInOperation
A collection with nodes added by an operation.private ModelTransaction.ChildrenUpdateOperation
childrenOperation
An operation for manipulating child nodes.private java.util.Collection<ModelTransaction.Operation>
operations
A collection for the other operations to be performed on the target node.
-
Constructor Summary
Constructors Modifier Constructor Description private
Operations()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChildrenOperation(ModelTransaction.ChildrenUpdateOperation co)
Adds an operation which manipulates children.void
addOperation(ModelTransaction.Operation op)
Adds an operation.void
apply(ImmutableNode target, int level)
Executes all operations stored in this object on the given target node.private void
handleAddedNodes(ImmutableNode node)
Checks whether new nodes have been added during operation execution.void
newNodesAdded(java.util.Collection<ImmutableNode> newNodes)
Notifies this object that new nodes have been added by a sub operation.private void
propagateChange(ImmutableNode target, ImmutableNode node, int level)
Propagates the changes on the target node to the next level above of the hierarchy.
-
-
-
Field Detail
-
childrenOperation
private ModelTransaction.ChildrenUpdateOperation childrenOperation
An operation for manipulating child nodes.
-
operations
private java.util.Collection<ModelTransaction.Operation> operations
A collection for the other operations to be performed on the target node.
-
addedNodesInOperation
private java.util.Collection<ImmutableNode> addedNodesInOperation
A collection with nodes added by an operation.
-
-
Method Detail
-
addChildrenOperation
public void addChildrenOperation(ModelTransaction.ChildrenUpdateOperation co)
Adds an operation which manipulates children.- Parameters:
co
- the operation
-
addOperation
public void addOperation(ModelTransaction.Operation op)
Adds an operation.- Parameters:
op
- the operation
-
apply
public void apply(ImmutableNode target, int level)
Executes all operations stored in this object on the given target node. The resulting node then has to be integrated in the current node hierarchy. Unless the root node is already reached, this causes another updated operation to be created which replaces the manipulated child in the parent node.- Parameters:
target
- the target node for this operationlevel
- the level of the target node
-
handleAddedNodes
private void handleAddedNodes(ImmutableNode node)
Checks whether new nodes have been added during operation execution. If so, the parent mapping has to be updated.- Parameters:
node
- the resulting node after applying all operations
-
newNodesAdded
public void newNodesAdded(java.util.Collection<ImmutableNode> newNodes)
Notifies this object that new nodes have been added by a sub operation. It has to be ensured that these nodes are added to the parent mapping.- Parameters:
newNodes
- the collection of newly added nodes
-
propagateChange
private void propagateChange(ImmutableNode target, ImmutableNode node, int level)
Propagates the changes on the target node to the next level above of the hierarchy. If the updated node is no longer defined, it can even be removed from its parent. Otherwise, it is just replaced.- Parameters:
target
- the target node for this operationnode
- the resulting node after applying all operationslevel
- the level of the target node
-
-