JML

org.jmlspecs.models
Class JMLEqualsToValueMap

java.lang.Object
  extended byorg.jmlspecs.models.JMLEqualsToValueRelation
      extended byorg.jmlspecs.models.JMLEqualsToValueMap
All Implemented Interfaces:
Cloneable, JMLCollection, JMLType, Serializable

public class JMLEqualsToValueMap
extends JMLEqualsToValueRelation

Maps (i.e., binary relations that are functional) from non-null elements of Object to non-null elements of JMLType. The first type, Object, is called the domain type of the map; the second type, JMLType, is called the range type of the map. A map can be seen as a set of pairs, of form (dv, rv), consisting of an element of the domain type, dv, and an element of the range type, rv. Alternatively, it can be seen as a function that maps each element of the domain to some of elements of the range type.

This type is a subtype of JMLEqualsToValueRelation, and as such as can be treated as a binary relation or a set valued function also. See the documentation for JMLEqualsToValueRelation and for the methods inherited from this supertype for more information.

This type considers elements val and dv of the domain type, to be distinct just when _val_not_equal_to_dv_. It considers elements of r and rv of the range type to be distinct just when _r_not_equal_to_rv_. Cloning takes place for the domain or range elements if the corresponding domain or range type is JMLType.

Version:
$Revision: 1.34 $
Author:
Gary T. Leavens, Clyde Ruby
See Also:
JMLCollection, JMLType, JMLEqualsToValueRelation, JMLEqualsToValueRelationEnumerator, JMLEqualsToValueRelationImageEnumerator, JMLValueSet, JMLObjectSet, JMLObjectToObjectMap, JMLValueToObjectMap, JMLObjectToValueMap, JMLValueToValueMap, JMLEqualsToValueRelation.toFunction()

Field Summary
static JMLEqualsToValueMap EMPTY
          The empty JMLEqualsToValueMap.
 
Fields inherited from class org.jmlspecs.models.JMLEqualsToValueRelation
domain_, imagePairSet_, size_, TOO_BIG_TO_UNION
 
Constructor Summary
  JMLEqualsToValueMap()
          Initialize this map to be the empty mapping.
  JMLEqualsToValueMap(Object dv, JMLType rv)
          Initialize this map to be a mapping that maps the given domain element to the given range element.
  JMLEqualsToValueMap(JMLEqualsValuePair pair)
          Initialize this map to be a mapping that maps the key in the given pair to the value in that pair.
protected JMLEqualsToValueMap(JMLValueSet ipset, JMLEqualsSet dom, int sz)
          Initialize this map based on the representation values given.
 
Method Summary
 JMLType apply(Object dv)
          Return the range element corresponding to dv, if there is one.
 JMLEqualsToValueMap clashReplaceUnion(JMLEqualsToValueMap othMap, JMLType errval)
          Return a new map that is like the union of the given map and this map, except that if both define a mapping for a given domain element, then each of these clashes is replaced by a mapping from the domain element in question to the given range element.
 Object clone()
          Return a clone of this object.
 JMLObjectToValueMap compose(JMLObjectToEqualsMap othMap)
          Return a new map that is the composition of this and the given map.
 JMLValueToValueMap compose(JMLValueToEqualsMap othMap)
          Return a new map that is the composition of this and the given map.
 JMLEqualsToValueMap disjointUnion(JMLEqualsToValueMap othMap)
          Return a map that is the disjoint union of this and othMap.
 JMLEqualsToValueMap extend(Object dv, JMLType rv)
          Return a new map that is like this but maps the given domain element to the given range element.
 JMLEqualsToValueMap extendUnion(JMLEqualsToValueMap othMap)
          Return a new map that is like the union of the given map and this map, except that if both define a mapping for a given domain element, then only the mapping in the given map is retained.
 boolean isaFunction()
          Tells whether this relation is a function.
 JMLEqualsToValueMap rangeRestrictedTo(JMLValueSet rng)
          Return a new map that is like this map but only contains associations that map to range elements in the given set.
 JMLEqualsToValueMap removeDomainElement(Object dv)
          Return a new map that is like this but has no association for the given domain element.
 JMLEqualsToValueMap restrictedTo(JMLEqualsSet dom)
          Return a new map that only maps elements in the given domain to the corresponding range elements in this map.
static JMLEqualsToValueMap singletonMap(Object dv, JMLType rv)
          Return the singleton map containing the given association.
static JMLEqualsToValueMap singletonMap(JMLEqualsValuePair pair)
          Return the singleton map containing the association described by the given pair.
 
Methods inherited from class org.jmlspecs.models.JMLEqualsToValueRelation
add, associations, compose, compose, difference, domain, domainElements, elementImage, elements, equals, has, has, has, hashCode, image, imagePairs, imagePairSet, insert, int_size, intersection, inverse, inverseElementImage, inverseImage, isDefinedAt, isEmpty, iterator, range, rangeElements, remove, remove, removeFromDomain, restrictDomainTo, restrictRangeTo, singleton, singleton, toBag, toFunction, toSequence, toSet, toString, union
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final JMLEqualsToValueMap EMPTY
The empty JMLEqualsToValueMap.

See Also:
JMLEqualsToValueMap()
Constructor Detail

JMLEqualsToValueMap

public JMLEqualsToValueMap()
Initialize this map to be the empty mapping.

See Also:
EMPTY

JMLEqualsToValueMap

public JMLEqualsToValueMap(Object dv,
                           JMLType rv)
Initialize this map to be a mapping that maps the given domain element to the given range element.

See Also:
singletonMap(Object, JMLType), JMLEqualsToValueMap(JMLEqualsValuePair)

JMLEqualsToValueMap

