org.exolab.core.database.recman
Class PMDHashMap

java.lang.Object
  extended byorg.exolab.core.foundation.PersistentObject
      extended byorg.exolab.core.database.recman.PMDHashMap
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, HashMapIfc, PersistentCapableIfc, java.io.Serializable

public class PMDHashMap
extends PersistentObject
implements HashMapIfc, java.io.Externalizable

This is an implementation of the HashMapIfc specific to the page managed database where references to objects are managed as PMDHandle instances rather than the objects themselves. This is necessary to optimise the concurrency and performance of the database.

In addition this class deals with PersistentObjects rather than just Object instance, since it assumes you are using this clas in a persistence context. Therefore some method, that take an Object may throw a runtime exception if the objects are not of this type.

Finally, an instance of this class is created within the context of a session and within a valid transaction....which I don't have a plan for

Instrument for better serialization by overriding the writeObject and readObject methods in a later version

Version:
$Revision: 1.4 $ $Date: 2001/06/12 07:11:35 $
Author:
Jim Alateras
See Also:
Serialized Form

Constructor Summary
PMDHashMap()
           
 
Method Summary
 void clear()
          Clear the map
 boolean containsKey(java.lang.Object key)
          Return true if the specified key maps to an element in the map
 boolean containsValue(PersistentCapableIfc element)
          Test to see whether the map contains the specified value
 java.util.Enumeration elements()
          Return an enumeration of all the elements in the map
 PersistentCapableIfc get(java.lang.Object key)
          Return the object mapped to this key.
 java.lang.Object getMapObject()
          Return a refernece to the enclosed map.
 boolean isEmpty()
          Test for an empty hashmap
 java.util.Enumeration keys()
          Return the enumeration of all keys in the map
 PersistentCapableIfc put(java.lang.Object key, PersistentCapableIfc element)
          Add the key and associated element to the map and return a reference to the object.
 void readExternal(java.io.ObjectInput stream)
           
 PersistentCapableIfc remove(java.lang.Object key)
          Remove the object mapped to the specified key from the map and return it to the client
 int size()
          Return the size of the map
 void writeExternal(java.io.ObjectOutput stream)
           
 
Methods inherited from class org.exolab.core.foundation.PersistentObject
clone, equals, getId, getMinimumObjectSize, getObjectId, getObjectVersion, getVersion, setId, setMinimumObjectSize, setObjectId, setObjectVersion, setVersion
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exolab.core.foundation.PersistentCapableIfc
getMinimumObjectSize, getObjectId, getObjectVersion, setMinimumObjectSize
 

Constructor Detail

PMDHashMap

public PMDHashMap()
Method Detail

size

public int size()
Return the size of the map

Specified by:
size in interface HashMapIfc
Returns:
int

isEmpty

public boolean isEmpty()
Test for an empty hashmap

Specified by:
isEmpty in interface HashMapIfc
Returns:
boolean true if empty; false otherwise

keys

public java.util.Enumeration keys()
Return the enumeration of all keys in the map

Specified by:
keys in interface HashMapIfc
Returns:
Enumeration

elements

public java.util.Enumeration elements()
Return an enumeration of all the elements in the map

Specified by:
elements in interface HashMapIfc
Returns:
Enumeration

containsValue

public boolean containsValue(PersistentCapableIfc element)
Test to see whether the map contains the specified value

Specified by:
containsValue in interface HashMapIfc
Parameters:
element - element to test against
Returns:
boolean true if key is mapped; false otherwise

containsKey

public boolean containsKey(java.lang.Object key)
Return true if the specified key maps to an element in the map

Specified by:
containsKey in interface HashMapIfc
Parameters:
key - key to test against
Returns:
boolean true if it maps; false otherwise

get

public PersistentCapableIfc get(java.lang.Object key)
Return the object mapped to this key.

Specified by:
get in interface HashMapIfc
Parameters:
key - key to lookup
Returns:
PersistentCapableIfc

put

public PersistentCapableIfc put(java.lang.Object key,
                                PersistentCapableIfc element)
Add the key and associated element to the map and return a reference to the object. In this implementation of the HashMapIfc the element must also be of type PersistentCapableIfc

Specified by:
put in interface HashMapIfc
Parameters:
key - key to map
element - corresponding element
Returns:
PersistentCapableIfc

remove

public PersistentCapableIfc remove(java.lang.Object key)
Remove the object mapped to the specified key from the map and return it to the client

Specified by:
remove in interface HashMapIfc
Parameters:
key - key to remove

clear

public void clear()
Clear the map

Specified by:
clear in interface HashMapIfc

getMapObject

public java.lang.Object getMapObject()
Return a refernece to the enclosed map. To be used it will have be cast to the Hashtable

Specified by:
getMapObject in interface HashMapIfc
Returns:
Object

writeExternal

public void writeExternal(java.io.ObjectOutput stream)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class PersistentObject
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput stream)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class PersistentObject
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 1999-2005 The Exolab Group. All Rights Reserved.