ptolemy.graph.mapping
Class ToDoubleMapMapping
java.lang.Object
ptolemy.graph.mapping.MapMapping
ptolemy.graph.mapping.ToDoubleMapMapping
- All Implemented Interfaces:
- Mapping, ToDoubleMapping
public class ToDoubleMapMapping
- extends MapMapping
- implements ToDoubleMapping
A ToDoubleMapping that is based on a Map. The values in the Map
must be instances of Double. ToDoubleMapMappings 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: ToDoubleMapMapping.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Shuvra S. Bhattacharyya
- Accepted Rating:
- Proposed Rating:
Constructor Summary |
ToDoubleMapMapping(java.util.Map map)
Construct a ToDoubleMapMapping from a given map. |
Method Summary |
boolean |
inDomain(java.lang.Object object)
Return true if the given object is in the domain of this Mapping. |
double |
toDouble(java.lang.Object object)
Return the double value that is associated with given object under
this mapping. |
java.lang.Object |
toObject(java.lang.Object object)
Return the object associated with the given object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
ToDoubleMapMapping
public ToDoubleMapMapping(java.util.Map map)
- Construct a ToDoubleMapMapping from a given map. The values in the map
must be instances of Double; otherwise, unpredictable behavior
may result. Modifications to the argument Map after construction
of this mapping will be reflected in the mapping. The Map modifications
must follow the restriction that all added values to the Map
must be instances of Double.
- Parameters:
map
- The given map.
inDomain
public boolean inDomain(java.lang.Object object)
- Return true if the given object is in the domain of this Mapping.
More precisely, return true if the given object is a valid argument
to
toDouble(Object)
, which means that the object is a
key in the Map that is associated with this Mapping and the value
in the Map is an instance of Double.
- Specified by:
inDomain
in interface Mapping
- Overrides:
inDomain
in class MapMapping
- Parameters:
object
- The given object.
- Returns:
- True if the given object is in the domain of this Mapping.
toDouble
public double toDouble(java.lang.Object object)
- Return the double value that is associated with given object under
this mapping. For efficiency, no error checking is performed
on the argument, and consequently, a runtime exception may result as
noted below. To perform argument validity checking before mapping an
object, use
ptolemy.graph.mapping
.
- Specified by:
toDouble
in interface ToDoubleMapping
- Parameters:
object
- The given object.
- Returns:
- The double value that is associated with given object under
this mapping.
- Throws:
java.lang.RuntimeException
- If the given object is not an instance
of Double
or if the given object is not in the
domain of the mapping.
toObject
public java.lang.Object toObject(java.lang.Object object)
- Return the object associated with the given object.
- Specified by:
toObject
in interface Mapping
- Parameters:
object
- The given object.
- Returns:
- The object that is associated with given object under
this mapping.