|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.thymeleaf.dom.Node
public abstract class Node
Base abstract class for all nodes in a Thymeleaf DOM tree.
Nested Class Summary | |
---|---|
static class |
Node.NodeLocalVariablesMap
|
Field Summary | |
---|---|
static String |
NODE_PROPERTY_XML_ENCODING
Name of the property set by XML-based parsers into Document nodes
for specifying the "XML Encoding" info from the XML Declaration. |
static String |
NODE_PROPERTY_XML_STANDALONE
Name of the property set by XML-based parsers into Document nodes
for specifying the "XML Standalone" flag from the XML Declaration. |
static String |
NODE_PROPERTY_XML_VERSION
Name of the property set by XML-based parsers into Document nodes
for specifying the "XML Version" info from the XML Declaration. |
Method Summary | |
---|---|
static String |
applyDialectPrefix(String name,
String dialectPrefix)
Deprecated. Deprecated in 2.1.0. Use Attribute.applyPrefixToAttributeName(String, String) or
Element.applyPrefixToElementName(String, String) instead. |
Node |
cloneNode(NestableNode newParent,
boolean cloneProcessors)
Creates a clone of this node. |
String |
getDocumentName()
Returns the name of the document this node comes from. |
Integer |
getLineNumber()
Returns the number of the line where this node appears in the original template document. |
java.util.Set<String> |
getNodeLocalVariableNames()
Returns the set of node local variable names. |
Object |
getNodeProperty(String name)
Returns the value of a specific node property, or null if the property has not been set. |
java.util.Set<String> |
getNodePropertyNames()
Returns the names of all the currently set node properties. |
NestableNode |
getParent()
Returns the parent of a node. |
boolean |
getProcessCommentNodes()
Returns the value of 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. |
boolean |
getProcessTextNodes()
Returns the value of 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. |
boolean |
getRecomputeProcessorsAfterEachExecution()
Returns the value of a flag indicating whether the list of processors to be applied to this node should be recomputed after the execution of each processor. |
boolean |
getRecomputeProcessorsImmediately()
Returns the value of a flag indicating whether the processors to be applied to this node should be recomputed once after the execution of the current processor ends. |
boolean |
hasNodeLocalVariables()
Returns whether the node has any node local variables set or not. |
boolean |
hasNodeProperty(String name)
Returns whether a node contains a specific node property or not. |
boolean |
hasParent()
Returns whether this node has a parent node or not. |
boolean |
isProcessable()
Returns the value of a flag indicating whether this node (and its children) should be processed. |
boolean |
isSkippable()
Returns the value of a flag indicating whether there is any reason to process this node (and its children). |
static String |
normalizeName(String name)
Deprecated. Deprecated in 2.1.0. Use Attribute.normalizeAttributeName(String) or
Element.normalizeElementName(String) instead. |
void |
setAllNodeLocalVariables(java.util.Map<String,Object> variables)
Sets several node local variables at once. |
void |
setNodeLocalVariable(String name,
Object value)
Sets a new node local variable. |
void |
setNodeProperty(String name,
Object value)
Sets a value for a node property. |
void |
setParent(NestableNode parent)
Sets a new parent for the node. |
void |
setProcessable(boolean processable)
Sets the value of a flag indicating whether this node (and its children) should be processed. |
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. |
void |
setRecomputeProcessorsAfterEachExecution(boolean recomputeProcessorsAfterEachExecution)
Sets the value of a flag indicating whether the processors to be applied to this node should be recomputed after the execution of each processor. |
void |
setRecomputeProcessorsImmediately(boolean recomputeProcessorsImmediately)
Sets the value of a flag indicating whether the processors to be applied to this node should be recomputed once after the execution of the current processor ends. |
protected void |
setSkippable(boolean isSkippable)
|
java.util.Map<String,Object> |
unsafeGetNodeProperties()
Returns the real inner map object containing the node properties. |
abstract void |
visit(DOMVisitor visitor)
Apply a DOM visitor. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NODE_PROPERTY_XML_ENCODING
Name of the property set by XML-based parsers into Document
nodes
for specifying the "XML Encoding" info from the XML Declaration.
Value: "XML_ENCODING"
public static final String NODE_PROPERTY_XML_VERSION
Name of the property set by XML-based parsers into Document
nodes
for specifying the "XML Version" info from the XML Declaration.
Value: "XML_VERSION"
public static final String NODE_PROPERTY_XML_STANDALONE
Name of the property set by XML-based parsers into Document
nodes
for specifying the "XML Standalone" flag from the XML Declaration.
Value: "XML_STANDALONE"
Method Detail |
---|
@Deprecated public static String normalizeName(String name)
Attribute.normalizeAttributeName(String)
or
Element.normalizeElementName(String)
instead.
Normalizes an element or attribute name by converting it to lower-case. Elements and attributes are processed as case-insensitive, and this method allows normalizing their names before processing.
name
- the name to be normalized.
@Deprecated public static String applyDialectPrefix(String name, String dialectPrefix)
Attribute.applyPrefixToAttributeName(String, String)
or
Element.applyPrefixToElementName(String, String)
instead.
Applies a prefix (a dialect prefix) to the specified name.
The result looks like: "${prefix}:${name}".
name
- the name to be prefixeddialectPrefix
- the prefix to be applied
public String getDocumentName()
Returns the name of the document this node comes from. Can be null, if node does not come from parsing a document (for example, could come from parsing an externalized message).
public Integer getLineNumber()
Returns the number of the line where this node appears in the original template document. Might be null if the parser used to create the node is not able to obtain this information for nodes, or if this kind of information does not apply (for example, when parsing externalized messages).
public final void setNodeProperty(String name, Object value)
Sets a value for a node property.
Node properties might contain arbitrary information, normally set by parsers into node objects for use from processors.
Users might need to create parsers that add specific properties to some nodes in order to give processing hints to their processors or result writers.
name
- the name of the propertyvalue
- the value of the propertypublic final boolean hasNodeProperty(String name)
Returns whether a node contains a specific node property or not.
Node properties might contain arbitrary information, normally set by parsers into node objects for use from processors.
Users might need to create parsers that add specific properties to some nodes in order to give processing hints to their processors or result writers.
name
- the name of the property to check
public final Object getNodeProperty(String name)
Returns the value of a specific node property, or null if the property has not been set.
Node properties might contain arbitrary information, normally set by parsers into node objects for use from processors.
Users might need to create parsers that add specific properties to some nodes in order to give processing hints to their processors or result writers.
name
- the name of the property to be retrieved
public final java.util.Set<String> getNodePropertyNames()
Returns the names of all the currently set node properties.
Node properties might contain arbitrary information, normally set by parsers into node objects for use from processors.
Users might need to create parsers that add specific properties to some nodes in order to give processing hints to their processors or result writers.
public final java.util.Map<String,Object> unsafeGetNodeProperties()
Returns the real inner map object containing the node properties. This method is only meant for internal use. DO NOT call this method directly from your code.
public final boolean getProcessTextNodes()
Returns the value of 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.
public 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.
Text nodes by default are not processed.
processTextNodes
- the new value for the flag.public final boolean getProcessCommentNodes()
Returns the value of 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.
public 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.
Comment nodes by default are not processed.
processCommentNodes
- the new value for the flag.public final boolean hasParent()
Returns whether this node has a parent node or not.
A node does not have a parent if its parent property
is set to null. Document
nodes always have no parent, and
other types of node might also have null parent if they represent
the root of a DOM subtree.
public final NestableNode getParent()
Returns the parent of a node. Will return null if this node has no parent.
public final void setParent(NestableNode parent)
Sets a new parent for the node.
parent
- the new parent.public final boolean getRecomputeProcessorsAfterEachExecution()
Returns the value of a flag indicating whether the list of processors to be applied to this node should be recomputed after the execution of each processor.
This flag is usually set by processors with very high precedence in order to signal the fact that they would like the engine to recompute the list of processors to be applied to the node after each of the subsequent processors finish their execution.
public final void setRecomputeProcessorsAfterEachExecution(boolean recomputeProcessorsAfterEachExecution)
Sets the value of a flag indicating whether the processors to be applied to this node should be recomputed after the execution of each processor.
This flag is usually set by processors with very high precedence in order to signal the fact that they would like the engine to recompute the list of processors to be applied to the node after each of the subsequent processors finish their execution.
recomputeProcessorsAfterEachExecution
- the new value for the flagpublic final boolean getRecomputeProcessorsImmediately()
Returns the value of a flag indicating whether the processors to be applied to this node should be recomputed once after the execution of the current processor ends.
This flag is usually set by processors in order to signal the fact that they have modified the node in a way that should modify the list of processors to be applied to it (for example, by adding an attribute which might have a processor associated).
If this flag is set to true, the engine will automatically recompute the applicable processors before looking for the next processor to execute.
public final void setRecomputeProcessorsImmediately(boolean recomputeProcessorsImmediately)
Sets the value of a flag indicating whether the processors to be applied to this node should be recomputed once after the execution of the current processor ends.
This flag is usually set by processors in order to signal the fact that they have modified the node in a way that should modify the list of processors to be applied to it (for example, by adding an attribute which might have a processor associated).
If this flag is set to true, the engine will automatically recompute the applicable processors before looking for the next processor to execute.
recomputeProcessorsImmediately
- the new value for the flagpublic final boolean isSkippable()
Returns the value of a flag indicating whether there is any reason to process this node (and its children).
This flag can be set by the engine -not by processors- in order to avoid the execution of certain parts of the DOM tree because it is known that there is nothing to execute (and therefore it would be a waste of time trying to process it).
protected final void setSkippable(boolean isSkippable)
public final boolean isProcessable()
Returns the value of a flag indicating whether this node (and its children) should be processed. It differs from skippable in that processing a skippable node simply means not taking profit from a performance advantage, whereas processing a non-processable node is completely forbidden.
This flag can be set by processors in order to avoid the execution of certain parts of the DOM tree, because we want to signal that specific parts of the tree should not be executed for security reasons (for example, to avoid code injection).
public final void setProcessable(boolean processable)
Sets the value of a flag indicating whether this node (and its children) should be processed. It differs from skippable in that processing a skippable node simply means not taking profit from a performance advantage, whereas processing a non-processable node is completely forbidden.
This flag can be set by processors in order to avoid the execution of certain parts of the DOM tree, because we want to signal that specific parts of the tree should not be executed for security reasons (for example, to avoid code injection).
processable
- the new value for the flagpublic final boolean hasNodeLocalVariables()
Returns whether the node has any node local variables set or not.
Node local variables are variables that are set locally to a specific node, and that will be added to the evaluation context of any expressions --for example: OGNL or Spring EL-- executed on that node or any of its children.
For example, the thing variable in <div th:each="thing : ${things}">...<div> is a node local variable that will only exist inside the <div> element and that will be made available to any expressions executed within those limits.
Note that there is an important difference between node local variables and node properties, as the latter are never added to the expression evaluation context and are only meant for internally carrying around metainformation about the DOM nodes.
public final java.util.Set<String> getNodeLocalVariableNames()
Returns the set of node local variable names.
Node local variables are variables that are set locally to a specific node, and that will be added to the evaluation context of any expressions --for example: OGNL or Spring EL-- executed on that node or any of its children.
For example, the thing variable in <div th:each="thing : ${things}">...<div> is a node local variable that will only exist inside the <div> element and that will be made available to any expressions executed within those limits.
Note that there is an important difference between node local variables and node properties, as the latter are never added to the expression evaluation context and are only meant for internally carrying around metainformation about the DOM nodes.
public final void setNodeLocalVariable(String name, Object value)
Sets a new node local variable.
Node local variables are variables that are set locally to a specific node, and that will be added to the evaluation context of any expressions --for example: OGNL or Spring EL-- executed on that node or any of its children.
For example, the thing variable in <div th:each="thing : ${things}">...<div> is a node local variable that will only exist inside the <div> element and that will be made available to any expressions executed within those limits.
Note that there is an important difference between node local variables and node properties, as the latter are never added to the expression evaluation context and are only meant for internally carrying around metainformation about the DOM nodes.
name
- the name of the local variablevalue
- the new value for the local variablepublic final void setAllNodeLocalVariables(java.util.Map<String,Object> variables)
Sets several node local variables at once.
Node local variables are variables that are set locally to a specific node, and that will be added to the evaluation context of any expressions --for example: OGNL or Spring EL-- executed on that node or any of its children.
For example, the thing variable in <div th:each="thing : ${things}">...<div> is a node local variable that will only exist inside the <div> element and that will be made available to any expressions executed within those limits.
Note that there is an important difference between node local variables and node properties, as the latter are never added to the expression evaluation context and are only meant for internally carrying around metainformation about the DOM nodes.
variables
- the variables to be setpublic final Node cloneNode(NestableNode newParent, boolean cloneProcessors)
Creates a clone of this node.
When cloning, it can be specified whether we want to clone also the available preprocessing information (the lists of processors that should be applicable to each node), and also the new parent to be assigned to the DOM tree resulting from cloning (parent can be null).
Node cloning is always performed in depth.
newParent
- the new parent node of the resulting cloned DOM tree, if any (can be specified
as null).cloneProcessors
- whether the lists of applicable processors for each node should
also be cloned or not.
public abstract void visit(DOMVisitor visitor)
Apply a DOM visitor.
visitor
- the visitor to be executed for this node.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |