/** * Adds an operation for changing the name of a target node. * * @param target the target node * @param newName the new name for this node */ public void addChangeNodeNameOperation(final ImmutableNode target, final String newName) { fetchOperations(target, LEVEL_UNKNOWN).addOperation( new ChangeNodeNameOperation(newName)); }
/** * Adds an operation for adding multiple attributes to a target node. * * @param target the target node * @param attributes the map with attributes to be set */ public void addAttributesOperation(final ImmutableNode target, final Map<String, Object> attributes) { fetchOperations(target, LEVEL_UNKNOWN).addOperation( new AddAttributesOperation(attributes)); }
/** * Adds an operation for changing the value of a target node. * * @param target the target node * @param newValue the new value for this node */ public void addChangeNodeValueOperation(final ImmutableNode target, final Object newValue) { fetchOperations(target, LEVEL_UNKNOWN).addOperation( new ChangeNodeValueOperation(newValue)); }
/** * Adds an operation for removing an attribute from a target node. * * @param target the target node * @param name the name of the attribute */ public void addRemoveAttributeOperation(final ImmutableNode target, final String name) { fetchOperations(target, LEVEL_UNKNOWN).addOperation( new RemoveAttributeOperation(name)); }
/** * Adds an operation for adding an attribute to a target node. * * @param target the target node * @param name the name of the attribute * @param value the value of the attribute */ public void addAttributeOperation(final ImmutableNode target, final String name, final Object value) { fetchOperations(target, LEVEL_UNKNOWN).addOperation( new AddAttributeOperation(name, value)); }
/** * Adds an operation for adding a new child to a given parent node. * * @param parent the parent node * @param newChild the new child to be added */ public void addAddNodeOperation(final ImmutableNode parent, final ImmutableNode newChild) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNewNode(newChild); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * Adds an operation for removing a child node of a given node. * * @param parent the parent node * @param node the child node to be removed */ public void addRemoveNodeOperation(final ImmutableNode parent, final ImmutableNode node) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNodeToRemove(node); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * Adds an operation for adding a number of new children to a given parent * node. * * @param parent the parent node * @param newNodes the collection of new child nodes */ public void addAddNodesOperation(final ImmutableNode parent, final Collection<? extends ImmutableNode> newNodes) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNewNodes(newNodes); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * 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. * * @param target the target node for this operation * @param node the resulting node after applying all operations * @param level the level of the target node */ private void propagateChange(final ImmutableNode target, final ImmutableNode node, final int level) { final ImmutableNode parent = getParent(target); final ChildrenUpdateOperation co = new ChildrenUpdateOperation(); if (InMemoryNodeModel.checkIfNodeDefined(node)) { co.addNodeToReplace(target, node); } else { co.addNodeToRemove(target); } fetchOperations(parent, level - 1).addChildrenOperation(co); }