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 newAbstractAttribute
instance.AbstractAttributable(CollectionAttribute coll)
Constructs a newAbstractAttribute
instance. -
Method Summary
Modifier and Type Method Description void
addAttribute(Attribute attr, String path)
Addsattr
to the attributes at position indicated by path.void
addBoolean(String path, String id, boolean value)
Adds anBooleanAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addByte(String path, String id, byte value)
Adds anByteAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addDouble(String path, String id, double value)
Adds aDoubleAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addFloat(String path, String id, float value)
Adds aFloatAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addInteger(String path, String id, int value)
Adds anIntegerAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addLong(String path, String id, long value)
Adds anLongAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addShort(String path, String id, short value)
Adds anShortAttribute
with the given value and id to aCollectionAttribute
atpath
.void
addString(String path, String id, String value)
Adds aStringAttribute
with the given value and id to aCollectionAttribute
atpath
.void
changeBoolean(String path, boolean value)
Changes theAttribute
at the given path to the given value.void
changeByte(String path, byte value)
Changes theAttribute
at the given path to the given value.void
changeDouble(String path, double value)
Changes theAttribute
at the given path to the given value.void
changeFloat(String path, float value)
Sets theAttribute
at the given path to the given value.void
changeInteger(String path, int value)
Changes theAttribute
at the given path to the given value.void
changeLong(String path, long value)
Changes theAttribute
at the given path to the given value.void
changeShort(String path, short value)
Changes theAttribute
at the given path to the given value.void
changeString(String path, String value)
Changes theAttribute
at the given path to the given value.Attribute
getAttribute(String path)
Returns theAttribute
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 theAttribute
at the given path.byte
getByte(String path)
Returns the value of theAttribute
at the given path.double
getDouble(String path)
Returns the value of theAttribute
at the given path.float
getFloat(String path)
Returns the value of theAttribute
at the given path.int
getInteger(String path)
Returns the value of theAttribute
at the given path.long
getLong(String path)
Returns the value of theAttribute
at the given path.short
getShort(String path)
Returns the value of theAttribute
at the given path.String
getString(String path)
Returns the value of theAttribute
at the given path.Attribute
removeAttribute(String path)
Deletes theAttribute
attr from the attributes.void
setBoolean(String path, boolean value)
Sets theAttribute
at the given path to the given value.void
setByte(String path, byte value)
Sets theAttribute
at the given path to the given value.void
setDouble(String path, double value)
Sets theAttribute
at the given path to the given value.void
setFloat(String path, float value)
Sets theAttribute
at the given path to the given value.void
setInteger(String path, int value)
Sets theAttribute
at the given path to the given value.void
setLong(String path, long value)
Sets theAttribute
at the given path to the given value.void
setShort(String path, short value)
Sets theAttribute
at the given path to the given value.void
setString(String path, String value)
Sets theAttribute
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 Details
-
AbstractAttributable
public AbstractAttributable()Constructs a newAbstractAttribute
instance. Instantiates itsCollectionAttribute
. -
AbstractAttributable
Constructs a newAbstractAttribute
instance.- Parameters:
coll
- theCollectionAttribute
of the newAbstractAttributable
instance.
-
-
Method Details
-
getAttribute
Returns theAttribute
of the given path.- Specified by:
getAttribute
in interfaceAttributable
- Parameters:
path
- the path to theAttribute
.- Returns:
- the
Attribute
at the specified location. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the location specified bypath
.
-
getAttributes
Returns the root CollectionAttribute which contains the attributes of the current object.- Specified by:
getAttributes
in interfaceAttributable
- Returns:
- the attributes of the current object.
-
setBoolean
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)
inCollectionAttribute
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:
setBoolean
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.
-
getBoolean
Returns the value of theAttribute
at the given path.- Specified by:
getBoolean
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- The value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setByte
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)
inCollectionAttribute
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:
setByte
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.
-
getByte
Returns the value of theAttribute
at the given path.- Specified by:
getByte
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- The value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setDouble
Sets theAttribute
at the given path to the given value. TheAttribute
is 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:
setDouble
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set to theAttribute
to.
-
getDouble
Returns the value of theAttribute
at the given path.- Specified by:
getDouble
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- the value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setFloat
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)
inCollectionAttribute
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:
setFloat
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set to theAttribute
to.
-
getFloat
Returns the value of theAttribute
at the given path.- Specified by:
getFloat
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- the value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setInteger
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)
inCollectionAttribute
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:
setInteger
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.
-
getInteger
Returns the value of theAttribute
at the given path.- Specified by:
getInteger
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- the vlaue of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setLong
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)
inCollectionAttribute
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:
setLong
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.
-
getLong
Returns the value of theAttribute
at the given path.- Specified by:
getLong
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- The value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setShort
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls to methodadd(Attribute a)
inCollectionAttribute
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:
setShort
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.
-
getShort
Returns the value of theAttribute
at the given path.- Specified by:
getShort
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- The value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
setString
Sets theAttribute
at the given path to the given value. TheAttribute
is created at the given location, if it does not yet exist. Appropriate (add and change) events are generated by calls of methodadd(Attribute a)
inCollectionAttribute
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:
setString
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set to theAttribute
to.
-
getString
Returns the value of theAttribute
at the given path.- Specified by:
getString
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.- Returns:
- the value of the
Attribute
at the given path. - Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
addAttribute
public void addAttribute(Attribute attr, String path) throws AttributeExistsException, NoCollectionAttributeException, FieldAlreadySetExceptionAddsattr
to the attributes at position indicated by path. Informs theListenerManager
about the change by using theadd(Attribute a)
method fromCollectionAttribute
.Implementation Notes:
path
specifies the location of theCollectionAttribute
or (in casepath
is the empty string) the Attributableattr
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 interfaceAttributable
- Parameters:
attr
- theAttribute
to be added.path
- DOCUMENT ME!- Throws:
AttributeExistsException
- if there is already anAttribute
with the sameid
asattr
at locationpath
.NoCollectionAttributeException
- if theAttribute
at locationpath
is not a CollectionAttribute.FieldAlreadySetException
- DOCUMENT ME!
-
addBoolean
public void addBoolean(String path, String id, boolean value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anBooleanAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addBoolean
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newBooleanAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addByte
public void addByte(String path, String id, byte value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anByteAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addByte
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newByteAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addDouble
public void addDouble(String path, String id, double value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds aDoubleAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addDouble
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newDoubleAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addFloat
public void addFloat(String path, String id, float value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds aFloatAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addFloat
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newFloatAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addInteger
public void addInteger(String path, String id, int value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anIntegerAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addInteger
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newIntegerAttribute
should be added to.id
- the id of the newIntegerAttribute
.value
- the value of the newIntegerAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already an attribute with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addLong
public void addLong(String path, String id, long value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anLongAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addLong
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newLongAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addShort
public void addShort(String path, String id, short value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds anShortAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addShort
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newShortAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
addString
public void addString(String path, String id, String value) throws NoCollectionAttributeException, AttributeExistsException, FieldAlreadySetExceptionAdds aStringAttribute
with the given value and id to aCollectionAttribute
atpath
. Events are generated by using theadd(Attribute a)
method fromCollectionAttribute
.- Specified by:
addString
in interfaceAttributable
- Parameters:
path
- the path to theCollectionAttribute
the newStringAttribute
should be added to.id
- the id of the newly createdAttribute
.value
- the value of the newly createdAttribute
.- Throws:
NoCollectionAttributeException
- if theAttribute
at the location specified bypath
is noCollectionAttribute
.AttributeExistsException
- if there is already anAttribute
with the givenid
at the givenpath
.FieldAlreadySetException
- DOCUMENT ME!
-
changeBoolean
Changes theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromBooleanAttribute
.- Specified by:
changeBoolean
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeByte
Changes theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromByteAttribute
.- Specified by:
changeByte
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeDouble
Changes theAttribute
at the given path to the given value. Events are generated by using thesetDouble(double value)
method fromDoubleAttribute
.- Specified by:
changeDouble
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set to theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeFloat
Sets theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromFloatAttribute
.- Specified by:
changeFloat
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set to theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeInteger
Changes theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromIntegerAttribute
.- Specified by:
changeInteger
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeLong
Changes theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromLongAttribute
.- Specified by:
changeLong
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeShort
Changes theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromShortAttribute
.- Specified by:
changeShort
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
changeString
Changes theAttribute
at the given path to the given value. Events are generated by using thesetInteger(int value)
method fromStringAttribute
.- Specified by:
changeString
in interfaceAttributable
- Parameters:
path
- the path to search for theAttribute
.value
- the value to set to theAttribute
to.- Throws:
AttributeNotFoundException
- if there is noAttribute
at the specified location.
-
removeAttribute
Deletes theAttribute
attr from the attributes. Informs theListenerManager
about the change by using theremove(Attribute a)
method fromCollectionAttribute
.- Specified by:
removeAttribute
in interfaceAttributable
- Parameters:
path
- the relative path of theAttribute
to be removed.- Returns:
- the removed attribute
- Throws:
AttributeNotFoundException
- if there is noAttribute
at the location specified bypath
.
-