org.graffiti.attributes
Class AbstractAttributable

java.lang.Object
  extended by org.graffiti.attributes.AbstractAttributable
All Implemented Interfaces:
Attributable
Direct Known Subclasses:
AbstractGraph, AbstractGraphElement

public abstract class AbstractAttributable
extends Object
implements Attributable

Provides common functionality for Attributable classes. This class also contains additional functionality for dealing with attributes.

Version:
$Revision: 5767 $
See Also:
Attributable

Constructor Summary
AbstractAttributable()
          Constructs a new AbstractAttribute instance.
AbstractAttributable(CollectionAttribute coll)
          Constructs a new AbstractAttribute instance.
 
Method Summary
 void addAttribute(Attribute attr, String path)
          Adds attr to the attributes at position indicated by path.
 void addBoolean(String path, String id, boolean value)
          Adds an BooleanAttribute with the given value and id to a CollectionAttribute at path.
 void addByte(String path, String id, byte value)
          Adds an ByteAttribute with the given value and id to a CollectionAttribute at path.
 void addDouble(String path, String id, double value)
          Adds a DoubleAttribute with the given value and id to a CollectionAttribute at path.
 void addFloat(String path, String id, float value)
          Adds a FloatAttribute with the given value and id to a CollectionAttribute at path.
 void addInteger(String path, String id, int value)
          Adds an IntegerAttribute with the given value and id to a CollectionAttribute at path.
 void addLong(String path, String id, long value)
          Adds an LongAttribute with the given value and id to a CollectionAttribute at path.
 void addShort(String path, String id, short value)
          Adds an ShortAttribute with the given value and id to a CollectionAttribute at path.
 void addString(String path, String id, String value)
          Adds a StringAttribute with the given value and id to a CollectionAttribute at path.
 void changeBoolean(String path, boolean value)
          Changes the Attribute at the given path to the given value.
 void changeByte(String path, byte value)
          Changes the Attribute at the given path to the given value.
 void changeDouble(String path, double value)
          Changes the Attribute at the given path to the given value.
 void changeFloat(String path, float value)
          Sets the Attribute at the given path to the given value.
 void changeInteger(String path, int value)
          Changes the Attribute at the given path to the given value.
 void changeLong(String path, long value)
          Changes the Attribute at the given path to the given value.
 void changeShort(String path, short value)
          Changes the Attribute at the given path to the given value.
 void changeString(String path, String value)
          Changes the Attribute at the given path to the given value.
 boolean containsAttribute(String path)
          Returns if the given path contains an Attribute of any kind.
 Attribute getAttribute(String path)
          Returns the Attribute of the given path.
 CollectionAttribute getAttributes()
          Returns the root CollectionAttribute which contains the attributes of the current object.
 boolean getBoolean(String path)
          Returns the value of the Attribute at the given path.
 byte getByte(String path)
          Returns the value of the Attribute at the given path.
 double getDouble(String path)
          Returns the value of the Attribute at the given path.
 float getFloat(String path)
          Returns the value of the Attribute at the given path.
 int getInteger(String path)
          Returns the value of theAttributeat the given path.
 long getLong(String path)
          Returns the value of the Attribute at the given path.
 short getShort(String path)
          Returns the value of the Attribute at the given path.
 String getString(String path)
          Returns the value of the Attribute at the given path.
 void removeAttribute(String path)
          Deletes the Attribute attr from the attributes.
 void setBoolean(String path, boolean value)
          Sets the Attribute at the given path to the given value.
 void setByte(String path, byte value)
          Sets the Attribute at the given path to the given value.
 void setDouble(String path, double value)
          Sets the Attribute at the given path to the given value.
 void setFloat(String path, float value)
          Sets the Attribute at the given path to the given value.
 void setInteger(String path, int value)
          Sets the Attribute at the given path to the given value.
 void setLong(String path, long value)
          Sets the Attribute at the given path to the given value.
 void setShort(String path, short value)
          Sets the Attribute at the given path to the given value.
 void setString(String path, String value)
          Sets the Attribute at the given path to the given value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.graffiti.attributes.Attributable
getListenerManager
 

Constructor Detail

AbstractAttributable

public AbstractAttributable()
Constructs a new AbstractAttribute instance. Instantiates its CollectionAttribute.


