Package org.graffiti.attributes
Class AbstractCollectionAttribute
java.lang.Object
org.graffiti.attributes.AbstractAttribute
org.graffiti.attributes.AbstractCollectionAttribute
- All Implemented Interfaces:
Attribute,CollectionAttribute,DeepCopy,Displayable
- Direct Known Subclasses:
HashMapAttribute,LinkedHashMapAttribute
public abstract class AbstractCollectionAttribute extends AbstractAttribute implements CollectionAttribute
Provides common functionality for
CollectionAttribute instances.
Calls the ListenerManager and delegates the functionality to the
implementing class.- Version:
- $Revision: 1.15 $
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractCollectionAttribute(String id)Constructor for setting the id of anAbstractCollectionAttribute. -
Method Summary
Modifier and Type Method Description voidadd(Attribute a)Adds a given attribute to the collection.voidadd(Attribute a, boolean inform)Adds a given attribute to the collection.AttributablegetAttributable()Returns theAttribute'sAttributable.AttributegetAttribute(String path)Returns the attribute located atpath.ObjectgetValue()Returns the value of this attribute, i.e.booleanisEmpty()Returnstrueif the HashMapAttribute is empty.voidremove(String attrId)Removes the attribute with the given id from the collection.voidremove(Attribute attr)Removes the given attribute from the collection by callingremove(String id)with the attribute's id as parameter.voidsetAttributable(Attributable att)Sets theAttribute'sAttributable.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 org.graffiti.attributes.AbstractAttribute
addEdgeAttributeType, addNodeAttributeType, getDescription, getIcon, getId, getName, getParent, getPath, getTypedAttribute, isDeleted, isTypedAttributeFromID, setDeleted, setDescription, setId, setParent, setValue, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.graffiti.attributes.Attribute
getId, getParent, getPath, isDeleted, setDefaultValue, setDeleted, setId, setParent, setValueMethods inherited from interface org.graffiti.attributes.CollectionAttribute
getCollection, setCollection, sizeMethods inherited from interface org.graffiti.plugin.Displayable
getDescription, getIcon, getName, setDescription
-
Constructor Details
-
AbstractCollectionAttribute
Constructor for setting the id of anAbstractCollectionAttribute.- Parameters:
id- the id of theAttribute.- Throws:
IllegalIdException- if the given id contains a seperator. This is checked for in the constructor of the superclassAbstractAttribute.
-
-
Method Details
-
setAttributable
Sets theAttribute'sAttributable.Implementation Notes: This method should only be called once and only by an
addAttribute()method call! The attributable property may only be set on the rootAttributeof a hierarchy- Specified by:
setAttributablein interfaceCollectionAttribute- Parameters:
att- the newAttributableof theAttribute.- Throws:
FieldAlreadySetException- DOCUMENT ME!
-
getAttributable
Returns theAttribute'sAttributable.- Specified by:
getAttributablein interfaceAttribute- Overrides:
getAttributablein classAbstractAttribute- Returns:
- the
Attribute'sAttributable.
-
getAttribute
Returns the attribute located atpath.- Specified by:
getAttributein interfaceCollectionAttribute- Parameters:
path- the relative path to the attribute fromthis.- Returns:
- the attribute found at
path. - Throws:
AttributeNotFoundException- if there is no attribute located at path.
-
isEmpty
public boolean isEmpty()Returnstrueif the HashMapAttribute is empty. The same asgetCollection().isEmpty()would yield, but this method should be faster since the map is not copied.- Specified by:
isEmptyin interfaceCollectionAttribute- Returns:
trueif the HashMapAttribute is empty.
-
getValue
Returns the value of this attribute, i.e. map between contained attributes' ids and these attributes. The behaviour of this method depends on implementation of methodgetCollection()in concret classes which inherit this one. See documentation of concret classes for more information.- Specified by:
getValuein interfaceAttribute- Specified by:
getValuein interfaceDisplayable- Returns:
- the value of this attribute.
-
add
Adds a given attribute to the collection. Informs theListenerManagerabout the addition.- Specified by:
addin interfaceCollectionAttribute- Parameters:
a- the new attribute to add to the list.- 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.
-
add
public void add(Attribute a, boolean inform) throws AttributeExistsException, FieldAlreadySetExceptionAdds a given attribute to the collection. Only informs theListenerManagerabout the addition wheninformis set to true.- Specified by:
addin interfaceCollectionAttribute- Parameters:
a- the new attribute to add to the list.inform- when true,ListenerManagergets 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
Removes the attribute with the given id from the collection. NotifiesListenerManagerwith an AttributeRemoved event when the attribute hierarchy is attached to anAttributable.- Specified by:
removein interfaceCollectionAttribute- Parameters:
attrId- the id of the attribute.- Throws:
AttributeNotFoundException- if there is no attribute with the given id.IllegalIdException- DOCUMENT ME!
-
remove
Removes the given attribute from the collection by callingremove(String id)with the attribute's id as parameter. NotifiesListenerManagerwith an AttributeRemoved event when the attribute hierarchy is attached to anAttributable.- Specified by:
removein interfaceCollectionAttribute- Parameters:
attr- the attribute to be removed.- Throws:
AttributeNotFoundException- if the given attribute is not in the HashMap.
-
toString
Description copied from interface:AttributeReturns a string representation prepended bynspaces of this attribute.- Specified by:
toStringin interfaceAttribute- Overrides:
toStringin classAbstractAttribute- 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- Overrides:
toXMLStringin classAbstractAttribute- Returns:
- string holding an XML representation of this Displayable
- See Also:
Displayable.toXMLString()
-