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 $
  • Constructor Details

    • 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.
    • AbstractAttribute

      public AbstractAttribute()
  • Method Details

    • setId

      public void setId​(String id)
      Specified by:
      setId in interface Attribute
    • addNodeAttributeType

      public static void addNodeAttributeType​(String id, Class<? extends Attribute> type)
    • addEdgeAttributeType

      public static void addEdgeAttributeType​(String id, Class<? extends Attribute> type)
    • getTypedAttribute

      public static Attribute getTypedAttribute​(String id, boolean isNodeTrue_isEdgeFalse)
    • isTypedAttributeFromID

      public static boolean isTypedAttributeFromID​(String id, boolean isNodeTrue_isEdgeFalse)
    • 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
      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
      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
      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
      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
      Returns:
      string holding an XML representation of this Displayable
      See Also:
      Displayable.toXMLString()
    • getIcon

      public JComponent getIcon()
      Specified by:
      getIcon in interface Displayable
    • isDeleted

      public boolean isDeleted()
      Specified by:
      isDeleted in interface Attribute
    • setDeleted

      public void setDeleted​(boolean deleted)
      Specified by:
      setDeleted in interface Attribute