/** * Appends a child to the current node. * * @param child the child to append * @return <code>true</code> */ public boolean append(Node child) { child.setParent(this); return getParentList(this).add(child); }
/** * Removes a child of the current node. * * @param child the child to remove * @return <code>true</code> if the param was a child of the current node */ public boolean remove(Node child) { child.setParent(null); return getParentList(this).remove(child); }
/** * Replaces the current node with nodes defined using builder-style notation via a Closure. * * @param c A Closure defining the new nodes using builder-style notation. * @return the original now replaced node */ public Node replaceNode(Closure c) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } appendNodes(c); getParentList(parent()).remove(this); this.setParent(null); return this; }
/** * Replaces the current node with the supplied node. * * @param n the new Node * @return the original now replaced node */ public Node replaceNode(Node n) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } List tail = getTail(); parent().appendNode(n.name(), n.attributes(), n.value()); parent().children().addAll(tail); getParentList(parent()).remove(this); this.setParent(null); return this; }
/** * Appends a child to the current node. * * @param child the child to append * @return <code>true</code> */ public boolean append(Node child) { child.setParent(this); return getParentList(this).add(child); }
/** * Removes a child of the current node. * * @param child the child to remove * @return <code>true</code> if the param was a child of the current node */ public boolean remove(Node child) { child.setParent(null); return getParentList(this).remove(child); }