public abstract class NestableNode extends Node
Base abstract class for all nodes in a Thymeleaf DOM tree which have children.
Node.NodeLocalVariablesMap
NODE_PROPERTY_XML_ENCODING, NODE_PROPERTY_XML_STANDALONE, NODE_PROPERTY_XML_VERSION
Modifier and Type | Method and Description |
---|---|
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.
|
List<Node> |
getChildren()
Returns the children of this node.
|
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(List<Node> newChildren)
Sets the new children of the node to the specified list.
|
void |
setProcessCommentNodes(boolean processCommentNodes)
Sets the node flag that specifies whether the comment nodes contained inside this node (or this node itself,
if it is a Comment node) should be processed.
|
void |
setProcessTextNodes(boolean processTextNodes)
Sets the node flag that specifies whether the text nodes contained inside this node (or this node itself,
if it is a Text node) should be processed.
|
Node[] |
unsafeGetChildrenNodeArray()
Returns the real, unsafe, inner array of node children.
|
void |
visit(DOMVisitor visitor)
Apply a DOM visitor.
|
addAllNonExistingNodeLocalVariables, applyDialectPrefix, cloneNode, getDocumentName, getLineNumber, getNodeLocalVariableNames, getNodeProperty, getNodePropertyNames, getParent, getProcessCommentNodes, getProcessTextNodes, getRecomputeProcessorsAfterEachExecution, getRecomputeProcessorsImmediately, hasNodeLocalVariables, hasNodeProperty, hasParent, isProcessable, isSkippable, normalizeName, setAllNodeLocalVariables, setNodeLocalVariable, setNodeProperty, setParent, setProcessable, setRecomputeProcessorsAfterEachExecution, setRecomputeProcessorsImmediately, setSkippable, unsafeGetNodeProperties
public final boolean hasChildren()
Returns whether this node has any children.
public final int numChildren()
Returns the number of children in this node.
public final List<Node> getChildren()
Returns the children of this node. The returned list is immutable.
public final List<Element> getElementChildren()
Returns the only the Element
children
of this node, discarding children of any other types.
The returned list is immutable.
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.
public final Node getFirstChild()
Returns the first child of this node.
public final Element getFirstElementChild()
Returns the first child of type Element
.
public void addChild(Node newChild)
Adds a new child to the node.
newChild
- the new child to be added.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.
index
- the position to insert the new child into.newChild
- the new child.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.
existingChild
- the child we want to insert the new child just before.newChild
- the new child.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.
existingChild
- the child we want to insert the new child just after.newChild
- the new child.public final void setChildren(List<Node> newChildren)
Sets the new children of the node to the specified list.
newChildren
- the new chidren.public final void clearChildren()
Removes all the children nodes.
public final void removeChild(int index)
Removes a node child at a specific position.
index
- the position to be removed.public final void removeChild(Node child)
Removes a specific child node from this node.
child
- the child to be removed.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).
newParent
- the new parent.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.
child
- the child to be extracted.public void setProcessTextNodes(boolean processTextNodes)
Node
Sets the node flag that specifies whether the text nodes contained inside this node (or this node itself, if it is a Text node) should be processed.
Text nodes by default are not processed.
setProcessTextNodes
in class Node
processTextNodes
- the new value for the flag.public void setProcessCommentNodes(boolean processCommentNodes)
Node
Sets the node flag that specifies whether the comment nodes contained inside this node (or this node itself, if it is a Comment node) should be processed.
Comment nodes by default are not processed.
setProcessCommentNodes
in class Node
processCommentNodes
- the new value for the flag.public final void visit(DOMVisitor visitor)
Node
Apply a DOM visitor.
Copyright © 2017 The THYMELEAF team. All rights reserved.