Class JOP.util.HashtableDB
All Packages Class Hierarchy This Package Previous Next Index Home
Class JOP.util.HashtableDB
java.lang.Object
|
+----JOP.util.HashtableDB
- public class HashtableDB
- extends Object
- implements Persistable
A HashtableDB implements a subset of the functionality
of a Hasthable. The HashtableDB supports the late
fetching of objects, ie objects are only fetched
from the database when they are referenced - hence
performance is improved. The semantics
of Hashtable are maintained so that HashtableDB and
Hasthable can be substituted for one another in applications
programs.
One of the main uses of HashtableDB is support indexed
collections of persistent objects.
Like a Hashtable when a HasthableDB is saved to a database by
calling streamOutObject(), the
hashtable, its keys and all referenced objects will
be automatically saved.
A typical application will have a 'root' HashtableDB with
a well known object id (read from an environment variable
etc). When this HashableDB is read it contains references
to other HashtableDB's and other application objects.
If you streamOutObject() a HashtableDB to a different
PersistManager than the one that was used to read the
HashtableDB (or first save the HashtableDB) then the
HashtableDB will be fully resolved (ie all referenced objects
will be read) before the HashtableDB is written to the second
PersistManager.
-
HashtableDB()
-
-
clear()
- Remove all entries from the hashtable
-
containsKey(Object)
- Test if the hashtable contains the given key and return 'true'
if the key is found.
-
defineObject(PersistController)
- Called by the PeristManager to define the hashtable.
-
elements()
- Return an enumerator of all objects in the hashtable.
-
get(Object)
- Retrieve an object from the hashtable with the given key.
-
keys()
- Return an enumerator of all objects over their key values.
-
put(Object, Object)
- Add a new object to the hashtable accessible by
the key value.
-
remove(Object)
- Remove an object with the given key from the hashtable.
-
streamIn(PersistController)
- Called by the PersistManager when this object is retrieved
from the persistent database.
-
streamOut(PersistController)
- Called by the PersistManager when this object is saved
to the persistent database.
HashtableDB
public HashtableDB()
clear
public synchronized void clear()
- Remove all entries from the hashtable
containsKey
public boolean containsKey(Object key)
- Test if the hashtable contains the given key and return 'true'
if the key is found.
remove
public void remove(Object key)
- Remove an object with the given key from the hashtable.
put
public synchronized void put(Object key,
Object obj)
- Add a new object to the hashtable accessible by
the key value.
get
public synchronized Object get(Object key)
- Retrieve an object from the hashtable with the given key. If
the object is not currently in memory or in the JOP cache
the object will be retrieved from the persistent database. Returns
'null' if the object is not in the hashtable or cannot be
retrieved.
Any exceptions from the PersistManager whilst retrieving the
object are caught and a strace trace is printed.
keys
public Enumeration keys()
- Return an enumerator of all objects over their key values. As the
'getNext()' method is called for the enumerator objects will
be retrieved from the persistent database (or the JOP cache).
elements
public Enumeration elements()
- Return an enumerator of all objects in the hashtable. As the
'getNext()' method is called for the enumerator objects will
be retrieved from the persistent database (or the JOP cache).
streamIn
public synchronized void streamIn(PersistController c) throws Exception
- Called by the PersistManager when this object is retrieved
from the persistent database.
To retrieve a HashtableDB object call the 'streamInObject()' method
or the 'streamInRoot()' method of the PersistManager.
streamOut
public synchronized void streamOut(PersistController c) throws Exception
- Called by the PersistManager when this object is saved
to the persistent database. To save a HashtableDB call the
'streamOutObject()' or 'streamOutRoot()' methods of the
PersistManager.
defineObject
public void defineObject(PersistController c) throws Exception
- Called by the PeristManager to define the hashtable.
All Packages Class Hierarchy This Package Previous Next Index Home