/** * Creates a new Node named <code>name</code> with value <code>value</code> and * with attributes specified in the <code>attributes</code> Map. If a parent is supplied, * the newly created node is added as a child of the parent. * * @param parent the parent node or null if no parent * @param name the name of the node * @param attributes a Map of name-value pairs * @param value the Node value, e.g. some text but in general any Object */ public Node(Node parent, Object name, Map attributes, Object value) { this.parent = parent; this.name = name; this.attributes = attributes; this.value = value; if (parent != null) { getParentList(parent).add(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); }
/** * 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; }
public boolean append(Node child) { child.parent = this; return getParentList(this).add(child); }
public Node(Node parent, Object name, Map attributes, Object value) { this.parent = parent; this.name = name; this.attributes = attributes; this.value = value; if (parent != null) { getParentList(parent).add(this); } }
public Node(Node parent, Object name, Map attributes, Object value) { this.parent = parent; this.name = name; this.attributes = attributes; this.value = value; if (parent != null) { getParentList(parent).add(this); } }
public boolean remove(Node child) { child.parent = null; return getParentList(this).remove(child); }
public Node(Node parent, Object name, Map attributes, Object value) { this.parent = parent; this.name = name; this.attributes = attributes; this.value = value; if (parent != null) { getParentList(parent).add(this); } }
public boolean append(Node child) { child.parent = this; return getParentList(this).add(child); }
public boolean remove(Node child) { child.parent = null; return getParentList(this).remove(child); }
public boolean append(Node child) { child.parent = this; return getParentList(this).add(child); }
public boolean remove(Node child) { child.parent = null; return getParentList(this).remove(child); }
/** * Creates a new Node named <code>name</code> with value <code>value</code> and * with attributes specified in the <code>attributes</code> Map. If a parent is supplied, * the newly created node is added as a child of the parent. * * @param parent the parent node or null if no parent * @param name the name of the node * @param attributes a Map of name-value pairs * @param value the Node value, e.g. some text but in general any Object */ public Node(Node parent, Object name, Map attributes, Object value) { this.parent = parent; this.name = name; this.attributes = attributes; this.value = value; if (parent != null) { getParentList(parent).add(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); }
/** * 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 last appended node */ public Node replaceNode(Closure c) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } Node result = appendNodes(c); getParentList(parent()).remove(this); // this.setParent(null); // return this; return result; }