ewe.util
Class WeakHashtable

java.lang.Object
  extended byewe.util.WeakHashtable

public class WeakHashtable
extends Object

A WeakHashtable is used to store data that may be garbage collected. The keys for the data are stored in the hashtable normally, but the data is stored via a weak reference.


Field Summary
protected  Hashtable table
           
 
Constructor Summary
WeakHashtable()
           
WeakHashtable(int initialCapacity)
           
WeakHashtable(int initialCapacity, float loadFactor)
           
 
Method Summary
 void clean()
          Remove all entries that have been garbage collected already.
 void clear()
          Remove all data in the table.
 Object get(Object key)
          Return the object associated with the key.
 Enumeration keys()
          Return an Enumeration on all the keys in the WeakHashtable.
 void put(Object key, Object data)
          Put data into the table with the specified key.
 void remove(Object key)
          Remove the entry with the specified key.
 int size()
          Return the number of keys in the WeakHashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

table

protected Hashtable table
Constructor Detail

WeakHashtable

public WeakHashtable(int initialCapacity,
                     float loadFactor)

WeakHashtable

public WeakHashtable(int initialCapacity)

WeakHashtable

public WeakHashtable()
Method Detail

put

public void put(Object key,
                Object data)
Put data into the table with the specified key.

Parameters:
key - the key to associate with the data.
data - the data that will be stored weakly in the table.

get

public Object get(Object key)
Return the object associated with the key. If none exists, or if the data object has been garbage collected, it returns null.

Parameters:
key - the key to search on.
Returns:
the object associated with the key or null if none exists or if the data has been garbage collected.

remove

public void remove(Object key)
Remove the entry with the specified key.


clear

public void clear()
Remove all data in the table.


clean

public void clean()
Remove all entries that have been garbage collected already.


size

public int size()
Return the number of keys in the WeakHashtable.


keys

public Enumeration keys()
Return an Enumeration on all the keys in the WeakHashtable.