Package org.graffiti.attributes
Class AbstractAttribute
java.lang.Object
org.graffiti.attributes.AbstractAttribute
- All Implemented Interfaces:
Attribute
,DeepCopy
,Displayable
- Direct Known Subclasses:
AbstractCollectionAttribute
,BooleanAttribute
,ByteAttribute
,CompositeAttribute
,DoubleAttribute
,FloatAttribute
,IndexAttribute
,IntegerAttribute
,LongAttribute
,ShortAttribute
,StringAttribute
public abstract class AbstractAttribute extends Object implements Attribute
Provides common functionality for classes implementing the
Attribute
interface. Stores the id
,
parent
and attributable
of the
Attribute
.- Version:
- $Revision: 1.15 $
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractAttribute()
AbstractAttribute(String id)
Constructor for setting the id of anAbstractAttribute
. -
Method Summary
Modifier and Type Method Description static void
addEdgeAttributeType(String id, Class<? extends Attribute> type)
static void
addNodeAttributeType(String id, Class<? extends Attribute> type)
Attributable
getAttributable()
Returns theAttribute
'sAttributable
.String
getDescription()
Returns a description for this attribute.JComponent
getIcon()
String
getId()
Returns theAttribute
's identifier.String
getName()
Returns the name of this object.CollectionAttribute
getParent()
Returns theAttribute
's parent,null
if it is root.String
getPath()
Returns theAttribute
's location.static Attribute
getTypedAttribute(String id, boolean isNodeTrue_isEdgeFalse)
boolean
isDeleted()
static boolean
isTypedAttributeFromID(String id, boolean isNodeTrue_isEdgeFalse)
void
setDeleted(boolean deleted)
void
setDescription(String desc)
Provides a description for this attribute.void
setId(String id)
void
setParent(CollectionAttribute parent)
Sets the attribute's parent.void
setValue(Object v)
Sets the value of thisAttribute
to the given value.String
toString()
Returns the ID of this attribute.String
toString(int n)
Returns a string representation prepended byn
spaces of this attribute.String
toXMLString()
Returns a well-formed XML string representing the Displayable.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.graffiti.attributes.Attribute
getValue, setDefaultValue
-
Constructor Details
-
AbstractAttribute
Constructor for setting the id of anAbstractAttribute
.- Parameters:
id
- the id of theAbstractAttribute
.- Throws:
IllegalIdException
- if the given id contains a separator.
-
AbstractAttribute
public AbstractAttribute()
-
-
Method Details
-
setId
-
addNodeAttributeType
-
addEdgeAttributeType
-
getTypedAttribute
-
isTypedAttributeFromID
-
getAttributable
Returns theAttribute
'sAttributable
.- Specified by:
getAttributable
in interfaceAttribute
- Returns:
- the
Attribute
'sAttributable
.
-
setDescription
Provides a description for this attribute. Used in tooltips etc.- Specified by:
setDescription
in interfaceDisplayable
- Parameters:
desc
- DOCUMENT ME!
-
getDescription
Returns a description for this attribute. Used in tooltips etc. Returns an empty string by default.- Specified by:
getDescription
in interfaceDisplayable
- Returns:
- DOCUMENT ME!
-
getId
Returns theAttribute
's identifier. -
getName
Description copied from interface:Displayable
Returns the name of this object.- Specified by:
getName
in interfaceDisplayable
- Returns:
- String
- See Also:
Displayable.getName()
-
setParent
Sets the attribute's parent.Implementation Notes: This method should only be called once and only by an
addAttribute()
method! TheListenerManager
is already informed by the callingaddAttribute
method that theAttribute
is now added to the hierarchy. Therefore no event is generated by this method.- Specified by:
setParent
in interfaceAttribute
- Parameters:
parent
- the new parent of theAttribute
.- Throws:
FieldAlreadySetException
- DOCUMENT ME!
-
getParent
Returns theAttribute
's parent,null
if it is root. -
getPath
Returns theAttribute
's location.Implementation Note: This function constructs the path by ascending recursivly to the root attribute, using the
getParent()
andgetId()
methods, -
setValue
Sets the value of thisAttribute
to the given value. If the value is set viaatt.setValue(x)
and then retrieved viay=att.getValue()
it is only guaranteed that x.equals(y) not x==y, i.e. some particular concret classes can provide x==y but this behaviour is not general, in contrast x.equals(y) must be always guaranteed.- Specified by:
setValue
in interfaceAttribute
- Specified by:
setValue
in interfaceDisplayable
- Parameters:
v
- the new value.- Throws:
IllegalArgumentException
- if v is not of the apropriate type.
-
toString
Returns the ID of this attribute. -
toString
Description copied from interface:Attribute
Returns a string representation prepended byn
spaces of this attribute.- Specified by:
toString
in interfaceAttribute
- Returns:
- DOCUMENT ME!
- See Also:
Attribute.toString(int)
-
toXMLString
Description copied from interface:Displayable
Returns a well-formed XML string representing the Displayable. The Displayable should be reconstructable via this representation. Therefore it must at least include the type of Displayable (classname) and a representation of its value. PROBABLE FUTURE DESIGN: The Displayables themselves will provide a method to reconstruct their value from the XML representation they provided.- Specified by:
toXMLString
in interfaceDisplayable
- Returns:
- string holding an XML representation of this Displayable
- See Also:
Displayable.toXMLString()
-
getIcon
- Specified by:
getIcon
in interfaceDisplayable
-
isDeleted
public boolean isDeleted() -
setDeleted
public void setDeleted(boolean deleted)- Specified by:
setDeleted
in interfaceAttribute
-