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
protected  String id
          The identifier of this Attribute.
 
Fields inherited from interface org.graffiti.attributes.Attribute
SEPARATOR
 
Constructor Summary
AbstractAttribute(String id)
          Constructor for setting the id of an AbstractAttribute.
 
Method Summary
protected  void callPostAttributeAdded(AttributeEvent ae)
          Informs the ListenerManager after an Attribute has been added.
protected  void callPostAttributeChanged(AttributeEvent ae)
          Informs the ListenerManager after the value of an Attribute has been changed.
protected  void callPostAttributeRemoved(AttributeEvent ae)
          Informs the ListenerManager after an Attribute has been removed.
protected  void callPreAttributeAdded(AttributeEvent ae)
          Informs the ListenerManager before an Attribute will be added.
protected  void callPreAttributeChanged(AttributeEvent ae)
          Informs the ListenerManager before the value of an Attribute will be changed.
protected  void callPreAttributeRemoved(AttributeEvent ae)
          Informs the ListenerManager before an Attribute will be removed.
protected abstract  void doSetValue(Object v)
          Sets the value of this Attribute to the given value without informing the ListenerManager.
 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.
protected  String getSpaces(int n)
          Returns n spaces.
protected  String getStandardXML(String valueString)
          Embeds the given String into an XML String.
 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
clone, equals, finalize, 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
 

Field Detail

id

protected String id
The identifier of this Attribute.

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()

getStandardXML

protected String getStandardXML(String valueString)
Embeds the given String into an XML String. It includes the classname of the parameter and a "value" element that gets the given String valueString as content.

Parameters:
valueString -
Returns:
DOCUMENT ME!

doSetValue

protected abstract void doSetValue(Object v)
                            throws IllegalArgumentException
Sets the value of this Attribute to the given value without informing the ListenerManager.

Parameters:
v - the new value.
Throws:
IllegalArgumentException - if v is not of the apropriate type.

getSpaces

protected String getSpaces(int n)
Returns n spaces.

Parameters:
n - the number of spaces.
Returns:
n spaces.

callPostAttributeAdded

protected void callPostAttributeAdded(AttributeEvent ae)
Informs the ListenerManager after an Attribute has been added.

Parameters:
ae - the Attribute which will be sent to the ListenerManager.

callPostAttributeChanged

protected void callPostAttributeChanged(AttributeEvent ae)
Informs the ListenerManager after the value of an Attribute has been changed.

Parameters:
ae - the Attribute which will be sent to the ListenerManager.

callPostAttributeRemoved

protected void callPostAttributeRemoved(AttributeEvent ae)
Informs the ListenerManager after an Attribute has been removed.

Parameters:
ae - the Attribute which will be sent to the ListenerManager.

callPreAttributeAdded

protected void callPreAttributeAdded(AttributeEvent ae)
Informs the ListenerManager before an Attribute will be added.

Parameters:
ae - the Attribute which will be sent to the ListenerManager.

callPreAttributeChanged

protected void callPreAttributeChanged(AttributeEvent ae)
Informs the ListenerManager before the value of an Attribute will be changed.

Parameters:
ae - the Attribute which will be sent to the ListenerManager.

callPreAttributeRemoved

protected void callPreAttributeRemoved(AttributeEvent ae)
Informs the ListenerManager before an Attribute will be removed.

Parameters:
ae - the Attribute which will be sent to the ListenerManager.


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