org.graffiti.attributes
Interface CollectionAttribute

All Superinterfaces:
Attribute, DeepCopy, Displayable<Object>
All Known Subinterfaces:
SortedCollectionAttribute
All Known Implementing Classes:
AbstractCollectionAttribute, ColorAttribute, CoordinateAttribute, DimensionAttribute, DockingAttribute, EdgeGraphicAttribute, EdgeLabelAttribute, EdgeLabelPositionAttribute, GraphElementGraphicAttribute, GraphGraphicAttribute, GridAttribute, GridOriginAttribute, GridParametersAttribute, HashMapAttribute, ImageAttribute, LabelAttribute, LinkedHashMapAttribute, NodeGraphicAttribute, NodeLabelAttribute, NodeLabelPositionAttribute, PortAttribute, PortsAttribute, PositionAttribute, ShapeDescriptionAttribute, SnapOnGridAttribute

public interface CollectionAttribute
extends DeepCopy, Attribute

Contains a Collection of Attributes. It is similar to a directory which contains files and subdirectories. All methods modifying the CollectionAttribute (no get-Methods or anything similar) have to inform the ListenerManager about the modification. The ListenerManager is accessible via getAttributable().getListenerManager().

Implementation note: The information of the ListenerManager could look as follows:

     public whatever modify() {
         AttributeEvent attr = new AttributeEvent(...);
         ListenerManager lm = getAttributable().getListenerManager();
         lm.preAttributeModified();
         // ...
         // here the Attribute will be modified.
         // ...
         lm.postAttributeModified();
         return anything;
     }
 

Version:
$Revision: 5767 $

Field Summary
 
Fields inherited from interface org.graffiti.attributes.Attribute
SEPARATOR
 
Method Summary
 void add(Attribute att)
          Adds a given Attribute to the list.
 void add(Attribute a, boolean inform)
          Adds a given attribute to the collection.
 boolean containsAttribute(String path)
          Returns if the given path contains an Attribute of any kind.
 Attribute getAttribute(String path)
          Returns the Attribute located at path.
 Map<String,Attribute> getCollection()
          Returns the map of ids to attributes in the CollectionAttribute.
 boolean isEmpty()
          Returns true if the CollectionAttribute is empty.
 void remove(Attribute att)
          Removes the given Attribute from the list.
 void remove(String id)
          Removes the Attribute with the given id from the list.
 void setAttributable(Attributable att)
          Sets the attributable the Attribute belongs to.
 void setCollection(Map<String,Attribute> attrs)
          Sets the collection of attributes contained within this CollectionAttribute
 
Methods inherited from interface org.graffiti.attributes.Attribute
getAttributable, getId, getParent, getPath, getValue, setDefaultValue, setParent, setValue, toString
 
Methods inherited from interface org.graffiti.plugin.Displayable
getDescription, getName, setDescription, toXMLString
 
Methods inherited from interface org.graffiti.core.DeepCopy
copy
 

Method Detail

setAttributable

void setAttributable(Attributable att)
                     throws FieldAlreadySetException
Sets the attributable the Attribute belongs to. Implementation Note: This function should only work if the Attribute's attributable is null before. Normaly only addAttribute() methods should call it.

Parameters:
att - the Attribute's attributable.
Throws:
FieldAlreadySetException - if the attributable was already set before.

getAttribute

Attribute getAttribute(String path)
                       throws AttributeNotFoundException,
                              NoCollectionAttributeException
Returns the Attribute located at path.

Parameters:
path - the relative path to the attribute from this.
Returns:
DOCUMENT ME!
Throws:
AttributeNotFoundException - if there is no attribute at the given location.
NoCollectionAttributeException

setCollection

void setCollection(Map<String,Attribute> attrs)
Sets the collection of attributes contained within this CollectionAttribute

Parameters:
attrs - the map that contains all attributes.

getCollection

Map<String,Attribute> getCollection()
Returns the map of ids to attributes in the CollectionAttribute.

Returns:
the map of ids to attributes in the CollectionAttribute.

isEmpty

boolean isEmpty()
Returns true if the CollectionAttribute is empty.

Returns:
true if this CollectionAttribute is empty.

add

void add(Attribute att)
         throws AttributeExistsException,
                FieldAlreadySetException
Adds a given Attribute to the list. The id of given attribute may not be already in the list.

Parameters:
att - the new attribute to add to the list.
Throws:
AttributeExistsException - if there is already an attribute with the same id as the given attribute.
FieldAlreadySetException

add

void add(Attribute a,
         boolean inform)
         throws AttributeExistsException,
                FieldAlreadySetException
Adds a given attribute to the collection. Only informs the ListenerManager about the addition when inform is set to true.

Parameters:
a - the new attribute to add to the list.
inform - when true, ListenerManager gets informed otherwise not
Throws:
AttributeExistsException - if there is already an attribute with the id of a.
FieldAlreadySetException - thrown if Attribute a already has a parent or attributable associated with it.

remove

void remove(String id)
            throws AttributeNotFoundException
Removes the Attribute with the given id from the list.

Parameters:
id - the id of the attribute.
Throws:
AttributeNotFoundException - if there is no attribute with the given id.

remove

void remove(Attribute att)
            throws AttributeNotFoundException
Removes the given Attribute from the list.

Parameters:
att - the attribute to be removed.
Throws:
AttributeNotFoundException - if the given attribute is not part of this CollectionAttribute.

containsAttribute

boolean containsAttribute(String path)
Returns if the given path contains an Attribute of any kind.

Parameters:
path - The path of the Attribute to be tested.
Returns:
true, if an Attribute is saved in the given path, false otherwise.


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