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 classOneAttributeElement.AttributeChangeEvent -
Constructor Summary
Constructors Constructor Description OneAttributeElement(String id)New element. -
Method Summary
Modifier and Type Method Description voidaddAttribute(String attribute, Object value)voidchangeAttribute(String attribute, Object value)voidclearAttributes()Remove all registered attributes.ObjectgetAttribute(String key)Get the attribute object bound to the given key.<T> TgetAttribute(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> TgetFirstAttributeOf(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.ObjectgetFirstAttributeOf(String... keys)LikeElement.getAttribute(String), but returns the first existing attribute in a list of keys, instead of only one key.StringgetId()Unique identifier of this element.CharSequencegetLabel(String key)Get the label string bound to the given key key.doublegetNumber(String key)Get the number bound to key.ArrayList<? extends Number>getVector(String key)Get the vector of number bound to key.booleanhasAttribute(String key)Does this element store a value for the given attribute key?booleanhasAttribute(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?booleanhasLabel(String key)Does this element store a label value for the given key?booleanhasNumber(String key)Does this element store a number for the given key?booleanhasVector(String key)Does this element store a vector value for the given key?voidremoveAttribute(String attribute)Remove an attribute.voidsetAttributes(Map<String,Object> attributes)Add or replace each attribute found in attributes.StringtoString()Override the Object methodMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:ElementUnique identifier of this element. -
getAttribute
Description copied from interface:ElementGet 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:
getAttributein 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:ElementLikeElement.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:
getFirstAttributeOfin interfaceElement- Parameters:
keys- Several strings naming attributes.- Returns:
- The first attribute that exists.
-
getAttribute
Description copied from interface:ElementGet 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:
getAttributein 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:ElementLikeElement.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:
getFirstAttributeOfin 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:ElementGet 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:ElementGet 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:ElementDoes 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:
hasAttributein 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:ElementDoes this element store a value for the given attribute key and this value is an instance of the given class?- Specified by:
hasAttributein 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:ElementDoes 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:ElementDoes 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:ElementDoes 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:ElementRemove all registered attributes. This includes numbers, labels and vectors.- Specified by:
clearAttributesin interfaceElement
-
addAttribute
-
changeAttribute
-
setAttributes
Description copied from interface:ElementAdd 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:
setAttributesin interfaceElement- Parameters:
attributes- A set of (key,value) pairs.
-
removeAttribute
Description copied from interface:ElementRemove an attribute. Non-existent attributes errors are ignored silently.- Specified by:
removeAttributein interfaceElement- Parameters:
attribute- Name of the attribute to remove.
-