arlut.csd.ganymede
Class DBObjectTable

java.lang.Object
  |
  +--arlut.csd.ganymede.DBObjectTable

public class DBObjectTable
extends java.lang.Object

A customized variant of the java.util.Hashtable class that is tuned for use in managing DBObjects in a Ganymede DBObjectBase.


Field Summary
private  java.util.Vector[] backPointerTable
          A collection of Vectors, one for each object in the database.
private  int count
          The total number of entries in the hash table.
private  float loadFactor
          The load factor for the hashtable.
private  DBObject[] table
          The hash table data.
private  int threshold
          Rehashes the table when count exceeds this threshold.
 
Constructor Summary
DBObjectTable()
          Constructs a new, empty DBObjectTable with a default capacity and load factor.
DBObjectTable(int initialCapacity)
          Constructs a new, empty DBObjectTable with the specified initial capacity and default load factor.
DBObjectTable(int initialCapacity, float loadFactor)
          Constructs a new, empty DBObjectTable with the specified initial capacity and the specified load factor.
 
Method Summary
 void clear()
          Clears this DBObjectTable.
 boolean contains(DBObject value)
          Tests if the DBObject value is contained in this DBObjectTable.
 boolean containsKey(int key)
          Tests if a DBObject with the specified object id is in this DBObjectTable.
 java.util.Enumeration elements()
          Returns an enumeration of the objects in this DBObjectTable.
 DBObject get(int key)
          Returns the DBObject with the specified key from this DBObjectTable, or null if no object with that id is in this table.
 DBObject getNoSync(int key)
          Returns the DBObject with the specified key from this DBObjectTable, or null if no object with that id is in this table.
 boolean isEmpty()
          Tests if this DBObjectTable contains no objects.
 void put(DBObject value)
          Inserts a DBObject into this DBObjectTable
 void putNoSync(DBObject value)
          Inserts a DBObject into this DBObjectTable.
 void putNoSyncNoRemove(DBObject value)
          Inserts a DBObject into this DBObjectTable.
protected  void rehash()
          Rehashes the contents of the DBObjectTable into a DBObjectTable with a larger capacity.
 void remove(int key)
          Removes the DBObject with the given id from this DBObjectTable.
 void removeNoSync(int key)
          Removes the DBObject with the given id from this DBObjectTable.
 int size()
          Returns the number of objects in this DBObjectTable.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

table

private transient DBObject[] table
The hash table data.

backPointerTable

private transient java.util.Vector[] backPointerTable
A collection of Vectors, one for each object in the database.

count

private transient int count
The total number of entries in the hash table.

threshold

private int threshold
Rehashes the table when count exceeds this threshold.

loadFactor

private float loadFactor
The load factor for the hashtable.
Constructor Detail

DBObjectTable

public DBObjectTable(int initialCapacity,
                     float loadFactor)
Constructs a new, empty DBObjectTable with the specified initial capacity and the specified load factor.
Parameters:
initialCapacity - the initial capacity of the hashtable.
loadFactor - a number between 0.0 and 1.0.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than or equal to zero, or if the load factor is less than or equal to zero.

DBObjectTable

public DBObjectTable(int initialCapacity)
Constructs a new, empty DBObjectTable with the specified initial capacity and default load factor.
Parameters:
initialCapacity - the initial capacity of the hashtable.

DBObjectTable

public DBObjectTable()
Constructs a new, empty DBObjectTable with a default capacity and load factor.
Method Detail

size

public int size()
Returns the number of objects in this DBObjectTable.
Returns:
the number of objects in this DBObjectTable.

isEmpty

public boolean isEmpty()
Tests if this DBObjectTable contains no objects.
Returns:
true if this DBObjectTable contains no values; false otherwise.

elements

public java.util.Enumeration elements()
Returns an enumeration of the objects in this DBObjectTable. Use the Enumeration methods on the returned object to fetch the elements sequentially.
Returns:
an enumeration of the objects in this DBObjectTable.
See Also:
Enumeration

contains

public boolean contains(DBObject value)
Tests if the DBObject value is contained in this DBObjectTable.
Parameters:
value - a DBObject to search for.
Throws:
NullPointerException - if the value is null.

containsKey

public boolean containsKey(int key)
Tests if a DBObject with the specified object id is in this DBObjectTable.
Parameters:
key - possible object id.

getNoSync

public DBObject getNoSync(int key)
Returns the DBObject with the specified key from this DBObjectTable, or null if no object with that id is in this table.

get

public DBObject get(int key)
Returns the DBObject with the specified key from this DBObjectTable, or null if no object with that id is in this table.

rehash

protected void rehash()
Rehashes the contents of the DBObjectTable into a DBObjectTable with a larger capacity. This method is called automatically when the number of keys in the hashtable exceeds this DBObjectTable's capacity and load factor.

putNoSync

public void putNoSync(DBObject value)
Inserts a DBObject into this DBObjectTable. This put is not sync'ed, and should only be used with higher level sync provisions.

put

public void put(DBObject value)
Inserts a DBObject into this DBObjectTable

putNoSyncNoRemove

public void putNoSyncNoRemove(DBObject value)
Inserts a DBObject into this DBObjectTable. This put is not sync'ed, and should only be used with higher level sync provisions.

removeNoSync

public void removeNoSync(int key)
Removes the DBObject with the given id from this DBObjectTable.

remove

public void remove(int key)
Removes the DBObject with the given id from this DBObjectTable.

clear

public void clear()
Clears this DBObjectTable.