de.grogra.graph
public abstract class Attribute<T> extends java.lang.Object implements KeyDescription, java.lang.Comparable
Attribute represents an attribute of nodes and edges
in a Graph. Attribute values are read and
written on objects within the context of a
GraphState, the corresponding
get- and set-methods are declared in
this class, its type-dependent subclasses
(IntAttribute,
ObjectAttribute, ...), and in
GraphState.
Attributes may be derived (see isDerived()),
which means that their values
are not directly stored in objects, but are computed on the basis
of the state of the object, and possibly of neighbouring objects, too.
Values of derived attributes cannot be written.
| Modifier and Type | Field and Description |
|---|---|
static Attribute[] |
ATTRIBUTE_0
An attribute array of length 0.
|
protected Type |
attrType |
protected Quantity |
quantity |
ACCELERATOR_KEY, ICON, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, TITLE| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(java.lang.Object o) |
static AttributeAccessor |
find(AttributeAccessor[] accessors,
java.lang.String name)
Finds an attribute accessor corresponding to a
name
in a list of accessors. |
static Attribute |
forName(java.lang.String name)
Returns the attribute with the specified
name. |
abstract T |
get(java.lang.Object object,
boolean asNode,
GraphState gs)
Returns the value of this attribute for the given object in
the given graph state.
|
protected java.lang.Object |
getAttributeState(GraphState gs) |
java.lang.Object |
getDescription(java.lang.String type)
Returns the description associated with the given
type. |
int |
getId()
Returns a unique id for this attribute.
|
java.lang.String |
getKey()
Returns the unique, fully-qualified name of this attribute.
|
Quantity |
getQuantity()
Returns the physical quantity of this attribute.
|
java.lang.String |
getSimpleName()
Returns the simple name of this attribute.
|
Type |
getType()
Returns the type of values of this attribute.
|
int |
hashCode() |
Attribute |
initializeI18N(I18NBundle bundle,
java.lang.String resourceKey) |
Attribute |
initializeName(java.lang.String name) |
boolean |
isContained(Attribute[] b)
Checks whether this attribute is contained in the sorted array
b. |
boolean |
isDerived()
Determines whether this is a derived attribute or not.
|
boolean |
isWritable(java.lang.Object object,
boolean asNode,
GraphState gs)
Checks whether a value for this attribute can be written to the
given object.
|
abstract T |
set(java.lang.Object object,
boolean asNode,
java.lang.Object value,
GraphState gs)
Sets the value of this attribute for the given
object
to the given value |
protected void |
setAttributeState(GraphState gs,
java.lang.Object info) |
Attribute[] |
toArray()
Returns an array of length one containing this attribute.
|
java.lang.String |
toString() |
public static final Attribute[] ATTRIBUTE_0
protected final Type attrType
protected final Quantity quantity
public final int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparablepublic static AttributeAccessor find(AttributeAccessor[] accessors, java.lang.String name)
name
in a list of accessors. If the attribute of one of the
accessors has a name or a simple name which equals
the given name, then this accessor is returned, otherwise
null. null-values are allowed within
accessors.accessors - the array of accessorsname - the name to searchname,
or nullpublic static final Attribute forName(java.lang.String name)
name.
If an attribute with that name has not yet been registered
by initializeName(String), null is
returned.name - name of an attributenullpublic abstract T get(java.lang.Object object, boolean asNode, GraphState gs)
object - the objectasNode - true if object is a node,
false if object is an edgegs - the graph state contextprotected final java.lang.Object getAttributeState(GraphState gs)
public java.lang.Object getDescription(java.lang.String type)
Describedtype.
type has to be one of the predefined constants
of this interface, the returned value has to conform to the
specification of the used constant.getDescription in interface Describedtype - the type of descriptionnull if no description is availablepublic final int getId()
public final java.lang.String getKey()
getKey in interface KeyDescriptionpublic final Quantity getQuantity()
getQuantity in interface KeyDescriptionpublic final java.lang.String getSimpleName()
public final Type getType()
getType in interface KeyDescriptionpublic final int hashCode()
hashCode in class java.lang.Objectpublic final Attribute initializeI18N(I18NBundle bundle, java.lang.String resourceKey)
public final Attribute initializeName(java.lang.String name)
public final boolean isContained(Attribute[] b)
b. The array has to be sorted in ascending order
according to the order induced by compareTo(Object).b - a sorted array of attributestrue iff this attribute is contained in bpublic boolean isDerived()
true iff this is a derived attributepublic boolean isWritable(java.lang.Object object,
boolean asNode,
GraphState gs)
object - the objectasNode - true if object is a node,
false if object is an edgegs - the graph state contexttrue iff the attribute is writable for the given objectpublic abstract T set(java.lang.Object object, boolean asNode, java.lang.Object value, GraphState gs)
object
to the given valueobject - the objectasNode - true if object is a node,
false if object is an edgevalue - the new value of the attribute for the objectgs - the graph state contextprotected final void setAttributeState(GraphState gs, java.lang.Object info)
public final Attribute[] toArray()
public java.lang.String toString()
toString in class java.lang.Object