Class Attribute

  • All Implemented Interfaces:
    IAttribute

    final class Attribute
    extends java.lang.Object
    implements IAttribute
    • Field Detail

      • completeName

        final java.lang.String completeName
      • operator

        final java.lang.String operator
      • value

        final java.lang.String value
      • templateName

        final java.lang.String templateName
      • line

        final int line
      • col

        final int col
    • Constructor Detail

      • Attribute

        Attribute​(AttributeDefinition definition,
                  java.lang.String completeName,
                  java.lang.String operator,
                  java.lang.String value,
                  AttributeValueQuotes valueQuotes,
                  java.lang.String templateName,
                  int line,
                  int col)
    • Method Detail

      • 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 java.lang.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 java.lang.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 java.lang.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.
      • getTemplateName

        public java.lang.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.
      • setCachedStandardExpression

        void setCachedStandardExpression​(IStandardExpression standardExpression)
      • write

        public void write​(java.io.Writer writer)
                   throws java.io.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:
        java.io.IOException - if an input/output exception occurs.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object