Class Attribute

java.lang.Object
org.thymeleaf.engine.Attribute
All Implemented Interfaces:
IAttribute

final class Attribute extends Object implements IAttribute
  • Field Details

  • Constructor Details

  • Method Details

    • getAttributeDefinition

      public AttributeDefinition getAttributeDefinition()
      Description copied from interface: IAttribute

      Returns the AttributeDefinition corresponding to this attribute.

      The attribute definition contains several metadata related to the attribute. For example, if the template mode is TemplateMode.HTML, an attribute definition could specify whether the attribute is boolean (represents a true/false value by appearing or not appearing at a specific tag).

      Specified by:
      getAttributeDefinition in interface IAttribute
      Returns:
      the attribute definition.
    • getAttributeCompleteName

      public String getAttributeCompleteName()
      Description copied from interface: IAttribute

      Returns the complete name of the attribute, exactly as it was written in the original template (if it did appear there).

      Specified by:
      getAttributeCompleteName in interface IAttribute
      Returns:
      the complete name.
    • getOperator

      public String getOperator()
      Description copied from interface: IAttribute

      Returns the operator specified for this attribute.

      The operator itself, if present, is always an equals sign (=), but the reason this is specified as a separate field is that it could be surrounded by white space, which should be respected in output when present at the input template.

      If the attribute is specified without a value at all (and therefore no operator either), this method will return null.

      Specified by:
      getOperator in interface IAttribute
      Returns:
      the attribute operator (might be null if no value specified).
    • getValue

      public String getValue()
      Description copied from interface: IAttribute

      Returns the value of this attribute, or null if it has none.

      A null-valued attribute is an attribute of which only the name has been specified (only allowed in HTML mode).

      Specified by:
      getValue in interface IAttribute
      Returns:
      the value of this attribute, or null if it has none.
    • getValueQuotes

      public AttributeValueQuotes getValueQuotes()
      Description copied from interface: IAttribute

      Returns the type of quotes surrounding the attribute value.

      Specified by:
      getValueQuotes in interface IAttribute
      Returns:
      the AttributeValueQuotes value representing the attribute value quotes (might be null).
    • getTemplateName

      public String getTemplateName()
      Description copied from interface: IAttribute

      Returns the name of the template from which parsing this attribute was originally created.

      Specified by:
      getTemplateName in interface IAttribute
      Returns:
      the name of the template
    • hasLocation

      public final boolean hasLocation()
      Description copied from interface: IAttribute

      Checks whether this attribute contains location information (template name, line and column).

      Only attributes that are generated during the parsing of templates contain location info, locating them in their original template. All attributes generated during template processing and not originally present at the template do not contain this location data.

      Specified by:
      hasLocation in interface IAttribute
      Returns:
      whether the attribute contains location data or not.
    • getLine

      public int getLine()
      Description copied from interface: IAttribute

      Returns the line at which this attribute can be found in the template specified by IAttribute.getTemplateName().

      Specified by:
      getLine in interface IAttribute
      Returns:
      the line number, starting in 1.
    • getCol

      public int getCol()
      Description copied from interface: IAttribute

      Returns the column at which this attribute can be found in the template specified by IAttribute.getTemplateName().

      Specified by:
      getCol in interface IAttribute
      Returns:
      the column number, starting in 1.
    • getCachedStandardExpression

      IStandardExpression getCachedStandardExpression()
    • setCachedStandardExpression

      void setCachedStandardExpression(IStandardExpression standardExpression)
    • modify

      Attribute modify(AttributeDefinition definition, String completeName, String value, AttributeValueQuotes valueQuotes)
    • write

      public void write(Writer writer) throws IOException
      Description copied from interface: IAttribute

      Writes this attribute to the specified Writer.

      This is usually called as a part of ITemplateEvent.write(Writer).

      Specified by:
      write in interface IAttribute
      Parameters:
      writer - the writer this attribute should be written to.
      Throws:
      IOException - if an input/output exception occurs.
    • toString

      public String toString()
      Overrides:
      toString in class Object