public abstract class NestableAttributeHolderNode extends NestableNode
A specialization of NestableNode
that adds the ability to hold
attributes.
Node.NodeLocalVariablesMap
NODE_PROPERTY_XML_ENCODING, NODE_PROPERTY_XML_STANDALONE, NODE_PROPERTY_XML_VERSION
Modifier | Constructor and Description |
---|---|
protected |
NestableAttributeHolderNode(String documentName,
Integer lineNumber) |
Modifier and Type | Method and Description |
---|---|
void |
clearAttributes()
Clears all the attributes of the element.
|
Attribute |
getAttributeFromNormalizedName(String normalizedAttributeName)
Returns an attribute, if it exists (null if not).
|
Map<String,Attribute> |
getAttributeMap()
Returns a map with all the names (normalized) and values of the element attributes.
|
String |
getAttributeOriginalNameFromNormalizedName(String normalizedAttributeName)
Returns the original name of an attribute from its normalized name.
|
String |
getAttributeValue(String attributeName)
Returns the value of an attribute from its attribute name, without needing this name
to be normalized (because the specified name will be normalized before performing the
comparison).
|
String |
getAttributeValueFromNormalizedName(String normalizedAttributeName)
Returns the value of an attribute from its normalized name.
|
String |
getAttributeValueFromNormalizedName(String dialectPrefix,
String normalizedAttributeName)
Returns the value of an attribute from its normalized names, usually obtained by applying a prefix to a
unprefixed name.
|
boolean |
hasAttribute(String attributeName)
Returns whether an attribute exists in the element or not.
|
boolean |
hasAttributes()
Returns whether this element has any attributes or not.
|
boolean |
hasNormalizedAttribute(String normalizedAttributeName)
Returns whether an attribute exists in the element or not.
|
boolean |
hasNormalizedAttribute(String dialectPrefix,
String normalizedAttributeName)
Returns whether an attribute (by any of its names) exists in the element or not.
|
int |
numAttributes()
Returns the number of attributes contained in this element.
|
void |
removeAttribute(String attributeName)
Removes a specific attribute from the element.
|
void |
setAttribute(String name,
boolean onlyName,
String value)
Establishes a new value for an element attribute.
|
void |
setAttribute(String name,
boolean onlyName,
String value,
boolean valueIsEscaped)
Establishes a new value for an element attribute.
|
void |
setAttribute(String name,
String value)
Establishes a new value for an element attribute.
|
void |
setAttributes(Map<String,String> newAttributes)
Establishes the value for several attributes at a time.
|
String[] |
unsafeGetAttributeNormalizedNames()
Returns the inner array used for storing the normalized names of all the
existing attributes.
|
Attribute[] |
unsafeGetAttributes()
Returns the inner array used for storing the element attributes.
|
addChild, clearChildren, extractChild, getChildren, getElementChildren, getFirstChild, getFirstElementChild, hasChildren, insertAfter, insertBefore, insertChild, moveAllChildren, numChildren, removeChild, removeChild, setChildren, setProcessCommentNodes, setProcessTextNodes, unsafeGetChildrenNodeArray, visit
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 hasAttributes()
Returns whether this element has any attributes or not.
public final int numAttributes()
Returns the number of attributes contained in this element.
public final boolean hasAttribute(String attributeName)
Returns whether an attribute exists in the element or not. The specified name does not have to be normalized, because a normalization operation will be performed before comparing.
attributeName
- the name of the attribute to be checked.public final boolean hasNormalizedAttribute(String normalizedAttributeName)
Returns whether an attribute exists in the element or not. The specified name has to be already normalized because no normalization operations will be performed before comparing.
normalizedAttributeName
- the name of the attribute to be checked, already normalized.public final boolean hasNormalizedAttribute(String dialectPrefix, String normalizedAttributeName)
Returns whether an attribute (by any of its names) exists in the element or not. The specified names have to be already normalized because no normalization operations will be performed before comparing.
dialectPrefix
- the dialect prefix to be applied to the specified attribute. Can be null.normalizedAttributeName
- the names of the attribute to be checked, already normalized.public final Attribute getAttributeFromNormalizedName(String normalizedAttributeName)
Returns an attribute, if it exists (null if not). The specified name has to be already normalized because no normalization operations will be performed before comparing.
normalizedAttributeName
- the name of the attribute to retrieve.public final String[] unsafeGetAttributeNormalizedNames()
Returns the inner array used for storing the normalized names of all the existing attributes. This method is unsafe and for internal use, and should not be called directly. Modifications to this array could produce severe DOM inconsistencies.
public final Attribute[] unsafeGetAttributes()
Returns the inner array used for storing the element attributes. This method is unsafe and for internal use, and should not be called directly. Modifications to this array could produce severe DOM inconsistencies.
public final String getAttributeOriginalNameFromNormalizedName(String normalizedAttributeName)
Returns the original name of an attribute from its normalized name.
normalizedAttributeName
- the normalized name of the attribute.public final String getAttributeValueFromNormalizedName(String normalizedAttributeName)
Returns the value of an attribute from its normalized name.
normalizedAttributeName
- the normalized name of the attribute.public final String getAttributeValueFromNormalizedName(String dialectPrefix, String normalizedAttributeName)
Returns the value of an attribute from its normalized names, usually obtained by applying a prefix to a unprefixed name.
dialectPrefix
- the dialect prefix to be applied to the specified attribute. Can be null.normalizedAttributeName
- the normalized name of the attribute.public final String getAttributeValue(String attributeName)
Returns the value of an attribute from its attribute name, without needing this name to be normalized (because the specified name will be normalized before performing the comparison).
attributeName
- the attribute name.public final Map<String,Attribute> getAttributeMap()
Returns a map with all the names (normalized) and values of the element attributes.
The map object returned by this method is a new instance, created ad-hoc with each method call.
public final void setAttribute(String name, String value)
Establishes a new value for an element attribute. If the attribute already exists, its value is substituted by the one specified.
name
- the name of the attribute.value
- the value of the attribute.public final void setAttribute(String name, boolean onlyName, String value)
Establishes a new value for an element attribute. If the attribute already exists, its value is substituted by the one specified.
name
- the name of the attribute.onlyName
- whether this attribute has a value or not (is only a name).value
- the value of the attribute.public final void setAttribute(String name, boolean onlyName, String value, boolean valueIsEscaped)
Establishes a new value for an element attribute. If the attribute already exists, its value is substituted by the one specified.
name
- the name of the attribute.onlyName
- whether this attribute has a value or not (is only a name).value
- the value of the attribute.valueIsEscaped
- whether the value being set for the attribute is already escaped (e.g. direct from template
parsing) or not.public final void setAttributes(Map<String,String> newAttributes)
Establishes the value for several attributes at a time. If any of the specified attributes already exists, their values will be substituted by the one specified in the parameter map.
newAttributes
- the new attributes to be established.public final void clearAttributes()
Clears all the attributes of the element.
public final void removeAttribute(String attributeName)
Removes a specific attribute from the element. The specified name does not have to be normalized (it will be normalized before performing the removal operation).
attributeName
- the name of tha attribute to remove (does not have to be
normalized).Copyright © 2016 The THYMELEAF team. All rights reserved.