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

    • HashMapAttribute

      public HashMapAttribute​(String id)
      Construct a new instance of a HashMapAttribute. The internal HashMap is initialized empty.
      Parameters:
      id - the id of the attribute.
    • HashMapAttribute

      public HashMapAttribute()
  • Method Details

    • setCollection

      public 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 method add(Attribute a) is called for each attribute in the map.
      Specified by:
      setCollection in interface CollectionAttribute
      Parameters:
      attrs - the Map that contains all attributes.
    • getCollection

      public Map<String,​Attribute> 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 interface CollectionAttribute
      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 interface Attribute
      See Also:
      Attribute.setDefaultValue()
    • copy

      public Object copy()
      Copies this CollectionAttribute and returns the copy. All sub-attributes will be copied, too, i.e. a deep-copy is returned.
      Specified by:
      copy in interface DeepCopy
      Returns:
      a copy of the CollectionAttribute.
    • compareTo

      public int compareTo​(Object o)
      Specified by:
      compareTo in interface Comparable<Object>
    • size

      public int size()
      Specified by:
      size in interface CollectionAttribute