static class Graphs.SynchronizedElement<U extends Element> extends java.lang.Object implements Element
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.locks.ReentrantLock |
attributeLock |
protected U |
wrappedElement |
Constructor and Description |
---|
Graphs.SynchronizedElement(U e) |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(java.lang.String attribute,
java.lang.Object... values)
Add or replace the value of an attribute.
|
void |
addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
Add or replace each attribute found in attributes.
|
void |
changeAttribute(java.lang.String attribute,
java.lang.Object... values)
Like
Element.addAttribute(String, Object...) but for consistency. |
void |
clearAttributes()
Remove all registered attributes.
|
java.lang.Object[] |
getArray(java.lang.String key)
Get the array of objects bound to key.
|
<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.
|
int |
getAttributeCount()
Number of attributes stored in this element.
|
java.util.Iterator<java.lang.String> |
getAttributeKeyIterator()
Iterator on all attributes keys.
|
java.lang.Iterable<java.lang.String> |
getAttributeKeySet()
An iterable view on the set of attributes keys usable with the for-each
loop.
|
<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.util.HashMap<?,?> |
getHash(java.lang.String key)
Get the hash bound to key.
|
java.lang.String |
getId()
Unique identifier of this element.
|
int |
getIndex()
The current index 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 |
hasArray(java.lang.String key)
Does this element store an array value for the given key? A vector is an
attribute whose value is an array of objects.
|
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 |
hasHash(java.lang.String key)
Does this element store a hash value for the given key? A hash is a set
of pairs (key,value) or objects that implement the
CompoundAttribute 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.
|
void |
setAttribute(java.lang.String attribute,
java.lang.Object... values)
Like
Element.addAttribute(String, Object...) but for consistency. |
Graphs.SynchronizedElement(U e)
public void addAttribute(java.lang.String attribute, java.lang.Object... values)
Element
addAttribute
in interface Element
attribute
- The attribute name.values
- The attribute value or set of values.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 changeAttribute(java.lang.String attribute, java.lang.Object... values)
Element
Element.addAttribute(String, Object...)
but for consistency.changeAttribute
in interface Element
attribute
- The attribute name.values
- The attribute value or array of values.Element.addAttribute(String, Object...)
public void clearAttributes()
Element
clearAttributes
in interface Element
public java.lang.Object[] getArray(java.lang.String key)
Element
public <T> T getAttribute(java.lang.String key)
Element
getAttribute
in interface Element
key
- Name of the attribute to search.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 int getAttributeCount()
Element
getAttributeCount
in interface Element
public java.util.Iterator<java.lang.String> getAttributeKeyIterator()
Element
getAttributeKeyIterator
in interface Element
public java.lang.Iterable<java.lang.String> getAttributeKeySet()
Element
getAttributeKeySet
in interface Element
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 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.util.HashMap<?,?> getHash(java.lang.String key)
Element
CompoundAttribute
interface are considered like hashes since they
can be transformed to a hash. If an attribute with the same name exists
but is not a hash, null is returned. We cannot enforce the type of the
key. It is considered a string and you should use "Object.toString()" to
get it.public java.lang.String getId()
Element
public int getIndex()
Element
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 hasArray(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 hasHash(java.lang.String key)
Element
CompoundAttribute
class.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 void removeAttribute(java.lang.String attribute)
Element
removeAttribute
in interface Element
attribute
- Name of the attribute to remove.public void setAttribute(java.lang.String attribute, java.lang.Object... values)
Element
Element.addAttribute(String, Object...)
but for consistency.setAttribute
in interface Element
attribute
- The attribute name.values
- The attribute value or array of values.Element.addAttribute(String, Object...)