Modifier and Type | Class and Description |
---|---|
static class |
OneAttributeElement.AttributeChangeEvent |
Constructor and Description |
---|
OneAttributeElement(java.lang.String id)
New element.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(java.lang.String attribute,
java.lang.Object value) |
void |
changeAttribute(java.lang.String attribute,
java.lang.Object value) |
void |
clearAttributes()
Remove all registered attributes.
|
java.lang.Object |
getAttribute(java.lang.String key)
Get the attribute object bound to the given key.
|
<T> T |
getAttribute(java.lang.String key,
java.lang.Class<T> clazz)
Get the attribute object bound to the given key if it is an instance of the
given class.
|
java.util.Iterator<java.lang.String> |
getAttributeKeyIterator() |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributeMap() |
<T> T |
getFirstAttributeOf(java.lang.Class<T> clazz,
java.lang.String... keys)
Like
Element.getAttribute(String, Class) , but returns the first existing
attribute in a list of keys, instead of only one key. |
java.lang.Object |
getFirstAttributeOf(java.lang.String... keys)
Like
Element.getAttribute(String) , but returns the first existing attribute
in a list of keys, instead of only one key. |
java.lang.String |
getId()
Unique identifier of this element.
|
java.lang.CharSequence |
getLabel(java.lang.String key)
Get the label string bound to the given key key.
|
double |
getNumber(java.lang.String key)
Get the number bound to key.
|
java.util.ArrayList<? extends java.lang.Number> |
getVector(java.lang.String key)
Get the vector of number bound to key.
|
boolean |
hasAttribute(java.lang.String key)
Does this element store a value for the given attribute key?
|
boolean |
hasAttribute(java.lang.String key,
java.lang.Class<?> clazz)
Does this element store a value for the given attribute key and this value is
an instance of the given class?
|
boolean |
hasLabel(java.lang.String key)
Does this element store a label value for the given key?
|
boolean |
hasNumber(java.lang.String key)
Does this element store a number for the given key?
|
boolean |
hasVector(java.lang.String key)
Does this element store a vector value for the given key?
|
void |
removeAttribute(java.lang.String attribute)
Remove an attribute.
|
void |
setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Add or replace each attribute found in attributes.
|
java.lang.String |
toString()
Override the Object method
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
attributeKeys, getArray, getAttributeCount, getIndex, getMap, hasArray, hasMap, setAttribute
public OneAttributeElement(java.lang.String id)
id
- The unique identifier of this element.public java.lang.String getId()
Element
public java.lang.Object getAttribute(java.lang.String key)
Element
getAttribute
in interface Element
key
- Name of the attribute to search.public java.lang.Object getFirstAttributeOf(java.lang.String... keys)
Element
Element.getAttribute(String)
, but returns the first existing attribute
in a list of keys, instead of only one key. The key list order matters.getFirstAttributeOf
in interface Element
keys
- Several strings naming attributes.public <T> T getAttribute(java.lang.String key, java.lang.Class<T> clazz)
Element
getAttribute
in interface Element
key
- The attribute name to search.clazz
- The expected attribute class.public <T> T getFirstAttributeOf(java.lang.Class<T> clazz, java.lang.String... keys)
Element
Element.getAttribute(String, Class)
, but returns the first existing
attribute in a list of keys, instead of only one key. The key list order
matters.getFirstAttributeOf
in interface Element
clazz
- The class the attribute must be instance of.keys
- Several string naming attributes.public java.lang.CharSequence getLabel(java.lang.String key)
Element
public double getNumber(java.lang.String key)
Element
public java.util.ArrayList<? extends java.lang.Number> getVector(java.lang.String key)
Element
List
of Number
objects.public boolean hasAttribute(java.lang.String key)
Element
hasAttribute
in interface Element
key
- The name of the attribute to search.public boolean hasAttribute(java.lang.String key, java.lang.Class<?> clazz)
Element
hasAttribute
in interface Element
key
- The name of the attribute to search.clazz
- The expected class of the attribute value.public boolean hasLabel(java.lang.String key)
Element
public boolean hasNumber(java.lang.String key)
Element
public boolean hasVector(java.lang.String key)
Element
public java.util.Iterator<java.lang.String> getAttributeKeyIterator()
public java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
public java.lang.String toString()
toString
in class java.lang.Object
public void clearAttributes()
Element
clearAttributes
in interface Element
public void addAttribute(java.lang.String attribute, java.lang.Object value)
public void changeAttribute(java.lang.String attribute, java.lang.Object value)
public void setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Element
setAttributes
in interface Element
attributes
- A set of (key,value) pairs.public void removeAttribute(java.lang.String attribute)
Element
removeAttribute
in interface Element
attribute
- Name of the attribute to remove.