Class COM.odi.util.OSHashMap

java.lang.Object
   |
   +----COM.odi.util.OSDictionary
           |
           +----COM.odi.util.OSHashtable
                   |
                   +----COM.odi.util.OSHashMap

public class OSHashMap
extends OSHashtable
implements Map
OSHashMap implements the COM.odi.util.Map interface with a persistent hash table. Certain operations on OSHashMap that require comparison of objects might cause ObjectStore to throw ReferencedObjectNotFoundException. If this occurs, it indicates that one or more of the key or value objects referenced by the hash table cannot be accessed, most likely because they have been destroyed. The OSHashMap class provides a clearDestroyed() operation that can be used to remove entries that contain these references to these destroyed objects.

Additional information about OSHashMap is in the user guide. Here are exceptions that might be thrown by many of the methods in this class:

DatabaseNotOpenException If the database containing the object is not open.

NoTransactionInProgressException If there is no transaction in progress.

ObjectNotFoundException If the object was not found, either because the object itself, its segment, or its database was destroyed.

ObjectException Ifthe object was local and was fetched in a previous transaction.

ObjectStoreException If the session implied by an argument to the call or the object the method is called on is not the same as the session associated with the current thread.

UpdateReadOnlyException If there is a readonly transaction in progress or if the database is open for readonly.


Constructor Index

 o OSHashMap()
Constructs a new persistence-capable hash map.
 o OSHashMap(int)
Constructs a new persistence-capable hash map.

Method Index

 o clear()
Removes all entries from the hash table.
 o equals(Object)
Compares the specified Object with this Map for equality.
 o hashCode()
UNSUPPORTED IN THIS RELEASE OF PSE.
 o put(Object, Object)
Enters the mapping of a key to a value in the hash table.
 o remove(Object)
Removes any existing mapping at the specified key.
 o removeValue(Object)
Removes the specified value from the hashtable.

Constructors

 o OSHashMap
  public OSHashMap(int initialCapacity)
Constructs a new persistence-capable hash map.

Parameters:
initialCapacity - The initial expected capacity requirement for the hash table.
 o OSHashMap
  public OSHashMap()
Constructs a new persistence-capable hash map. A default size is used as the initial hash table capacity.

Methods

 o put
  public synchronized Object put(Object key,
                                 Object value)
Enters the mapping of a key to a value in the hash table.

Parameters:
key - The identifier for the value.

value - The value being stored in the hash table.

Returns:
The object previously mapped at the specified key, or null.

Throws: NullPointerException
If either key or value is null.
Throws: ReferencedObjectNotFoundException
If an entry key is not found.
Overrides:
put in class OSHashtable
 o remove
  public synchronized Object remove(Object key)
Removes any existing mapping at the specified key.

Parameters:
key - The key of the object to remove.

Returns:
The object previously mapped at the specified key, or null.

Throws: NullPointerException
If key is null.
Throws: ReferencedObjectNotFoundException
If an entry key is not found.
Overrides:
remove in class OSHashtable
 o removeValue
  public synchronized boolean removeValue(Object value)
Removes the specified value from the hashtable. If more than one key maps to this element, the first such mapping that is found is removed.

Parameters:
value - The element to search for, which must be nonnull.

Returns:
The true constant if the hash table was changed as a result of this operation (that is, if the value was an element of the hashtable). The false constant if the element is not in the hash table.

Throws: NullPointerException
If value is null.
Throws: ReferencedObjectNotFoundException
If an entry value is not found.
Overrides:
removeValue in class OSHashtable
 o clear
  public synchronized void clear()
Removes all entries from the hash table.

Overrides:
clear in class OSHashtable
 o 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))) . Note that this meets the JDK1.2 specification for Map.equals, but that it means that it is not appropriate to store an instance of OSHashMap in any hash-based collection, because its hash code will change if the OSHashMap is modified.

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
 o hashCode
  public int hashCode()
UNSUPPORTED IN THIS RELEASE OF PSE. THIS METHOD WILL BE CHANGED TO PROVIDE A BEHAVIOR COMPATIBLE WITH THE JDK1.2 MAP SPECIFICATION, WHEN THE JDK1.2 IS RELEASED.

Throws: UnsupportedOperationException
hashCode() is not supported. 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. Note that this meets the JDK1.2 specification for Map.equals, but that it means that it is not appropriate to store an instance of OSHashMap in any hash-based collection, because its hash code will change if the OSHashMap is modified.
Overrides:
hashCode in class OSDictionary
See Also:
hashCode, equals, equals

Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.