public final class Attribute extends Object implements Serializable
Models an element attribute.
Constructor and Description |
---|
Attribute(String name,
boolean onlyName,
String value) |
Attribute(String name,
boolean onlyName,
String value,
boolean valueIsEscaped) |
Modifier and Type | Method and Description |
---|---|
static String[] |
applyPrefixToAttributeName(String name,
String dialectPrefix)
Applies a prefix (a dialect prefix) to the specified name in order to obtain a complete
valid attribute name.
|
String |
getEscapedValue()
Returns the escaped value of the attribute.
|
String |
getNormalizedName()
Returns the normalized name of the attribute.
|
String |
getNormalizedPrefix()
Deprecated.
Deprecated in 2.1.0. There is no actual usage of this method
|
String |
getOriginalName()
Returns the original name of the attribute.
|
String |
getOriginalValue()
Returns the original value (escaped or not) of the attribute.
|
static String |
getPrefixFromAttributeName(String attributeName)
Returns the prefix being applied to an attribute.
|
static String |
getUnprefixedAttributeName(String attributeName)
Returns the equivalent, un-prefixed name of an attribute from its complete (prefixed, if applies) version.
|
String |
getUnprefixedNormalizedName()
Deprecated.
Deprecated in 2.1.0. There is no actual usage of this method
|
String |
getValue()
Returns the value of the attribute.
|
String |
getXmlnsPrefix()
Deprecated.
Deprecated in 2.1.0. The only usage of this method is at the moment of writing the template. No
need to be always pre-computed.
|
boolean |
hasPrefix()
Deprecated.
Deprecated in 2.1.0. There is no actual usage of this method
|
boolean |
isOnlyName()
Determines whether this attribute is to be specified only by its
name (no equals sign, no value).
|
boolean |
isXmlnsAttribute()
Deprecated.
Deprecated in 2.1.0. The only usage of this method is at the moment of writing the template. No
need to be always pre-computed.
|
static String |
normalizeAttributeName(String name)
Normalizes an attribute name by converting it
to lower-case.
|
public String getOriginalName()
Returns the original name of the attribute. Given the fact that the engine works using the normalized versions of attribute names (in order to be case-insensitive), it is necessary to make a distinction between the 'original' name of an attribute (as it is written in the template file) and its 'normalized' name.
If the attribute name has a prefix, this 'original name' includes such prefix.
public String getNormalizedName()
Returns the normalized name of the attribute. Attribute names are normalized by
means of the normalizeAttributeName(String)
method so that the engine
can work in a case-insensitive way.
If the attribute name has a prefix, this 'normalized name' includes such prefix.
@Deprecated public String getNormalizedPrefix()
Returns the normalized prefix of this attribute (part of its name), if it exists, or null if the element is unprefixed.
Prefixes are normalized in the same way as attribute names.
@Deprecated public String getUnprefixedNormalizedName()
Returns the normalized version of the attribute name, without its prefix (if it has one).
@Deprecated public boolean hasPrefix()
Returns whether the attribute name has a prefix or not.
public boolean isOnlyName()
Determines whether this attribute is to be specified only by its name (no equals sign, no value).
If this is true, but getValue()
is not null, this flag is
ignored.
Parsers and/or template writers are not required to honor this flag, and they can choose to render attributes with their values always even if these are empty and/or null and this flag is set.
public String getValue()
Returns the value of the attribute.
public String getEscapedValue()
Returns the escaped value of the attribute.
public String getOriginalValue()
Returns the original value (escaped or not) of the attribute.
@Deprecated public boolean isXmlnsAttribute()
Returns whether this attribute is a namespace declaration (xmlns:*) or not.
@Deprecated public String getXmlnsPrefix()
If this is a namespace declaration attribute (like "xmlns:x"), this method returns the prefix (the "x").
If this is not a namespace declaration attribute, this method will return null.
public static String normalizeAttributeName(String name)
Normalizes an attribute name by converting it to lower-case. Attributes are processed as case-insensitive, and this method allows normalizing their names before processing.
name
- the name to be normalized.public static String[] applyPrefixToAttributeName(String name, String dialectPrefix)
Applies a prefix (a dialect prefix) to the specified name in order to obtain a complete valid attribute name.
The result looks like: "${prefix}:${name}".
name
- the name to be prefixed.dialectPrefix
- the prefix to be applied.public static String getUnprefixedAttributeName(String attributeName)
Returns the equivalent, un-prefixed name of an attribute from its complete (prefixed, if applies) version.
It supports both namespace prefix style (using :) and HTML5 custom attribute style ('data-{prefix}-{name}'). Examples: src -> src, th:href -> href, data-th-class -> class.
attributeName
- the complete (prefixed, if applies) version of an attribute name.public static String getPrefixFromAttributeName(String attributeName)
Returns the prefix being applied to an attribute.
attributeName
- the complete (prefixed, if applies) version of an attribute name.Copyright © 2017 The THYMELEAF team. All rights reserved.