org.thymeleaf.dom
Class Attribute

Object
  extended by org.thymeleaf.dom.Attribute
All Implemented Interfaces:
Serializable

public final class Attribute
extends Object
implements Serializable

Models an element attribute.

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

Constructor Summary
Attribute(String name, boolean onlyName, String value)
           
 
Method Summary
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 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.
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.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(String name,
                 boolean onlyName,
                 String value)
Method Detail

getOriginalName

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.

Returns:
the original name of the attribute.

getNormalizedName

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.

Returns:
the normalized name of the attribute.

getNormalizedPrefix

@Deprecated
public String getNormalizedPrefix()
Deprecated. Deprecated in 2.1.0. There is no actual usage of this method

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.

Returns:
the normalized prefix.

getUnprefixedNormalizedName

@Deprecated
public String getUnprefixedNormalizedName()
Deprecated. Deprecated in 2.1.0. There is no actual usage of this method

Returns the normalized version of the attribute name, without its prefix (if it has one).

Returns:
the unprefixed normalized name.

hasPrefix

@Deprecated
public boolean hasPrefix()
Deprecated. Deprecated in 2.1.0. There is no actual usage of this method

Returns whether the attribute name has a prefix or not.

Returns:
true if the attribute name has a prefix, false if not.

isOnlyName

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.

Returns:
true if attribute should be represented only by its name.
Since:
2.0.14

getValue

public String getValue()

Returns the value of the attribute.

Returns:
the value of the attribute.

isXmlnsAttribute

@Deprecated
public 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.

Returns whether this attribute is a namespace declaration (xmlns:*) or not.

Returns:
true if the attribute is a namespace declaration, false if not.

getXmlnsPrefix

@Deprecated
public 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.

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.

Returns:
the namespace prefix, if this is a namespace declaration attribute.

normalizeAttributeName

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.

Parameters:
name - the name to be normalized.
Returns:
the normalized name.
Since:
2.1.0

applyPrefixToAttributeName

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}".

Parameters:
name - the name to be prefixed.
dialectPrefix - the prefix to be applied.
Returns:
the prefixed name.
Since:
2.1.0

getUnprefixedAttributeName

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.

Parameters:
attributeName - the complete (prefixed, if applies) version of an attribute name.
Returns:
the unprefixed version of the specified attribute name.
Since:
2.1.0

getPrefixFromAttributeName

public static String getPrefixFromAttributeName(String attributeName)

Returns the prefix being applied to an attribute.

Parameters:
attributeName - the complete (prefixed, if applies) version of an attribute name.
Returns:
the prefix being applied to the name, or null if the attribute has no prefix.
Since:
2.1.0


Copyright © 2013 The THYMELEAF team. All Rights Reserved.