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 voidaddEdgeAttributeType(String id, Class<? extends Attribute> type)static voidaddNodeAttributeType(String id, Class<? extends Attribute> type)AttributablegetAttributable()Returns theAttribute'sAttributable.StringgetDescription()Returns a description for this attribute.JComponentgetIcon()StringgetId()Returns theAttribute's identifier.StringgetName()Returns the name of this object.CollectionAttributegetParent()Returns theAttribute's parent,nullif it is root.StringgetPath()Returns theAttribute's location.static AttributegetTypedAttribute(String id, boolean isNodeTrue_isEdgeFalse)booleanisDeleted()static booleanisTypedAttributeFromID(String id, boolean isNodeTrue_isEdgeFalse)voidsetDeleted(boolean deleted)voidsetDescription(String desc)Provides a description for this attribute.voidsetId(String id)voidsetParent(CollectionAttribute parent)Sets the attribute's parent.voidsetValue(Object v)Sets the value of thisAttributeto the given value.StringtoString()Returns the ID of this attribute.StringtoString(int n)Returns a string representation prepended bynspaces of this attribute.StringtoXMLString()Returns a well-formed XML string representing the Displayable.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
getAttributablein interfaceAttribute- Returns:
- the
Attribute'sAttributable.
-
setDescription
Provides a description for this attribute. Used in tooltips etc.- Specified by:
setDescriptionin interfaceDisplayable- Parameters:
desc- DOCUMENT ME!
-
getDescription
Returns a description for this attribute. Used in tooltips etc. Returns an empty string by default.- Specified by:
getDescriptionin interfaceDisplayable- Returns:
- DOCUMENT ME!
-
getId
Returns theAttribute's identifier. -
getName
Description copied from interface:DisplayableReturns the name of this object.- Specified by:
getNamein 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! TheListenerManageris already informed by the callingaddAttributemethod that theAttributeis now added to the hierarchy. Therefore no event is generated by this method.- Specified by:
setParentin interfaceAttribute- Parameters:
parent- the new parent of theAttribute.- Throws:
FieldAlreadySetException- DOCUMENT ME!
-
getParent
Returns theAttribute's parent,nullif 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 thisAttributeto 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:
setValuein interfaceAttribute- Specified by:
setValuein 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:AttributeReturns a string representation prepended bynspaces of this attribute.- Specified by:
toStringin interfaceAttribute- Returns:
- DOCUMENT ME!
- See Also:
Attribute.toString(int)
-
toXMLString
Description copied from interface:DisplayableReturns 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:
toXMLStringin interfaceDisplayable- Returns:
- string holding an XML representation of this Displayable
- See Also:
Displayable.toXMLString()
-
getIcon
- Specified by:
getIconin interfaceDisplayable
-
isDeleted
public boolean isDeleted() -
setDeleted
public void setDeleted(boolean deleted)- Specified by:
setDeletedin interfaceAttribute
-