AbstractAttributable

public AbstractAttributable(CollectionAttribute coll)
Constructs a new AbstractAttribute instance.

Parameters:
coll - the CollectionAttribute of the new AbstractAttributable instance.
Method Detail

getAttribute

public Attribute getAttribute(String path)
                       throws AttributeNotFoundException
Returns the Attribute of the given path.

Specified by:
getAttribute in interface Attributable
Parameters:
path - the path to theAttribute.
Returns:
the Attribute at the specified location.
Throws:
AttributeNotFoundException - if there is no Attribute at the location specified by path.

getAttributes

public CollectionAttribute getAttributes()
Returns the root CollectionAttribute which contains the attributes of the current object.

Specified by:
getAttributes in interface Attributable
Returns:
the attributes of the current object.

setBoolean

public void setBoolean(String path,
                       boolean value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setBoolean in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.

getBoolean

public boolean getBoolean(String path)
                   throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getBoolean in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
The value of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setByte

public void setByte(String path,
                    byte value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setByte in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.

getByte

public byte getByte(String path)
             throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getByte in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
The value of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setDouble

public void setDouble(String path,
                      double value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setDouble in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set to the Attribute to.

getDouble

public double getDouble(String path)
                 throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getDouble in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
the value of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setFloat

public void setFloat(String path,
                     float value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setFloat in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set to the Attribute to.

getFloat

public float getFloat(String path)
               throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getFloat in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
the vlaue of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setInteger

public void setInteger(String path,
                       int value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setInteger in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.

getInteger

public int getInteger(String path)
               throws AttributeNotFoundException
Returns the value of theAttributeat the given path.

Specified by:
getInteger in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
the vlaue of theAttributeat the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setLong

public void setLong(String path,
                    long value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setLong in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.

getLong

public long getLong(String path)
             throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getLong in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
The value of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setShort

public void setShort(String path,
                     short value)
Sets the Attribute at the given path to the given value. The Attribute is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setShort in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.

getShort

public short getShort(String path)
               throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getShort in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
The value of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

setString

public void setString(String path,
                      String value)
Sets the Attribute at the given path to the given value. The Attributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls of method add(Attribute a) in CollectionAttribute and method setValue(Object o) in Attribute. If more than one attributes have to be created while stepping down the path, only one event is generated, containing the attribute that has been created first (i.e. the root attribute of the newly appended hierarchy).

Specified by:
setString in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set to theAttributeto.

getString

public String getString(String path)
                 throws AttributeNotFoundException
Returns the value of the Attribute at the given path.

Specified by:
getString in interface Attributable
Parameters:
path - the path to search for the Attribute.
Returns:
the value of the Attribute at the given path.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

addAttribute

public void addAttribute(Attribute attr,
                         String path)
                  throws AttributeExistsException,
                         NoCollectionAttributeException,
                         FieldAlreadySetException
Adds attr to the attributes at position indicated by path. Informs the ListenerManager about the change by using the add(Attribute a) method from CollectionAttribute.

Implementation Notes:path specifies the location of the CollectionAttribute or (in case path is the empty string) the Attributable attr should be added to. Usage should look as follows:

         Graph g = new Graph(..);
         CollectionAttribute ca = new CollectionAttribute("root");
         //add ca to the attributable g as root attribute
         g.addAttribute(ca, "");
         IntegerAttribute ia = new IntegerAttribute("int", 10);
         //add ia as child of root
         g.addAttribute(ia, "root");
 

Specified by:
addAttribute in interface Attributable
Parameters:
attr - the Attribute to be added.
path - DOCUMENT ME!
Throws:
AttributeExistsException - if there is already an Attribute with the same id as attr at location path.
NoCollectionAttributeException - if theAttribute at location path is not a CollectionAttribute.
FieldAlreadySetException - DOCUMENT ME!

addBoolean

public void addBoolean(String path,
                       String id,
                       boolean value)
                throws NoCollectionAttributeException,
                       AttributeExistsException,
                       FieldAlreadySetException
Adds an BooleanAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addBoolean in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new BooleanAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addByte

public void addByte(String path,
                    String id,
                    byte value)
             throws NoCollectionAttributeException,
                    AttributeExistsException,
                    FieldAlreadySetException
Adds an ByteAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addByte in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new ByteAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addDouble

public void addDouble(String path,
                      String id,
                      double value)
               throws NoCollectionAttributeException,
                      AttributeExistsException,
                      FieldAlreadySetException
Adds a DoubleAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addDouble in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new DoubleAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addFloat

public void addFloat(String path,
                     String id,
                     float value)
              throws NoCollectionAttributeException,
                     AttributeExistsException,
                     FieldAlreadySetException
Adds a FloatAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addFloat in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new FloatAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if theAttribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addInteger

public void addInteger(String path,
                       String id,
                       int value)
                throws NoCollectionAttributeException,
                       AttributeExistsException,
                       FieldAlreadySetException
Adds an IntegerAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addInteger in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new IntegerAttribute should be added to.
id - the id of the new IntegerAttribute.
value - the value of the new IntegerAttribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addLong

public void addLong(String path,
                    String id,
                    long value)
             throws NoCollectionAttributeException,
                    AttributeExistsException,
                    FieldAlreadySetException
Adds an LongAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addLong in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new LongAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addShort

public void addShort(String path,
                     String id,
                     short value)
              throws NoCollectionAttributeException,
                     AttributeExistsException,
                     FieldAlreadySetException
Adds an ShortAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addShort in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new ShortAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

addString

public void addString(String path,
                      String id,
                      String value)
               throws NoCollectionAttributeException,
                      AttributeExistsException,
                      FieldAlreadySetException
Adds a StringAttribute with the given value and id to a CollectionAttribute at path. Events are generated by using the add(Attribute a) method from CollectionAttribute.

Specified by:
addString in interface Attributable
Parameters:
path - the path to the CollectionAttribute the new StringAttribute should be added to.
id - the id of the newly created Attribute.
value - the value of the newly created Attribute.
Throws:
NoCollectionAttributeException - if the Attribute at the location specified by path is no CollectionAttribute.
AttributeExistsException - if there is already an Attribute with the given id at the given path.
FieldAlreadySetException - DOCUMENT ME!

changeBoolean

public void changeBoolean(String path,
                          boolean value)
                   throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from BooleanAttribute.

Specified by:
changeBoolean in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeByte

public void changeByte(String path,
                       byte value)
                throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from ByteAttribute.

Specified by:
changeByte in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeDouble

public void changeDouble(String path,
                         double value)
                  throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setDouble(double value) method from DoubleAttribute.

Specified by:
changeDouble in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set to the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeFloat

public void changeFloat(String path,
                        float value)
                 throws AttributeNotFoundException
Sets the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from FloatAttribute.

Specified by:
changeFloat in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set to the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeInteger

public void changeInteger(String path,
                          int value)
                   throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from IntegerAttribute.

Specified by:
changeInteger in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeLong

public void changeLong(String path,
                       long value)
                throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from LongAttribute.

Specified by:
changeLong in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeShort

public void changeShort(String path,
                        short value)
                 throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from ShortAttribute.

Specified by:
changeShort in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

changeString

public void changeString(String path,
                         String value)
                  throws AttributeNotFoundException
Changes the Attribute at the given path to the given value. Events are generated by using the setInteger(int value) method from StringAttribute.

Specified by:
changeString in interface Attributable
Parameters:
path - the path to search for the Attribute.
value - the value to set to the Attribute to.
Throws:
AttributeNotFoundException - if there is no Attribute at the specified location.

removeAttribute

public void removeAttribute(String path)
                     throws AttributeNotFoundException
Deletes the Attribute attr from the attributes. Informs the ListenerManager about the change by using the remove(Attribute a) method from CollectionAttribute.

Specified by:
removeAttribute in interface Attributable
Parameters:
path - the relative path of theAttributeto be removed.
Throws:
AttributeNotFoundException - if there is no Attribute at the location specified by path.

containsAttribute

public boolean containsAttribute(String path)
Returns if the given path contains an Attribute of any kind.

Specified by:
containsAttribute in interface Attributable
Parameters:
path - The path of the Attribute to be tested.
Returns:
true, if an Attribute is saved in the given path, false otherwise.


Generated at 2012-05-30 11:00:14 PM CEST