public interface Element
An interface that defines common method to manipulate identifiers, attributes and indices of the elements (graph, nodes and edges) of a graph.
*
Attributes can be any object and are identified by arbitrary strings. Some
attributes are stored as numbers or strings and are in this case named
number, label or vector. There are utility methods to handle these attributes
(getNumber(String)
, getLabel(String)
) or
getVector(String)
, however they are also accessible through the more
general method getAttribute(String)
.
Implementing classes should indicate the complexity of their implementation for each method.
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String attribute,
Object... values)
Add or replace the value of an attribute.
|
void |
addAttributes(Map<String,Object> attributes)
Add or replace each attribute found in attributes.
|
void |
changeAttribute(String attribute,
Object... values)
Like
addAttribute(String, Object...) but for consistency. |
void |
clearAttributes()
Remove all registered attributes.
|
Object[] |
getArray(String key)
Get the array of objects bound to key.
|
<T> T |
getAttribute(String key)
Get the attribute object bound to the given key.
|
<T> T |
getAttribute(String key,
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.
|
Iterator<String> |
getAttributeKeyIterator()
Iterator on all attributes keys.
|
Collection<String> |
getAttributeKeySet()
An unmodifiable view on the set of attribute keys.
|
Iterable<String> |
getEachAttributeKey()
An iterable view on the set of attribute keys usable within a for-each
loop.
|
<T> T |
getFirstAttributeOf(Class<T> clazz,
String... keys)
Like
getAttribute(String, Class) , but returns the first existing
attribute in a list of keys, instead of only one key. |
<T> T |
getFirstAttributeOf(String... keys)
Like
getAttribute(String) , but returns the first existing
attribute in a list of keys, instead of only one key. |
HashMap<?,?> |
getHash(String key)
Get the hash bound to key.
|
String |
getId()
Unique identifier of this element.
|
int |
getIndex()
The current index of this element
|
CharSequence |
getLabel(String key)
Get the label string bound to the given key key.
|
double |
getNumber(String key)
Get the number bound to key.
|
ArrayList<? extends Number> |
getVector(String key)
Get the vector of number bound to key.
|
boolean |
hasArray(String key)
Does this element store an array value for the given key?
|
boolean |
hasAttribute(String key)
Does this element store a value for the given attribute key?
|
boolean |
hasAttribute(String key,
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(String key)
Does this element store a hash value for the given key?
|
boolean |
hasLabel(String key)
Does this element store a label value for the given key?
|
boolean |
hasNumber(String key)
Does this element store a number for the given key?
|
boolean |
hasVector(String key)
Does this element store a vector value for the given key?
|
void |
removeAttribute(String attribute)
Remove an attribute.
|
void |
setAttribute(String attribute,
Object... values)
Like
addAttribute(String, Object...) but for consistency. |
int getIndex()
<T> T getAttribute(String key)
key
- Name of the attribute to search.<T> T getFirstAttributeOf(String... keys)
getAttribute(String)
, but returns the first existing
attribute in a list of keys, instead of only one key. The key list order
matters.keys
- Several strings naming attributes.<T> T getAttribute(String key, Class<T> clazz)
key
- The attribute name to search.clazz
- The expected attribute class.<T> T getFirstAttributeOf(Class<T> clazz, String... keys)
getAttribute(String, Class)
, but returns the first existing
attribute in a list of keys, instead of only one key. The key list order
matters.clazz
- The class the attribute must be instance of.keys
- Several string naming attributes.CharSequence getLabel(String key)
key
- The label to search.double getNumber(String key)
key
- The name of the number to search.ArrayList<? extends Number> getVector(String key)
key
- The name of the number to search.Object[] getArray(String key)
key
- The name of the array to search.HashMap<?,?> getHash(String key)
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.key
- The name of the hash to search.boolean hasAttribute(String key)
key
- The name of the attribute to search.boolean hasAttribute(String key, Class<?> clazz)
key
- The name of the attribute to search.clazz
- The expected class of the attribute value.boolean hasLabel(String key)
key
- The name of the label.boolean hasNumber(String key)
key
- The name of the number.boolean hasVector(String key)
key
- The name of the vector.boolean hasArray(String key)
key
- The name of the array.boolean hasHash(String key)
CompoundAttribute
class.key
- The name of the hash.Iterator<String> getAttributeKeyIterator()
Iterable<String> getEachAttributeKey()
Collection<String> getAttributeKeySet()
void clearAttributes()
void addAttribute(String attribute, Object... values)
attribute
- The attribute name.values
- The attribute value or set of values.void changeAttribute(String attribute, Object... values)
addAttribute(String, Object...)
but for consistency.attribute
- The attribute name.values
- The attribute value or array of values.addAttribute(String, Object...)
void setAttribute(String attribute, Object... values)
addAttribute(String, Object...)
but for consistency.attribute
- The attribute name.values
- The attribute value or array of values.addAttribute(String, Object...)
void addAttributes(Map<String,Object> attributes)
attributes
- A set of (key,value) pairs.void removeAttribute(String attribute)
attribute
- Name of the attribute to remove.int getAttributeCount()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses