org.graffiti.attributes
Class AbstractAttribute

java.lang.Object
  extended by org.graffiti.attributes.AbstractAttribute
All Implemented Interfaces:
Attribute, DeepCopy, Displayable<Object>
Direct Known Subclasses:
AbstractCollectionAttribute, BooleanAttribute, ByteAttribute, CompositeAttribute, DoubleAttribute, FloatAttribute, IntegerAttribute, LongAttribute, ObjectAttribute, ShortAttribute, StringAttribute

public abstract class AbstractAttribute
extends Object
implements Attribute, DeepCopy

Provides common functionality for classes implementing the Attribute interface. Stores the id, parent and attributable of the Attribute.

Version:
$Revision: 5779 $

Field Summary
 
Fields inherited from interface org.graffiti.attributes.Attribute
SEPARATOR
 
Constructor Summary
AbstractAttribute(String id)
          Constructor for setting the id of an AbstractAttribute.
 
Method Summary
 Attributable getAttributable()
          Returns the Attribute's Attributable.
 String getDescription()
          Returns a description for this attribute.
 String getId()
          Returns the Attribute's identifier.
 String getName()
          Returns the name of this object.
 CollectionAttribute getParent()
          Returns the Attribute's parent, null if it is root.
 String getPath()
          Returns the Attribute's location.
 void setDescription(String desc)
          Provides a description for this attribute.
 void setParent(CollectionAttribute parent)
          Sets the attribute's parent.
 void setValue(Object v)
          Sets the value of this Attribute to the given value.
 String toString()
          Returns the ID of this attribute.
 String toString(int n)
          Returns a string representation prepended by n 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
 
Methods inherited from interface org.graffiti.core.DeepCopy
copy
 

Constructor Detail

AbstractAttribute

public AbstractAttribute(String id)
                  throws IllegalIdException
Constructor for setting the id of an AbstractAttribute.

Parameters:
id - the id of the AbstractAttribute.
Throws:
IllegalIdException - if the given id contains a separator.
Method Detail

getAttributable

public Attributable getAttributable()
Returns the Attribute's Attributable.

Specified by:
getAttributable in interface Attribute
Returns:
the Attribute's Attributable.

setDescription

public void setDescription(String desc)
Provides a description for this attribute. Used in tooltips etc.

Specified by:
setDescription in interface Displayable<Object>
Parameters:
desc - DOCUMENT ME!

getDescription

public String getDescription()
Returns a description for this attribute. Used in tooltips etc. Returns an empty string by default.

Specified by:
getDescription in interface Displayable<Object>
Returns:
DOCUMENT ME!

getId

public String getId()
Returns the Attribute's identifier.

Specified by:
getId in interface Attribute
Returns:
the Attribute's identifier.

getName

public String getName()
Description copied from interface: Displayable
Returns the name of this object.

Specified by:
getName in interface Displayable<Object>
Returns:
String
See Also:
Displayable.getName()

setParent

public void setParent(CollectionAttribute parent)
               throws FieldAlreadySetException
Sets the attribute's parent.

Implementation Notes: This method should only be called once and only by an addAttribute() method! The ListenerManager is already informed by the calling addAttribute method that the Attribute is now added to the hierarchy. Therefore no event is generated by this method.

Specified by:
setParent in interface Attribute
Parameters:
parent - the new parent of the Attribute.
Throws:
FieldAlreadySetException - DOCUMENT ME!

getParent

public CollectionAttribute getParent()
Returns the Attribute's parent, null if it is root.

Specified by:
getParent in interface Attribute
Returns:
the Attribute's parent, null if it is root.

getPath

public String getPath()
Returns the Attribute's location.

Implementation Note: This function constructs the path by ascending recursivly to the root attribute, using the getParent() and getId() methods,

Specified by:
getPath in interface Attribute
Returns:
the path to the given Attribute.

setValue

public void setValue(Object v)
              throws IllegalArgumentException
Sets the value of this Attribute to the given value. If the value is set via att.setValue(x) and then retrieved via y=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 interface Attribute
Specified by:
setValue in interface Displayable<Object>
Parameters:
v - the new value.
Throws:
IllegalArgumentException - if v is not of the apropriate type.

toString

public String toString()
Returns the ID of this attribute.

Overrides:
toString in class Object
Returns:
DOCUMENT ME!

toString

public String toString(int n)
Description copied from interface: Attribute
Returns a string representation prepended by n spaces of this attribute.

Specified by:
toString in interface Attribute
Returns:
DOCUMENT ME!
See Also:
Attribute.toString(int)

toXMLString

public String 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 interface Displayable<Object>
Returns:
string holding an XML representation of this Displayable
See Also:
Displayable.toXMLString()


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