Class Attribute<T>

java.lang.Object
com.google.gwt.aria.client.Attribute<T>
Type Parameters:
T - The attribute value type
Direct Known Subclasses:
AriaValueAttribute, PrimitiveValueAttribute

public abstract class Attribute<T> extends Object

Class representing ARIA state/property attribute. Contains methods for setting, getting, removing ARIA attributes for an HTML Element.

For more details about ARIA states and properties check the W3C ARIA documentation Supported States and Properties .

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a state/property ARIA attribute with name name and null default value.
    Attribute(String name, String defaultValue)
    Constructs a state/property ARIA attribute with name name and defaultValue.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(Element element)
    Gets the HTML attribute value for the attribute with name name for element element
    Gets the property/state name
    protected abstract String
    Gets the string representation of value to be set as an attribute value to an HTML element.
    void
    remove(Element element)
    Removes the state/property attribute for element element.
    void
    set(Element element, T... values)
    Sets the state/property value for the HTML element element.
    void
    Sets the state/property value to the defaultValue if not null.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      protected final String name
    • defaultValue

      protected String defaultValue
  • Constructor Details

    • Attribute

      public Attribute(String name, String defaultValue)
      Constructs a state/property ARIA attribute with name name and defaultValue.
      Parameters:
      name - State/Property name
      defaultValue - Default values
    • Attribute

      public Attribute(String name)
      Constructs a state/property ARIA attribute with name name and null default value.
      Parameters:
      name - State/Property name
  • Method Details

    • get

      public String get(Element element)
      Gets the HTML attribute value for the attribute with name name for element element
      Parameters:
      element - HTML element
      Returns:
      The attribute value for element
    • getName

      public String getName()
      Gets the property/state name
      Returns:
      The attribute name
    • remove

      public void remove(Element element)
      Removes the state/property attribute for element element.
      Parameters:
      element - HTM element
    • set

      public void set(Element element, T... values)
      Sets the state/property value for the HTML element element.
      Parameters:
      element - HTML element
      values - Attribute value
    • setDefault

      public void setDefault(Element element)
      Sets the state/property value to the defaultValue if not null. If a list of default values is set, every default value is converted to string and the string values are concatenated in a string token list. There is an assertion checking whether the default is null. Note that the asserts are enabled during development and testing but they will be stripped in production mode.
      Parameters:
      element - HTML element
    • getSingleValue

      protected abstract String getSingleValue(T value)
      Gets the string representation of value to be set as an attribute value to an HTML element.
      Parameters:
      value - The item to be stringified
      Returns:
      the stringified representation of value