com.tensegrity.graph.model
Interface GraphObject

All Superinterfaces:
Attributable, AttributableOnSet
All Known Subinterfaces:
Edge, Node, Subgraph

public interface GraphObject
extends AttributableOnSet

This interface represents the aspects common to all Graph elements, including a Node, Edge and Subgraph.

GraphObject instances are created using factory objects that return specialized, concrete GraphObject types.

GraphObjects have an identifiable nature. Every GraphObject has both an identifier unique to its context as well as a global identifier that is unique within a hierarchy of Graph objects.


Each GraphObject implementation is constructed with an initial identifier of -1. When a GraphObject is added to a GraphObjectContainer, the identifier is changed internally by the container to a value that becomes unique within that container context. The container may nest other containers recursively, which might have the same identifier assigned to one of their managed objects. Identifiers, therefore, are unique within the scope of a single GraphObjectContainer only.
When a GraphObject is removed from a GraphObjectContainer, the identifier is reset to -1.
Methods to access both of these identifiers are available.

It is possible to associate a name and a description with a GraphObject. These can be used for example to easily assign a type and a descriptive text to the GraphObject.

The standard attributes of a GraphObject may be extended with custom attributes.
The custom attributes added to the GraphObject are grouped into the category custom and returned by a call to AttributableOnSet.getAttributes().
The methods provided by a GraphObject to handle custom attributes are listed below:

GraphObject instances that are removed from their containers and dereferenced will be garbage collected.

GraphObject extends the AttributableOnSet interface, which allows clients to associate attributes with them.

Version:
$Id: GraphObject.java,v 1.51 2005/08/17 09:35:38 MichaelKegel Exp $
Author:
Stepan Rutz
See Also:
Edge, Node, Subgraph, GraphObjectContainer, Graph

