Package org.graffiti.attributes
Class HashMapAttribute
java.lang.Object
org.graffiti.attributes.AbstractAttribute
org.graffiti.attributes.AbstractCollectionAttribute
org.graffiti.attributes.HashMapAttribute
- All Implemented Interfaces:
Comparable<Object>,Attribute,CollectionAttribute,DeepCopy,Displayable
- Direct Known Subclasses:
ColorAttribute,CoordinateAttribute,DimensionAttribute,DockingAttribute,GraphElementGraphicAttribute,ImageAttribute,LabelAttribute,PortAttribute,PortsAttribute,PositionAttribute
public class HashMapAttribute extends AbstractCollectionAttribute implements CollectionAttribute, Comparable<Object>
Maps a given id to an attribute. (e.g. if this Attribute contains 2 other
attributes, one StringAttribute with id "Name" and another
CollectionAttribute with id "Color" which contains three
IntegerAttributes ('red', 'green' and 'blue'). The map then contains only the
two key-value pairs 'Name'-StringAttribute and 'Color'-CollectionAttribute.
The subattributes 'red', 'green' and 'blue' are not mapped in this Attribute!
- Version:
- $Revision: 1.14 $
- See Also:
CollectionAttribute,CompositeAttribute
-
Field Summary
-
Constructor Summary
Constructors Constructor Description HashMapAttribute()HashMapAttribute(String id)Construct a new instance of aHashMapAttribute. -
Method Summary
Modifier and Type Method Description intcompareTo(Object o)Objectcopy()Copies thisCollectionAttributeand returns the copy.Map<String,Attribute>getCollection()Returns a cloned map (shallow copy of map: i.e.voidsetCollection(Map<String,Attribute> attrs)Sets the collection of attributes contained within this CollectionAttribute For each entry in the map, pre- and post- AttributeAdded events are generated since methodadd(Attribute a)is called for each attribute in the map.voidsetDefaultValue()Already done in constructor for this attribute type.intsize()Methods inherited from class org.graffiti.attributes.AbstractCollectionAttribute
add, add, getAttributable, getAttribute, getValue, isEmpty, remove, remove, setAttributable, toString, toXMLStringMethods 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
getAttributable, getId, getParent, getPath, getValue, isDeleted, setDeleted, setId, setParent, setValue, toStringMethods inherited from interface org.graffiti.attributes.CollectionAttribute
add, add, getAttribute, isEmpty, remove, remove, setAttributableMethods inherited from interface org.graffiti.plugin.Displayable
getDescription, getIcon, getName, setDescription, toXMLString
-
Constructor Details
-
HashMapAttribute
Construct a new instance of aHashMapAttribute. The internal HashMap is initialized empty.- Parameters:
id- the id of the attribute.
-
HashMapAttribute
public HashMapAttribute()
-
-
Method Details
-
setCollection
Sets the collection of attributes contained within this CollectionAttribute For each entry in the map, pre- and post- AttributeAdded events are generated since methodadd(Attribute a)is called for each attribute in the map.- Specified by:
setCollectionin interfaceCollectionAttribute- Parameters:
attrs- the Map that contains all attributes.
-
getCollection
Returns a cloned map (shallow copy of map: i.e.this.map.equals(getCollection())but notthis.map == getCollection()) between attributes' ids and attributes contained in this attribute.- Specified by:
getCollectionin interfaceCollectionAttribute- Returns:
- a clone of the list of attributes in this attribute.
-
setDefaultValue
public void setDefaultValue()Already done in constructor for this attribute type.- Specified by:
setDefaultValuein interfaceAttribute- See Also:
Attribute.setDefaultValue()
-
copy
Copies thisCollectionAttributeand returns the copy. All sub-attributes will be copied, too, i.e. a deep-copy is returned. -
compareTo
- Specified by:
compareToin interfaceComparable<Object>
-
size
public int size()- Specified by:
sizein interfaceCollectionAttribute
-