Package com.google.gwt.aria.client
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 java.lang.ObjectClass 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 java.lang.StringdefaultValueprotected java.lang.Stringname
-
Constructor Summary
Constructors Constructor Description Attribute(java.lang.String name)Constructs a state/property ARIA attribute with namenameand null default value.Attribute(java.lang.String name, java.lang.String defaultValue)Constructs a state/property ARIA attribute with namenameanddefaultValue.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Stringget(Element element)Gets the HTML attribute value for the attribute with namenamefor elementelementjava.lang.StringgetName()Gets the property/state nameprotected abstract java.lang.StringgetSingleValue(T value)Gets the string representation ofvalueto be set as an attribute value to an HTML element.voidremove(Element element)Removes the state/property attribute for elementelement.voidset(Element element, T... values)Sets the state/propertyvaluefor the HTML elementelement.voidsetDefault(Element element)Sets the state/property value to the defaultValue if not null.
-
-
-
Constructor Detail
-
Attribute
public Attribute(java.lang.String name, java.lang.String defaultValue)Constructs a state/property ARIA attribute with namenameanddefaultValue.- Parameters:
name- State/Property namedefaultValue- Default values
-
Attribute
public Attribute(java.lang.String name)
Constructs a state/property ARIA attribute with namenameand null default value.- Parameters:
name- State/Property name
-
-
Method Detail
-
get
public java.lang.String get(Element element)
Gets the HTML attribute value for the attribute with namenamefor elementelement- Parameters:
element- HTML element- Returns:
- The attribute value for
element
-
getName
public java.lang.String getName()
Gets the property/state name- Returns:
- The attribute name
-
remove
public void remove(Element element)
Removes the state/property attribute for elementelement.- Parameters:
element- HTM element
-
set
public void set(Element element, T... values)
Sets the state/propertyvaluefor the HTML elementelement.- Parameters:
element- HTML elementvalues- 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 java.lang.String getSingleValue(T value)
Gets the string representation ofvalueto be set as an attribute value to an HTML element.- Parameters:
value- The item to be stringified- Returns:
- the stringified representation of
value
-
-