/** * 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 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)); }
/** * Extracts the value from a query result. * * @param result the {@code QueryResult} * @param handler the {@code NodeHandler} * @return the value of this result (may be <b>null</b>) */ private Object valueFromResult(final QueryResult<T> result, final NodeHandler<T> handler) { return result.isAttributeResult() ? result.getAttributeValue(handler) : handler.getValue(result.getNode()); }
/** * {@inheritDoc} This implementation returns the tracked node instance * acting as root node of this model. */ @Override public ImmutableNode getInMemoryRepresentation() { return getNodeHandler().getRootNode(); }
@Override public T getRootNode() { return getDecoratedNodeHandler().getRootNode(); }
/** * 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 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 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)); }
@Override public boolean initTransaction(final ModelTransaction tx) { final List<QueryResult<ImmutableNode>> results = resolver.resolveKey(tx.getQueryRoot(), key, tx.getCurrentData()); return initializeClearTransaction(tx, results); } }, selector, resolver);
@Override public void addProperty(final String key, final Iterable<?> values, final NodeKeyResolver<ImmutableNode> resolver) { getParentModel().addProperty(key, getSelector(), values, resolver); }
@Override public void addNodes(final String key, final Collection<? extends ImmutableNode> nodes, final NodeKeyResolver<ImmutableNode> resolver) { getParentModel().addNodes(key, getSelector(), nodes, resolver); }
/** * Returns a flag whether the specified tracked node is detached. * * @param selector the {@code NodeSelector} * @return a flag whether this node is detached * @throws ConfigurationRuntimeException if no data for this selector is * available */ public boolean isTrackedNodeDetached(final NodeSelector selector) { return getTrackedNodeData(selector).isDetached(); }
@Override public List<T> getChildren(final T node) { return getDecoratedNodeHandler().getChildren(node); }
@Override public int getChildrenCount(final T node, final String name) { return getDecoratedNodeHandler().getChildrenCount(node, name); }
/** * {@inheritDoc} This implementation delegates to the handler with the * parent mapping. */ @Override public ImmutableNode getParent(final ImmutableNode node) { return getParentHandler().getParent(node); }
@Override public Object getValue(final T node) { return getDecoratedNodeHandler().getValue(node); }
@Override public T getChild(final T node, final int index) { return getDecoratedNodeHandler().getChild(node, index); }
@Override public int indexOfChild(final T parent, final T child) { return getDecoratedNodeHandler().indexOfChild(parent, child); }
@Override public Object getAttributeValue(final T node, final String name) { return getDecoratedNodeHandler().getAttributeValue(node, name); }