Class COM.odi.util.TypedMap
java.lang.Object
|
+----COM.odi.util.TypedMap
- public class TypedMap
- extends Object
- implements Map, Cloneable, Serializable
Transient implementation of Map, with additional type-checking on key and value.
-
TypedMap(int, Class, Class, boolean, boolean)
- Constructs a new hash table and allocates internal structures.
-
clear()
- Removes all of the elements from this Collection.
-
contains(Object)
- Same as containsValue.
-
containsKey(Object)
- Returns true if this Map contains a mapping for the specified
key.
-
containsValue(Object)
- Returns true if this Map maps one or more keys to this value.
-
elements()
- Return an enumeration on the elements of the Map.
-
entries()
- Returns a Collection view of the mappings contained in this Map.
-
equals(Object)
- Compares the specified Object with this Map for equality.
-
get(Object)
- Returns the value to which this Map maps the specified key.
-
hashCode()
- Returns the hash code value for this Map.
-
isEmpty()
- Returns true if this Collection contains no elements.
-
keys()
- Return an enumeration on the keys of the Map.
-
keySet()
- Returns a Set view of the keys contained in this Map.
-
put(Object, Object)
- Associates the specified value with the specified key in this
Map.
-
putAll(Map)
- Copies all of the mappings from the specified Map to this Map.
-
remove(Object)
- Removes the mapping for this key from this Map if present.
-
size()
- Returns the number of elements in this Collection.
-
values()
- Returns a Collection view of the values contained in this Map.
TypedMap
public TypedMap(int capacity,
Class keyType,
Class valueType,
boolean nullKeys,
boolean nullValues)
- Constructs a new hash table and allocates internal structures.
- Parameters:
- initialCapacity - The initial expected capacity requirement
for the hash table.
size
public int size()
- Returns the number of elements in this Collection.
isEmpty
public boolean isEmpty()
- Returns true if this Collection contains no elements.
clear
public void clear()
- Removes all of the elements from this Collection.
The Collection will be empty after this call returns.
containsValue
public boolean containsValue(Object value)
- Returns true if this Map maps one or more keys to this value.
More formally, returns true if and only if this Map contains at
least one mapping to a value
v
such that
(value==null ? v==null : value.equals(v))
.
- Parameters:
- value - value whose presence in this Map is to be tested.
contains
public boolean contains(Object value)
- Same as containsValue.
containsKey
public boolean containsKey(Object key)
- Returns true if this Map contains a mapping for the specified
key.
- Parameters:
- key - key whose presence in this Map is to be tested.
elements
public Enumeration elements()
- Return an enumeration on the elements of the Map.
keys
public Enumeration keys()
- Return an enumeration on the keys of the Map.
get
public Object get(Object key)
- Returns the value to which this Map maps the specified key.
Returns null if the Map contains no mapping for this key. A
return value of null does not necessarily indicate
that the Map contains no mapping for the key; it's also
possible that the Map explicitly maps the key to null. The
containsKey operation may be used to distinguish these two
cases.
- Parameters:
- key - key whose associated value is to be returned.
put
public Object put(Object key,
Object value)
- Associates the specified value with the specified key in this
Map. If the Map previously contained a
mapping for this key, the old value is replaced.
- Parameters:
- key - key with which the specified value is to be associated.
- value - value to be associated with the specified key.
- Returns:
- previous value associated with specified key, or null if there
was no mapping for key. (A null return can also indicate that
the Map previously associated null with the specified key,
if the implementation supports null values.)
- Throws: ClassCastException
- class of the specified key or value
prevents it from being stored in this Map.
- Throws: IllegalArgumentException
- some aspect of this key or value
prevents it from being stored in this Map.
- Throws: NullPointerException
- this Map does not permit null keys
or values, and the specified key or value is null.
remove
public Object remove(Object key)
- Removes the mapping for this key from this Map if present.
- Parameters:
- key - key whose mapping is to be removed from the Map.
- Returns:
- previous value associated with specified key, or null if there
was no mapping for key. (A null return can also indicate that
the Map previously associated null with the specified key,
if the implementation supports null values.)
putAll
public void putAll(Map t)
- Copies all of the mappings from the specified Map to this Map.
This optional operation is UNSUPPORTED.
- Throws: UnsupportedOperationException
- putAll is not supported
by this Map.
keySet
public Set keySet()
- Returns a Set view of the keys contained in this Map. The Set is
backed by the Map, so changes to the Map are reflected in the Set,
and vice-versa. (If the Map is modified while while an iteration over
the Set is in progress, the results of the iteration are undefined.)
The Set supports element removal (which removes the corresponding
mapping from the Map) via the Iterator.remove, Set.remove, removeAll
retainAll, and clear operations. It does not support the add or
addAll operations.
values
public Collection values()
- Returns a Collection view of the values contained in this Map. The
Collection is backed by the Map, so changes to the Map are
reflected in the Collection, and vice-versa. (If the Map is
modified while while an iteration over the Collection is in progress,
the results of the iteration are undefined.) The Collection supports
element removal (which removes the corresponding mapping from the
Map) via the Iterator.remove, Collection.remove, removeAll,
retainAll and clear operations. It does not support the add or
addAll operations.
entries
public Set entries()
- Returns a Collection view of the mappings contained in this Map.
Each element in this collection is a Map.Entry. The Collection is
backed by the Map, so changes to the Map are reflected in the
Collection, and vice-versa. (If the Map is modified while while an
iteration over the Collection is in progress, the results of the
iteration are undefined.) The Collection supports element removal
(which removes the corresponding mapping from the Map) via the
Iterator.remove, Collection.remove, removeAll, retainAll and clear
operations. It does not support the add or addAll operations.
equals
public boolean equals(Object obj)
- Compares the specified Object with this Map for equality.
Returns true if the given object is also a Map and the two Maps
represent the same mappings. More formally, two Maps
t1
and t2
represent the same mappings
if t1.keySet().equals(t2.keySet())
and for every
key k
in t1.keySet()
,
(t1.get(k)==null ? t2.get(k)==null :
t1.get(k).equals(t2.get(k)))
. This ensures that the
equals method works properly across different implementations
of the Map interface.
- Parameters:
- o - Object to be compared for equality with this Map.
- Returns:
- true if the specified Object is equal to this Map.
- Overrides:
- equals in class Object
hashCode
public int hashCode()
- Returns the hash code value for this Map. The hash code of a
Map is defined to be the sum of the hashCodes of each Entry in
the Map's entries view. This ensures that
t1.equals(t2)
implies that
t1.hashCode()==t2.hashCode()
for any two Maps
t1
and t2
, as required by the general
contract of Object.hashCode.
- Overrides:
- hashCode in class Object
Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.