org.thymeleaf.dom
Class NestableNode

Object
  extended by org.thymeleaf.dom.Node
      extended by org.thymeleaf.dom.NestableNode
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Document, Element

public abstract class NestableNode
extends Node

Base abstract class for all nodes in a Thymeleaf DOM tree which have children.

Since:
2.0.0
Author:
Daniel Fernández
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.thymeleaf.dom.Node
NODE_PROPERTY_XML_ENCODING, NODE_PROPERTY_XML_STANDALONE, NODE_PROPERTY_XML_VERSION
 
Method Summary
 void addChild(Node newChild)
           Adds a new child to the node.
 void clearChildren()
           Removes all the children nodes.
 void extractChild(Node child)
           Extracts a child by removing it from the DOM tree and lifting all of its children one level, so that they become children nodes of this node.
 java.util.List<Node> getChildren()
           Returns the children of this node.
 java.util.List<Element> getElementChildren()
           Returns the only the Element children of this node, discarding children of any other types.
 Node getFirstChild()
           Returns the first child of this node.
 Element getFirstElementChild()
           Returns the first child of type Element.
 boolean hasChildren()
           Returns whether this node has any children.
 void insertAfter(Node existingChild, Node newChild)
           Adds a new children to the node, positioned just after another child node that is also specified.
 void insertBefore(Node existingChild, Node newChild)
           Adds a new children to the node, positioned just before another child node that is also specified.
 void insertChild(int index, Node newChild)
           Adds a new child to the node, at a specific position.
 void moveAllChildren(NestableNode newParent)
           Refactors a DOM tree by moving all the children of this node to another (which will be their new parent node).
 int numChildren()
           Returns the number of children in this node.
 void removeChild(int index)
           Removes a node child at a specific position.
 void removeChild(Node child)
           Removes a specific child node from this node.
 void setChildren(java.util.List<Node> newChildren)
           Sets the new children of the node to the specified list.
 Node[] unsafeGetChildrenNodeArray()
           Returns the real, unsafe, inner array of node children.
 void visit(DOMVisitor visitor)
           Apply a DOM visitor.
 
Methods inherited from class org.thymeleaf.dom.Node
applyDialectPrefix, cloneNode, getDocumentName, getLineNumber, getNodeLocalVariableNames, getNodeProperty, getNodePropertyNames, getParent, getRecomputeProcessorsAfterEachExecution, getRecomputeProcessorsImmediately, hasNodeLocalVariables, hasNodeProperty, hasParent, isSkippable, normalizeName, setAllNodeLocalVariables, setNodeLocalVariable, setNodeProperty, setParent, setRecomputeProcessorsAfterEachExecution, setRecomputeProcessorsImmediately, setSkippable, unsafeGetNodeLocalVariables, unsafeGetNodeProperties
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasChildren

public final boolean hasChildren()

Returns whether this node has any children.

Returns:
true if the node as any children, false if not.

numChildren

public final int numChildren()

Returns the number of children in this node.

Returns:
the number of children.

getChildren

public final java.util.List<Node> getChildren()

Returns the children of this node. The returned list is immutable.

Returns:
the list of children.

getElementChildren

public final java.util.List<Element> getElementChildren()

Returns the only the Element children of this node, discarding children of any other types. The returned list is immutable.

Returns:
the list of Element children.

unsafeGetChildrenNodeArray

public final Node[] unsafeGetChildrenNodeArray()

Returns the real, unsafe, inner array of node children. DO NOT use this method directly. Modifying this array could result in severe DOM corruption.

Returns:
the array of node children.

getFirstChild

public final Node getFirstChild()

Returns the first child of this node.

Returns:
the first child.

getFirstElementChild

public final Element getFirstElementChild()

Returns the first child of type Element.

Returns:
the first Element child.

addChild

public void addChild(Node newChild)

Adds a new child to the node.

Parameters:
newChild - the new child to be added.

insertChild

public final void insertChild(int index,
                              Node newChild)

Adds a new child to the node, at a specific position.

All children nodes from that position are moved one position forward in order to make room for the new child.

Parameters:
index - the position to insert the new child into.
newChild - the new child.

insertBefore

public final void insertBefore(Node existingChild,
                               Node newChild)

Adds a new children to the node, positioned just before another child node that is also specified.

This method is effectively equivalent to first searching the existing child and then executing insertChild(int, Node) specifying its position.

Parameters:
existingChild - the child we want to insert the new child just before.
newChild - the new child.

insertAfter

public final void insertAfter(Node existingChild,
                              Node newChild)

Adds a new children to the node, positioned just after another child node that is also specified.

This method is effectively equivalent to first searching the existing child and then executing insertChild(int, Node) specifying its position + 1.

Parameters:
existingChild - the child we want to insert the new child just after.
newChild - the new child.

setChildren

public final void setChildren(java.util.List<Node> newChildren)

Sets the new children of the node to the specified list.

Parameters:
newChildren - the new chidren.

clearChildren

public final void clearChildren()

Removes all the children nodes.


removeChild

public final void removeChild(int index)

Removes a node child at a specific position.

Parameters:
index - the position to be removed.

removeChild

public final void removeChild(Node child)

Removes a specific child node from this node.

Parameters:
child - the child to be removed.

moveAllChildren

public final void moveAllChildren(NestableNode newParent)

Refactors a DOM tree by moving all the children of this node to another (which will be their new parent node).

Parameters:
newParent - the new parent.

extractChild

public final void extractChild(Node child)

Extracts a child by removing it from the DOM tree and lifting all of its children one level, so that they become children nodes of this node.

Node local variables, because of their hierarchical nature, are handled accordingly.

Parameters:
child - the child to be extracted.

visit

public final void visit(DOMVisitor visitor)
Description copied from class: Node

Apply a DOM visitor.

Specified by:
visit in class Node
Parameters:
visitor - the visitor to be executed for this node.


Copyright © 2012 The THYMELEAF team. All Rights Reserved.