ptolemy.graph.mapping
Class MapMapping

java.lang.Object
  extended by ptolemy.graph.mapping.MapMapping
All Implemented Interfaces:
Mapping
Direct Known Subclasses:
ToDoubleMapMapping, ToIntMapMapping

public abstract class MapMapping
extends java.lang.Object
implements Mapping

A Mapping that is based on a Map. The domain of the Mapping is the set of keys in the Map. MapMappings are immutable in the sense that the underlying Map cannot be changed (although the keys and values associated with the Map can be changed).

Since:
Ptolemy II 4.0
Version:
$Id: MapMapping.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Shuvra S. Bhattacharyya
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (ssb)

Field Summary
protected  java.util.Map _map
          The Map on which this Mapping is based.
 
Constructor Summary
MapMapping(java.util.Map map)
          Construct a MapMapping from a given Map.
 
Method Summary
 boolean equals(java.lang.Object object)
          Return true if the given object is of the same Class and based on the same Map as this one.
 int hashCode()
          Return the hash code of this MapMapping.
 boolean inDomain(java.lang.Object object)
          Return true if the given object is a key in the Map that is associated with this mapping.
 java.lang.String toString()
          Return a string representation of this MapMapping.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.graph.mapping.Mapping
toObject
 

Field Detail

_map

protected java.util.Map _map
The Map on which this Mapping is based.

Constructor Detail

MapMapping

public MapMapping(java.util.Map map)
Construct a MapMapping from a given Map. Modifications to the argument Map after construction of this mapping will be reflected in the Mapping.

Parameters:
map - The given map.
Method Detail

equals

public boolean equals(java.lang.Object object)
Return true if the given object is of the same Class and based on the same Map as this one.

Overrides:
equals in class java.lang.Object
Parameters:
object - The given object.
Returns:
True if the given object is of the same class and based on the same Map as this one.

hashCode

public int hashCode()
Return the hash code of this MapMapping. The hash code is simply that of the Map that this Mapping is based on.

Overrides:
hashCode in class java.lang.Object

inDomain

public boolean inDomain(java.lang.Object object)
Return true if the given object is a key in the Map that is associated with this mapping.

Specified by:
inDomain in interface Mapping
Parameters:
object - The given object.
Returns:
True if the given object is a key in the Map that is associated with this mapping.

toString

public java.lang.String toString()
Return a string representation of this MapMapping. The string representation is the class name, followed by a delimiting string, followed by a string representation of the underlying Map.

Overrides:
toString in class java.lang.Object