org.strutsme.common
Class SafeHashtable

java.lang.Object
  extended by org.strutsme.common.SafeHashtable

public final class SafeHashtable
extends java.lang.Object

SafeHashtable is a hash table implementation that supports null values. This is required because the Hashtable implementation from CLDC 1.0 doesn't support this.

Version:
$Date$
Author:
rfalke

Constructor Summary
SafeHashtable()
          Each class should have one Constructor.
 
Method Summary
 void clear()
          Clears this hashtable so that it contains no keys.
 boolean containsKey(java.lang.Object key)
          Tests if the specified object is a key in this hashtable.
 boolean equals(java.lang.Object obj)
          
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 int hashCode()
          
 java.util.Enumeration keys()
          Returns an enumeration of the keys in this hashtable.
 void put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 void remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this hashtable.
 int size()
          Returns the number of keys in this hashtable.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SafeHashtable

public SafeHashtable()
Each class should have one Constructor. (PMD)

Method Detail

put

public void put(java.lang.Object key,
                java.lang.Object value)
Maps the specified key to the specified value in this hashtable. The value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - the hashtable key.
value - the value.
See Also:
Object.equals(Object), get(Object)

remove

public void remove(java.lang.Object key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters:
key - the key that needs to be removed.

clear

public void clear()
Clears this hashtable so that it contains no keys.


size

public int size()
Returns the number of keys in this hashtable.

Returns:
the number of keys in this hashtable.

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys in this hashtable.

Returns:
an enumeration of the keys in this hashtable.
See Also:
Enumeration

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which the specified key is mapped in this hashtable.

Parameters:
key - a key in the hashtable.
Returns:
the value to which the key is mapped in this hashtable;
See Also:
put(Object, Object)

containsKey

public boolean containsKey(java.lang.Object key)
Tests if the specified object is a key in this hashtable.

Parameters:
key - possible key.
Returns:
true if and only if the specified object is a key in this hashtable, as determined by the equals method; false otherwise.

toString

public java.lang.String toString()
Returns a string representation of the object. The exact format is a private implementation detail and subject to change.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object