public JMLEqualsToValueMap(JMLEqualsValuePair pair)
Initialize this map to be a mapping that maps the key in the given pair to the value in that pair.

See Also:
singletonMap(JMLEqualsValuePair), JMLEqualsToValueMap(Object, JMLType)

JMLEqualsToValueMap

protected JMLEqualsToValueMap(JMLValueSet ipset,
                              JMLEqualsSet dom,
                              int sz)
Initialize this map based on the representation values given.

Method Detail

singletonMap

public static JMLEqualsToValueMap singletonMap(Object dv,
                                               JMLType rv)
Return the singleton map containing the given association.

See Also:
JMLEqualsToValueMap(Object, JMLType), singletonMap(JMLEqualsValuePair)

singletonMap

public static JMLEqualsToValueMap singletonMap(JMLEqualsValuePair pair)
Return the singleton map containing the association described by the given pair.

See Also:
JMLEqualsToValueMap(JMLEqualsValuePair), singletonMap(Object, JMLType)

isaFunction

public boolean isaFunction()
Tells whether this relation is a function.

Overrides:
isaFunction in class JMLEqualsToValueRelation

apply

public JMLType apply(Object dv)
              throws JMLNoSuchElementException
Return the range element corresponding to dv, if there is one.

Parameters:
dv - the domain element for which an association is sought (the key to the table).
Throws:
JMLNoSuchElementException - when dv is not associated to any range element by this.
See Also:
JMLEqualsToValueRelation.isDefinedAt(java.lang.Object), JMLEqualsToValueRelation.elementImage(java.lang.Object), JMLEqualsToValueRelation.image(org.jmlspecs.models.JMLEqualsSet)

clone

public Object clone()
Description copied from class: JMLEqualsToValueRelation
Return a clone of this object.

Specified by:
clone in interface JMLType
Overrides:
clone in class JMLEqualsToValueRelation

extend

public JMLEqualsToValueMap extend(Object dv,
                                  JMLType rv)
Return a new map that is like this but maps the given domain element to the given range element. Any previously existing mapping for the domain element is removed first.

See Also:
JMLEqualsToValueRelation#insert(Object, JMLType)

removeDomainElement

public JMLEqualsToValueMap removeDomainElement(Object dv)
Return a new map that is like this but has no association for the given domain element.

See Also:
JMLEqualsToValueRelation.removeFromDomain(java.lang.Object)

compose

public JMLValueToValueMap compose(JMLValueToEqualsMap othMap)
Return a new map that is the composition of this and the given map. The composition is done in the usual order; that is, if the given map maps x to y and this maps y to z, then the result maps x to z.

See Also:
compose(JMLObjectToEqualsMap)

compose

public JMLObjectToValueMap compose(JMLObjectToEqualsMap othMap)
Return a new map that is the composition of this and the given map. The composition is done in the usual order; that is, if the given map maps x to y and this maps y to z, then the result maps x to z.

See Also:
compose(JMLValueToEqualsMap)

restrictedTo

public JMLEqualsToValueMap restrictedTo(JMLEqualsSet dom)
Return a new map that only maps elements in the given domain to the corresponding range elements in this map.

See Also:
rangeRestrictedTo(org.jmlspecs.models.JMLValueSet), JMLEqualsToValueRelation.restrictDomainTo(org.jmlspecs.models.JMLEqualsSet)

rangeRestrictedTo

public JMLEqualsToValueMap rangeRestrictedTo(JMLValueSet rng)
Return a new map that is like this map but only contains associations that map to range elements in the given set.

See Also:
restrictedTo(org.jmlspecs.models.JMLEqualsSet), JMLEqualsToValueRelation.restrictRangeTo(org.jmlspecs.models.JMLValueSet)

extendUnion

public JMLEqualsToValueMap extendUnion(JMLEqualsToValueMap othMap)
                                throws IllegalStateException
Return a new map that is like the union of the given map and this map, except that if both define a mapping for a given domain element, then only the mapping in the given map is retained.

Throws:
IllegalStateException
See Also:
clashReplaceUnion(org.jmlspecs.models.JMLEqualsToValueMap, org.jmlspecs.models.JMLType), disjointUnion(org.jmlspecs.models.JMLEqualsToValueMap), JMLEqualsToValueRelation.union(org.jmlspecs.models.JMLEqualsToValueRelation)

clashReplaceUnion

public JMLEqualsToValueMap clashReplaceUnion(JMLEqualsToValueMap othMap,
                                             JMLType errval)
                                      throws IllegalStateException
Return a new map that is like the union of the given map and this map, except that if both define a mapping for a given domain element, then each of these clashes is replaced by a mapping from the domain element in question to the given range element.

Parameters:
othMap - the other map.
errval - the range element to use when clashes occur.
Throws:
IllegalStateException
See Also:
extendUnion(org.jmlspecs.models.JMLEqualsToValueMap), disjointUnion(org.jmlspecs.models.JMLEqualsToValueMap), JMLEqualsToValueRelation.union(org.jmlspecs.models.JMLEqualsToValueRelation)

disjointUnion

public JMLEqualsToValueMap disjointUnion(JMLEqualsToValueMap othMap)
                                  throws JMLMapException,
                                         IllegalStateException
Return a map that is the disjoint union of this and othMap.

Parameters:
othMap - the other mapping
Throws:
JMLMapException - the ranges of this and othMap have elements in common (i.e., when they interesect).
IllegalStateException
See Also:
extendUnion(org.jmlspecs.models.JMLEqualsToValueMap), clashReplaceUnion(org.jmlspecs.models.JMLEqualsToValueMap, org.jmlspecs.models.JMLType), JMLEqualsToValueRelation.union(org.jmlspecs.models.JMLEqualsToValueRelation)

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.