Class COM.odi.util.OSHashtable
java.lang.Object
|
+----COM.odi.Persistent
|
+----COM.odi.util.HashPersistent
|
+----COM.odi.util.OSDictionary
|
+----COM.odi.util.OSHashtable
- public class OSHashtable
- extends OSDictionary
- implements Cloneable, Serializable
OSHashtable implements a persistent hash table. The API is
similar to java.util.Hashtable for ease of code conversion.
- See Also:
- Persistent, Hashtable
-
OSHashtable()
- Constructs a new persistence-capable hash table.
-
OSHashtable(ClassInfo)
- Constructs a new hollow hash table.
-
OSHashtable(int)
- Constructs a new persistence-capable hash table.
-
clear()
- Removes all entries from the hash table.
-
clearContents()
- Resets the values of the fields of an active persistent object to the default
initial values of that class of object.
-
clone()
- Clones the object.
-
contains(Object)
- Checks whether or not the hash table contains a specified value as an element.
-
containsKey(Object)
- Checks whether or not the hash table contains an element with the
specified key and maintains a cache from the OSHashtable
object to the element.
-
containsKey(Object, boolean)
- Checks whether or not the hash table contains an element with the
specified key and optionally maintains a cache from the
OSHashtable object to the element.
-
destroy()
- Destroys the hash table in the database.
-
elements()
- Obtains an enumeration of the elements in the hash table.
-
flushContents(GenericObject)
- Stores the values of the fields of an active persistent object in
an instance of GenericObject.
-
get(Object)
- Obtains the element mapped at the specified key and
maintains a cache from the OSHashtable object to the element.
-
get(Object, boolean)
- Obtains the element mapped at the specified key and optionally
maintains a cache from the OSHashtable object to the element.
-
getKey(Object)
-
Returns the actual key stored in the hash table for the given key
and maintains a cache from the OSHashtable
object to the element.
-
getKey(Object, boolean)
-
Returns the actual key stored in the hash table for the given key
and optionally maintains a cache from the OSHashtable
object to the element.
-
initializeContents(GenericObject)
- Initializes the values of the fields of a hollow persistent object from
data contained in an instance of GenericObject.
-
isEmpty()
- Determines whether or not there are any keys in the hash table.
-
keys()
- Returns an enumeration of the keys in the hash table.
-
put(Object, Object)
- Enter the mapping of a key to a value in the hash table.
-
remove(Object)
- Removes any existing mapping at the specified key.
-
size()
- Determines the number of keys in the hash table.
-
toString()
- Produces a printable representation of the object.
OSHashtable
protected OSHashtable(ClassInfo ignored)
- Constructs a new hollow hash table.
This constructor should be used only for that purpose
- Parameters:
- ignored - Only used to distinguish this overloading.
The value is not used.
OSHashtable
public OSHashtable(int initialCapacity)
- Constructs a new persistence-capable hash table.
- Parameters:
- initialCapacity - The initial expected capacity requirement
for the hash table.
OSHashtable
public OSHashtable()
- Constructs a new persistence-capable hash table.
A default size is used as the initial hash table capacity.
initializeContents
public void initializeContents(GenericObject genObject)
- Initializes the values of the fields of a hollow persistent object from
data contained in an instance of GenericObject.
PSE/PSE Pro arranges to call this
method when an application calls fetch() or dirty() on a
persistent object. In the class you define, the method that
overrides this method must
initialize all fields in the hollow persistent object, including any fields defined by
superclasses. Initialize superclass fields by invoking
initializeContents() on the superclass. This is similar to calls to superclass
constructors, although in this case the superclass initialization is not
enforced by the compiler.
- Parameters:
- genObj - The representation of the persistent object that the
method should read the field values from.
- Overrides:
- initializeContents in class OSDictionary
- See Also:
- initializeContents
flushContents
public void flushContents(GenericObject genObject)
- Stores the values of the fields of an active persistent object in
an instance of GenericObject. PSE/PSE Pro arranges to call this
method when a modified persistent object is evicted and when a transaction
is committed. Your persistent class
definition must define a method to override this one. Ensure that it
writes all fields, even fields that were not modified.
- Parameters:
- genObject - The representation of the persistent object that this
method should write the field values into.
- Overrides:
- flushContents in class OSDictionary
- See Also:
- flushContents
clearContents
public void clearContents()
- Resets the values of the fields of an active persistent object to the default
initial values of that class of object. This causes the object to become
a stale persistent object. As with initializeContents(),
this method must invoke
clearContents() on its superclass to ensure that all fields are correctly
cleared.
- Overrides:
- clearContents in class OSDictionary
- See Also:
- clearContents
destroy
public synchronized void destroy()
- Destroys the hash table in the database. The keys and elements in the
hash table are unaffected by this operation. If the hash table is
persistent, the database must be open for update and there must be
an update transaction in progress.
- Throws: DatabaseNotOpenException
- If the database containing the object
is not open.
- Throws: NoTransactionInProgressException
- If there is no transaction
in progress.
- Throws: ObjectNotFoundException
- If the object was not found,
either because the object itself, its segment, or its database was
destroyed, or because the object was local and was fetched in a
previous transaction.
- Throws: ObjectStoreException
- If PSE/PSE Pro is not initialized for
the current thread or if the object is not associated with this thread.
- Throws: UpdateReadOnlyException
- If there is a read-only
transaction in progress or if the database is open read-only.
- Overrides:
- destroy in class Persistent
size
public int size()
- Determines the number of keys in the hash table.
- Returns:
- An integer that indicates the number of keys.
- Overrides:
- size in class OSDictionary
isEmpty
public boolean isEmpty()
- Determines whether or not there are any keys in the hash table.
- Returns:
- The true constant if there are no keys in the
hash table. The false constant if there is at least one
key in the hash table.
- Overrides:
- isEmpty in class OSDictionary
keys
public synchronized Enumeration keys()
- Returns an enumeration of the keys in the hash table.
Note that the enumeration is only guaranteed to be valid for the
duration of the current transaction.
- Overrides:
- keys in class OSDictionary
elements
public synchronized Enumeration elements()
- Obtains an enumeration of the elements in the hash table.
Note that the elements are not necessarily unique and
that the enumeration is only guaranteed to be valid for the
duration of the current transaction.
- Returns:
- Enumeration The list of elements in the hash table.
- Overrides:
- elements in class OSDictionary
contains
public synchronized boolean contains(Object value)
- Checks whether or not the hash table contains a specified value as an element.
- Parameters:
- value - The element to search for, which must be nonnull.
- Returns:
- The true constant if the element is in the hash table. The
false constant if the element is not in the hash table.
- Throws: NullPointerException
- If value is null.
- Overrides:
- contains in class OSDictionary
containsKey
public synchronized boolean containsKey(Object key)
- Checks whether or not the hash table contains an element with the
specified key and maintains a cache from the OSHashtable
object to the element. This cache prevents the element from
being garbage collected unless the application evicts the entire
OSHashtable.
- Parameters:
- key - The key to search for.
- Returns:
- The true constant if the hash table contains an
element with the specified key. The false constant if the
hash table does not.
- Throws: NullPointerException
- If key is null.
- Overrides:
- containsKey in class OSDictionary
containsKey
public synchronized boolean containsKey(Object key,
boolean noCache)
- Checks whether or not the hash table contains an element with the
specified key and optionally maintains a cache from the
OSHashtable object to the element. Normally, the
containsKey() method maintains this cache which prevents the
element from being garbage collected unless the application
evicts the entire OSHashtable.
- Parameters:
- key - The key to search for.
- noCache - If true, the OSHashtable does
not maintain a cache to the returned element. This allows the
object to be garbage collected. If false, the OSHashtable
maintains a cache to the element.
- Returns:
- The true constant if the hash table contains an
element with the specified key. The false constant if the
hash table does not.
- Throws: NullPointerException
- If key is null.
get
public synchronized Object get(Object key)
- Obtains the element mapped at the specified key and
maintains a cache from the OSHashtable object to the element.
This cache prevents the element from being garbage collected unless
the application evicts the entire OSHashtable.
If you prefer to not maintain the cache, invoke
get(key, noCache).
- Parameters:
- key - The key for the element you want to obtain.
- Returns:
- The element at the key, or null if no such key exists
or the object that it refers to is destroyed.
- Throws: NullPointerException
- If key is null.
- Overrides:
- get in class OSDictionary
get
public synchronized Object get(Object key,
boolean noCache)
- Obtains the element mapped at the specified key and optionally
maintains a cache from the OSHashtable object to the element.
Normally, the get() method maintains this cache,
which prevents the element from being garbage collected.
There is a potential performance penalty if an application
repeatedly invokes get() for the same key without
maintaining a cache. This is because there is no caching.
- Parameters:
- key - The key for the element you want to obtain.
- noCache - If true, the OSHashtable does
not maintain a cache to the returned element. This allows the
object to be garbage collected. If false, the OSHashtable
maintains a cache to the element.
- Returns:
- The element at the key or null if no such key exists or
the object that it refers to is destroyed.
- Throws: NullPointerException
- If key is null.
getKey
public synchronized Object getKey(Object key)
- Returns the actual key stored in the hash table for the given key
and maintains a cache from the OSHashtable
object to the element. Normally, the getKey() method
maintains this cache, which prevents the element from being
garbage collected.
There is a potential performance penalty if an application
repeatedly invokes getKey() for the same key without
maintaining a cache. This is because there is no caching.
- Parameters:
- key - The key to search for.
- Returns:
- The actual key stored in the hash table for the given key,
or null if no such key exists.
- Throws: NullPointerException
- If key is null.
- Overrides:
- getKey in class OSDictionary
getKey
public synchronized Object getKey(Object key,
boolean noCache)
- Returns the actual key stored in the hash table for the given key
and optionally maintains a cache from the OSHashtable
object to the element. Normally, the getKey() method
maintains this cache, which prevents the element from being
garbage collected.
There is a potential performance penalty if an application
repeatedly invokes getKey() for the same key without
maintaining a cache. This is because there is no caching.
- Parameters:
- key - The key to search for.
- noCache - If true, the OSHashtable does
not maintain a cache to the returned element. This allows the
object to be garbage collected. If false, the OSHashtable
maintains a cache to the element.
- Returns:
- The actual key stored in the hash table for the given key,
or null if no such key exists.
- Throws: NullPointerException
- If key is null.
put
public synchronized Object put(Object key,
Object value)
- Enter 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.
- Overrides:
- put in class OSDictionary
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.
- Overrides:
- remove in class OSDictionary
clear
public synchronized void clear()
- Removes all entries from the hash table.
- Overrides:
- clear in class OSDictionary
clone
public synchronized Object clone()
- Clones the object.
- Returns:
- The cloned object.
- Overrides:
- clone in class HashPersistent
toString
public synchronized String toString()
- Produces a printable representation of the object.
- Returns:
- A string that represents the object.
- Overrides:
- toString in class Object
- See Also:
- toString
Copyright © 1996, 1997 Object Design, Inc. All rights reserved.