Package org.graffiti.attributes
Class AbstractAttributable
java.lang.Object
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: 1.7 $
- See Also:
Attributable
-
Constructor Summary
Constructors Constructor Description AbstractAttributable()Constructs a newAbstractAttributeinstance.AbstractAttributable(CollectionAttribute coll)Constructs a newAbstractAttributeinstance. -
Method Summary
Modifier and Type Method Description voidaddAttribute(Attribute attr, String path)Addsattrto the attributes at position indicated by path.voidaddBoolean(String path, String id, boolean value)Adds anBooleanAttributewith the given value and id to aCollectionAttributeatpath.voidaddByte(String path, String id, byte value)Adds anByteAttributewith the given value and id to aCollectionAttributeatpath.voidaddDouble(String path, String id, double value)Adds aDoubleAttributewith the given value and id to aCollectionAttributeatpath.voidaddFloat(String path, String id, float value)Adds aFloatAttributewith the given value and id to aCollectionAttributeatpath.voidaddInteger(String path, String id, int value)Adds anIntegerAttributewith the given value and id to aCollectionAttributeatpath.voidaddLong(String path, String id, long value)Adds anLongAttributewith the given value and id to aCollectionAttributeatpath.voidaddShort(String path, String id, short value)Adds anShortAttributewith the given value and id to aCollectionAttributeatpath.voidaddString(String path, String id, String value)Adds aStringAttributewith the given value and id to aCollectionAttributeatpath.voidchangeBoolean(String path, boolean value)Changes theAttributeat the given path to the given value.voidchangeByte(String path, byte value)Changes theAttributeat the given path to the given value.voidchangeDouble(String path, double value)Changes theAttributeat the given path to the given value.voidchangeFloat(String path, float value)Sets theAttributeat the given path to the given value.voidchangeInteger(String path, int value)Changes theAttributeat the given path to the given value.voidchangeLong(String path, long value)Changes theAttributeat the given path to the given value.voidchangeShort(String path, short value)Changes theAttributeat the given path to the given value.voidchangeString(String path, String value)Changes theAttributeat the given path to the given value.AttributegetAttribute(String path)Returns theAttributeof the given path.CollectionAttributegetAttributes()Returns the root CollectionAttribute which contains the attributes of the current object.booleangetBoolean(String path)Returns the value of theAttributeat the given path.bytegetByte(String path)Returns the value of theAttributeat the given path.doublegetDouble(String path)Returns the value of theAttributeat the given path.floatgetFloat(String path)Returns the value of theAttributeat the given path.intgetInteger(String path)Returns the value of theAttributeat the given path.longgetLong(String path)Returns the value of theAttributeat the given path.shortgetShort(String path)Returns the value of theAttributeat the given path.StringgetString(String path)Returns the value of theAttributeat the given path.AttributeremoveAttribute(String path)Deletes theAttributeattr from the attributes.voidsetBoolean(String path, boolean value)Sets theAttributeat the given path to the given value.voidsetByte(String path, byte value)Sets theAttributeat the given path to the given value.voidsetDouble(String path, double value)Sets theAttributeat the given path to the given value.voidsetFloat(String path, float value)Sets theAttributeat the given path to the given value.voidsetInteger(String path, int value)Sets theAttributeat the given path to the given value.voidsetLong(String path, long value)Sets theAttributeat the given path to the given value.voidsetShort(String path, short value)Sets theAttributeat the given path to the given value.voidsetString(String path, String value)Sets theAttributeat the given path to the given value.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.graffiti.attributes.Attributable
getListenerManager
-
Constructor Details
-
AbstractAttributable
public AbstractAttributable()Constructs a newAbstractAttributeinstance. Instantiates itsCollectionAttribute. -
AbstractAttributable
Constructs a newAbstractAttributeinstance.- Parameters:
coll- theCollectionAttributeof the newAbstractAttributableinstance.
-
-
Method Details
-
getAttribute
Returns theAttributeof the given path.- Specified by:
getAttributein interfaceAttributable- Parameters:
path- the path to theAttribute.- Returns:
- the
Attributeat the specified location. - Throws:
AttributeNotFoundException- if there is noAttributeat the location specified bypath.
-
getAttributes
Returns the root CollectionAttribute which contains the attributes of the current object.- Specified by:
getAttributesin interfaceAttributable- Returns:
- the attributes of the current object.
-
setBoolean
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setBooleanin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.
-
getBoolean
Returns the value of theAttributeat the given path.- Specified by:
getBooleanin interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- The value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setByte
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setBytein interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.
-
getByte
Returns the value of theAttributeat the given path.- Specified by:
getBytein interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- The value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setDouble
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)in CollectionAttribute and methodsetValue(Object o)inAttribute. 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:
setDoublein interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set to theAttributeto.
-
getDouble
Returns the value of theAttributeat the given path.- Specified by:
getDoublein interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- the value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setFloat
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setFloatin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set to theAttributeto.
-
getFloat
Returns the value of theAttributeat the given path.- Specified by:
getFloatin interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- the value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setInteger
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setIntegerin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.
-
getInteger
Returns the value of theAttributeat the given path.- Specified by:
getIntegerin interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- the vlaue of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setLong
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setLongin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.
-
getLong
Returns the value of theAttributeat the given path.- Specified by:
getLongin interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- The value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setShort
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setShortin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.
-
getShort
Returns the value of theAttributeat the given path.- Specified by:
getShortin interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- The value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
setString
Sets theAttributeat the given path to the given value. TheAttributeis created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls of methodadd(Attribute a)inCollectionAttributeand methodsetValue(Object o)inAttribute. 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:
setStringin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set to theAttributeto.
-
getString
Returns the value of theAttributeat the given path.- Specified by:
getStringin interfaceAttributable- Parameters:
path- the path to search for theAttribute.- Returns:
- the value of the
Attributeat the given path. - Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
addAttribute
public void addAttribute(Attribute attr, String path) throws AttributeExistsException, NoCollectionAttributeException, FieldAlreadySetExceptionAddsattrto the attributes at position indicated by path. Informs theListenerManagerabout the change by using theadd(Attribute a)method fromCollectionAttribute.Implementation Notes:
pathspecifies the location of theCollectionAttributeor (in casepathis the empty string) the Attributableattrshould 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:
addAttributein interfaceAttributable- Parameters:
attr- theAttributeto be added.path- DOCUMENT ME!- Throws:
AttributeExistsException- if there is already anAttributewith the sameidasattrat locationpath.NoCollectionAttributeException- if theAttributeat locationpathis not a CollectionAttribute.FieldAlreadySetException- DOCUMENT ME!
-
addBoolean
public void addBoolean(String path, String id, boolean value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anBooleanAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addBooleanin interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newBooleanAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addByte
public void addByte(String path, String id, byte value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anByteAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addBytein interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newByteAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addDouble
public void addDouble(String path, String id, double value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds aDoubleAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addDoublein interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newDoubleAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addFloat
public void addFloat(String path, String id, float value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds aFloatAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addFloatin interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newFloatAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addInteger
public void addInteger(String path, String id, int value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anIntegerAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addIntegerin interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newIntegerAttributeshould be added to.id- the id of the newIntegerAttribute.value- the value of the newIntegerAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already an attribute with the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addLong
public void addLong(String path, String id, long value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anLongAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addLongin interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newLongAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addShort
public void addShort(String path, String id, short value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anShortAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addShortin interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newShortAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
addString
public void addString(String path, String id, String value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds aStringAttributewith the given value and id to aCollectionAttributeatpath. Events are generated by using theadd(Attribute a)method fromCollectionAttribute.- Specified by:
addStringin interfaceAttributable- Parameters:
path- the path to theCollectionAttributethe newStringAttributeshould be added to.id- the id of the newly createdAttribute.value- the value of the newly createdAttribute.- Throws:
NoCollectionAttributeException- if theAttributeat the location specified bypathis noCollectionAttribute.AttributeExistsException- if there is already anAttributewith the givenidat the givenpath.FieldAlreadySetException- DOCUMENT ME!
-
changeBoolean
Changes theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromBooleanAttribute.- Specified by:
changeBooleanin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeByte
Changes theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromByteAttribute.- Specified by:
changeBytein interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeDouble
Changes theAttributeat the given path to the given value. Events are generated by using thesetDouble(double value)method fromDoubleAttribute.- Specified by:
changeDoublein interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set to theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeFloat
Sets theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromFloatAttribute.- Specified by:
changeFloatin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set to theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeInteger
Changes theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromIntegerAttribute.- Specified by:
changeIntegerin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeLong
Changes theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromLongAttribute.- Specified by:
changeLongin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeShort
Changes theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromShortAttribute.- Specified by:
changeShortin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
changeString
Changes theAttributeat the given path to the given value. Events are generated by using thesetInteger(int value)method fromStringAttribute.- Specified by:
changeStringin interfaceAttributable- Parameters:
path- the path to search for theAttribute.value- the value to set to theAttributeto.- Throws:
AttributeNotFoundException- if there is noAttributeat the specified location.
-
removeAttribute
Deletes theAttributeattr from the attributes. Informs theListenerManagerabout the change by using theremove(Attribute a)method fromCollectionAttribute.- Specified by:
removeAttributein interfaceAttributable- Parameters:
path- the relative path of theAttributeto be removed.- Returns:
- the removed attribute
- Throws:
AttributeNotFoundException- if there is noAttributeat the location specified bypath.
-