Modifier and Type | Class and Description |
---|---|
static class |
OneAttributeElement.AttributeChangeEvent |
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.Object |
attribute
The only one attribute
|
protected java.lang.String |
id
Tag of this element.
|
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 |
addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Add or replace each attribute found in attributes.
|
protected abstract void |
attributeChanged(java.lang.String sourceId,
long timeId,
java.lang.String attribute,
OneAttributeElement.AttributeChangeEvent event,
java.lang.Object oldValue,
java.lang.Object newValue)
Called for each change in the attribute set.
|
void |
changeAttribute(java.lang.String attribute,
java.lang.Object value) |
void |
clearAttributes()
Remove all registered attributes.
|
<T> T |
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()
Iterator on all attributes keys.
|
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. |
<T> T |
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? A label is an
attribute whose value is a string.
|
boolean |
hasNumber(java.lang.String key)
Does this element store a number for the given key? A number is an
attribute whose value is an instance of Number.
|
boolean |
hasVector(java.lang.String key)
Does this element store a vector value for the given key? A vector is an
attribute whose value is a sequence of numbers.
|
void |
removeAttribute(java.lang.String attribute)
Remove an attribute.
|
java.lang.String |
toString()
Override the Object method
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAttribute, changeAttribute, getArray, getAttributeCount, getAttributeKeySet, getHash, getIndex, hasArray, hasHash, setAttribute
protected java.lang.String id
java.lang.Object attribute
public OneAttributeElement(java.lang.String id)
id
- The unique identifier of this element.public java.lang.String getId()
Element
public <T> T getAttribute(java.lang.String key)
Element
getAttribute
in interface Element
key
- Name of the attribute to search.public <T> T 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
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()
Element
getAttributeKeyIterator
in interface Element
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 addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Element
addAttributes
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.protected abstract void attributeChanged(java.lang.String sourceId, long timeId, java.lang.String attribute, OneAttributeElement.AttributeChangeEvent event, java.lang.Object oldValue, java.lang.Object newValue)
sourceId
- The source of the change.timeId
- The source time of the change, for synchronization.attribute
- The attribute name that changed.event
- The type of event among ADD, CHANGE and REMOVE.oldValue
- The old value of the attribute, null if the attribute was
added.newValue
- The new value of the attribute, null if the attribute is about
to be removed.