Class OneAttributeElement
java.lang.Object
org.graphstream.graph.implementations.OneAttributeElement
- All Implemented Interfaces:
Element
public abstract class OneAttributeElement extends Object implements Element
An implementation of an
Element
.
It allows only one attribute and has no internal map structure. It is not used and may be removed.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OneAttributeElement.AttributeChangeEvent
-
Constructor Summary
Constructors Constructor Description OneAttributeElement(String id)
New element. -
Method Summary
Modifier and Type Method Description void
addAttribute(String attribute, Object value)
void
changeAttribute(String attribute, Object value)
void
clearAttributes()
Remove all registered attributes.Object
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.Iterator<String>
getAttributeKeyIterator()
Map<String,Object>
getAttributeMap()
<T> T
getFirstAttributeOf(Class<T> clazz, String... keys)
LikeElement.getAttribute(String, Class)
, but returns the first existing attribute in a list of keys, instead of only one key.Object
getFirstAttributeOf(String... keys)
LikeElement.getAttribute(String)
, but returns the first existing attribute in a list of keys, instead of only one key.String
getId()
Unique identifier 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
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
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
setAttributes(Map<String,Object> attributes)
Add or replace each attribute found in attributes.String
toString()
Override the Object methodMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.graphstream.graph.Element
attributeKeys, getArray, getAttributeCount, getIndex, getMap, hasArray, hasMap, setAttribute
-
Constructor Details
-
OneAttributeElement
New element.- Parameters:
id
- The unique identifier of this element.
-
-
Method Details
-
getId
Description copied from interface:Element
Unique identifier of this element. -
getAttribute
Description copied from interface:Element
Get the attribute object bound to the given key. The returned value may be null to indicate the attribute does not exists or is not supported.- Specified by:
getAttribute
in interfaceElement
- Parameters:
key
- Name of the attribute to search.- Returns:
- The object bound to the given key or null if no object match this attribute name.
-
getFirstAttributeOf
Description copied from interface:Element
LikeElement.getAttribute(String)
, but returns the first existing attribute in a list of keys, instead of only one key. The key list order matters.- Specified by:
getFirstAttributeOf
in interfaceElement
- Parameters:
keys
- Several strings naming attributes.- Returns:
- The first attribute that exists.
-
getAttribute
Description copied from interface:Element
Get the attribute object bound to the given key if it is an instance of the given class. Some The returned value maybe null to indicate the attribute does not exists or is not an instance of the given class.- Specified by:
getAttribute
in interfaceElement
- Parameters:
key
- The attribute name to search.clazz
- The expected attribute class.- Returns:
- The object bound to the given key or null if no object match this attribute.
-
getFirstAttributeOf
Description copied from interface:Element
LikeElement.getAttribute(String, Class)
, but returns the first existing attribute in a list of keys, instead of only one key. The key list order matters.- Specified by:
getFirstAttributeOf
in interfaceElement
- Parameters:
clazz
- The class the attribute must be instance of.keys
- Several string naming attributes.- Returns:
- The first attribute that exists.
-
getLabel
Description copied from interface:Element
Get the label string bound to the given key key. Labels are special attributes whose value is a character sequence. If an attribute with the same name exists but is not a character sequence, null is returned. -
getNumber
Description copied from interface:Element
Get the number bound to key. Numbers are special attributes whose value is an instance of Number. If an attribute with the same name exists but is not a Number, NaN is returned. -
getVector
Description copied from interface:Element
-
hasAttribute
Description copied from interface:Element
Does this element store a value for the given attribute key? Note that returning true here does not mean that calling getAttribute with the same key will not return null since attribute values can be null. This method just checks if the key is present, with no test on the value.- Specified by:
hasAttribute
in interfaceElement
- Parameters:
key
- The name of the attribute to search.- Returns:
- True if a value is present for this attribute.
-
hasAttribute
Description copied from interface:Element
Does this element store a value for the given attribute key and this value is an instance of the given class?- Specified by:
hasAttribute
in interfaceElement
- Parameters:
key
- The name of the attribute to search.clazz
- The expected class of the attribute value.- Returns:
- True if a value is present for this attribute.
-
hasLabel
Description copied from interface:Element
Does this element store a label value for the given key? A label is an attribute whose value is a char sequence. -
hasNumber
Description copied from interface:Element
Does this element store a number for the given key? A number is an attribute whose value is an instance of Number. -
hasVector
Description copied from interface:Element
Does this element store a vector value for the given key? A vector is an attribute whose value is a sequence of numbers. -
getAttributeKeyIterator
-
getAttributeMap
-
toString
Override the Object method -
clearAttributes
public void clearAttributes()Description copied from interface:Element
Remove all registered attributes. This includes numbers, labels and vectors.- Specified by:
clearAttributes
in interfaceElement
-
addAttribute
-
changeAttribute
-
setAttributes
Description copied from interface:Element
Add or replace each attribute found in attributes. Existing attributes are overwritten silently. All classes inheriting from Number can be considered as numbers. All classes inheriting from CharSequence can be considered as labels.- Specified by:
setAttributes
in interfaceElement
- Parameters:
attributes
- A set of (key,value) pairs.
-
removeAttribute
Description copied from interface:Element
Remove an attribute. Non-existent attributes errors are ignored silently.- Specified by:
removeAttribute
in interfaceElement
- Parameters:
attribute
- Name of the attribute to remove.
-