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 int
compareTo(Object o)
Object
copy()
Copies thisCollectionAttribute
and returns the copy.Map<String,Attribute>
getCollection()
Returns a cloned map (shallow copy of map: i.e.void
setCollection(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.void
setDefaultValue()
Already done in constructor for this attribute type.int
size()
Methods inherited from class org.graffiti.attributes.AbstractCollectionAttribute
add, add, getAttributable, getAttribute, getValue, isEmpty, remove, remove, setAttributable, toString, toXMLString
Methods inherited from class org.graffiti.attributes.AbstractAttribute
addEdgeAttributeType, addNodeAttributeType, getDescription, getIcon, getId, getName, getParent, getPath, getTypedAttribute, isDeleted, isTypedAttributeFromID, setDeleted, setDescription, setId, setParent, setValue, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.graffiti.attributes.Attribute
getAttributable, getId, getParent, getPath, getValue, isDeleted, setDeleted, setId, setParent, setValue, toString
Methods inherited from interface org.graffiti.attributes.CollectionAttribute
add, add, getAttribute, isEmpty, remove, remove, setAttributable
Methods 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:
setCollection
in 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:
getCollection
in 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:
setDefaultValue
in interfaceAttribute
- See Also:
Attribute.setDefaultValue()
-
copy
Copies thisCollectionAttribute
and returns the copy. All sub-attributes will be copied, too, i.e. a deep-copy is returned. -
compareTo
- Specified by:
compareTo
in interfaceComparable<Object>
-
size
public int size()- Specified by:
size
in interfaceCollectionAttribute
-