Field Summary
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Method Summary
 void addCustomAttribute(Attribute attribute)
          Adds the Attribute given by attribute to the custom attributes of the GraphObject.
 boolean assertCustomAttribute(Attribute attribute)
          Sets a custom attribute and adds it, if it doesn't exist yet.
 boolean assertCustomAttribute(java.lang.String path, java.lang.Object value)
          Sets the value of a custom attributes and creates it first, if it doesn't exist.
 void fillInDump(java.util.List list, int level)
          Fills in a dump into the given list.
 AttributeSet getCustomAttributes()
          Returns an AttributeSet that contains all custom attributes currently assigned to the GraphObject or null if no custom attribute is assigned to the GraphObject.
 java.lang.String getDescription()
          Returns the description string of this GraphObject
 long getID()
          Returns the local identifier (unique within a single GraphObjectContainer.
 java.lang.String getLabel()
          Returns the label associated with this object.
 GraphObjectContainer getParentContainer()
          This method returns the GraphObjectContainer this GraphObject instance currently resides in.
 long getUniqueID()
          Returns the global identifier (unique within the complete GraphObjectContainer hierarchy)
 void registerEventMediator(GraphEventMediator mediator)
          Registers the GraphEventMediator object given by mediator to the GraphObject.
 void registerEventMediatorInternal(GraphEventMediator mediatorInternal)
          Registers the GraphEventMediator object given by mediator to the GraphObject.
 void registerVetoableEventMediator(VetoableGraphEventMediator vmediator)
          Registers the VetoableGraphEventMediator object given by vmediator to the GraphObject.
 void removeCustomAttribute(java.lang.String attributename)
          Removes the custom Attribute with the name given by attributename from the GraphObjects custom attributes.
 void setCustomAttributes(AttributeSet customAttributes)
          Sets the Attributes within the AttributeSet given by customAttributes to the custom attributes currently added to the GraphObject.
 void setDescription(java.lang.String description)
          Sets the description of this GraphObject to the given string
 void setLabel(java.lang.String label)
          Sets the label to be associated with this object.
 
Methods inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
addAttributableOnSetListener, areAttributableEventsEnabled, disableAttributableEvents, enableAttributableEvents, getAttributes, getAttributesTree, removeAttributableOnSetListener, setAttributes, setAttributesTree
 
Methods inherited from interface com.tensegrity.generic.attribute.Attributable
getAttribute, getAttributeType, getAttributeValue, setAttribute, setAttributeValue
 

Method Detail

getID

public long getID()
Returns the local identifier (unique within a single GraphObjectContainer.

Returns:
the local ID.

Find more information in the class documentation


getUniqueID

public long getUniqueID()
Returns the global identifier (unique within the complete GraphObjectContainer hierarchy)

Returns:
long the identifier

Find more information in the class documentation


getLabel

public java.lang.String getLabel()
Returns the label associated with this object.

Returns:
the label associated with this object.

Find more information in the class documentation


setLabel

public void setLabel(java.lang.String label)
Sets the label to be associated with this object.

Parameters:
label - the label

Find more information in the class documentation


getDescription

public java.lang.String getDescription()
Returns the description string of this GraphObject

Returns:
the description string of this GraphObject

Find more information in the class documentation


setDescription

public void setDescription(java.lang.String description)
Sets the description of this GraphObject to the given string

Parameters:
description - The description to set

Find more information in the class documentation


addCustomAttribute

public void addCustomAttribute(Attribute attribute)
Adds the Attribute given by attribute to the custom attributes of the GraphObject.
If a custom attribute with the same key as the attribute that is given was already added to this GraphObject then the adding of the new custom attribute fails and the instance remains unchanged.

Parameters:
attribute - the custom Attribute to add

Find more information in the class documentation


removeCustomAttribute

public void removeCustomAttribute(java.lang.String attributename)
Removes the custom Attribute with the name given by attributename from the GraphObjects custom attributes.

Parameters:
attributename - the name of the custom Attribute to remove

Find more information in the class documentation


getCustomAttributes

public AttributeSet getCustomAttributes()
Returns an AttributeSet that contains all custom attributes currently assigned to the GraphObject or null if no custom attribute is assigned to the GraphObject.

Notice: The Attributes within the returned AttributeSet are copies of the custom attributes currently added to the GraphObject and no references. So that if you want to change them you have to call setCustomAttributes(com.tensegrity.generic.attribute.AttributeSet) afterwards.

Returns:
AttributeSet a set with the custom attributes currently added to the GraphObject

Find more information in the class documentation


setCustomAttributes

public void setCustomAttributes(AttributeSet customAttributes)
Sets the Attributes within the AttributeSet given by customAttributes to the custom attributes currently added to the GraphObject. This is done by a merge of the given Attributes and the custom attributes currently added. The merge is done by the following rules:

Parameters:
customAttributes - The AttributeSet with the Attributes to set

Find more information in the class documentation


assertCustomAttribute

public boolean assertCustomAttribute(java.lang.String path,
                                     java.lang.Object value)
                              throws IllegalValueException,
                                     ConstraintViolationException,
                                     IllegalNameException
Sets the value of a custom attributes and creates it first, if it doesn't exist.

Parameters:
path - The path of the custom attribute
value - The value of the custom attribute
Returns:
true, if the attribute has been created
Throws:
IllegalValueException - is thrown when the given value is illegal (for instance when it is null).
ConstraintViolationException - is thrown when the given value violates the constraint of the Attribute to set.
IllegalNameException - is thrown if the given name for the attribute is invalid.

assertCustomAttribute

public boolean assertCustomAttribute(Attribute attribute)
                              throws IllegalValueException,
                                     ConstraintViolationException,
                                     IllegalNameException
Sets a custom attribute and adds it, if it doesn't exist yet.

Parameters:
attribute - The custom attribute to set
Returns:
true, if the attribute has been added
Throws:
IllegalValueException - is thrown when the value of the given Attribute is illegal (for instance when it is null).
ConstraintViolationException - is thrown when the value of the given Attribute violates the constraint of the Attribute to set.
IllegalNameException - is thrown if the given attribute has an invalid name.

getParentContainer

public GraphObjectContainer getParentContainer()
This method returns the GraphObjectContainer this GraphObject instance currently resides in. In case this GraphObject instance is not added to a GraphObjectContainer this method returns null.

Returns:
GraphObjectContainer the parent container of this GraphObject instance or null.

Find more information in the class documentation


registerEventMediator

public void registerEventMediator(GraphEventMediator mediator)
Registers the GraphEventMediator object given by mediator to the GraphObject. Subsequently the mediator will be informed about all events that occurs at the GraphObject.

This method is a framework internal method. Invoking this method by clients of the API is prohibited.

Parameters:
mediator - the GraphEventMediator to register

registerEventMediatorInternal

public void registerEventMediatorInternal(GraphEventMediator mediatorInternal)
Registers the GraphEventMediator object given by mediator to the GraphObject. Subsequently the mediator will be informed about all events that occurs at the GraphObject.

This method is a framework internal method. Invoking this method by clients of the API is prohibited.

Parameters:
mediatorInternal - the GraphEventMediator to register.

registerVetoableEventMediator

public void registerVetoableEventMediator(VetoableGraphEventMediator vmediator)
Registers the VetoableGraphEventMediator object given by vmediator to the GraphObject. Subsequently the vmediator will be informed about all vetoable events that occurs at the GraphObject.
Notice that this method is an internal method used by the framework and forceful recommended not to work with!!

Parameters:
vmediator - the GraphEventMediator to register

fillInDump

public void fillInDump(java.util.List list,
                       int level)
Fills in a dump into the given list. Each entry in the list is interpreted as a single line of output.

Parameters:
list - the list to fill the dump into.
level - the current depth of the dump.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.