org.openbandy.util
Class TwoWayHashtable

java.lang.Object
  extended by org.openbandy.util.TwoWayHashtable

public class TwoWayHashtable
extends java.lang.Object

Wrapper for java.util.Hashtable with methods to get objects as well as well as keys by hash.

(c) Copyright P. Bolliger 2007, ALL RIGHTS RESERVED.

Version:
1.0
Author:
Philipp Bolliger (philipp@bolliger.name)

Constructor Summary
TwoWayHashtable()
           
 
Method Summary
 void clear()
          Removes all elements from the hashtable.
 boolean containsKey(java.lang.Object key)
          Check if the hashtable contains the given key object.
 boolean containsValue(java.lang.Object value)
          Check if the hashtable contains the given value object.
 java.lang.Object getKeyByValue(java.lang.Object value)
          Return the key of the hashtable using the value object.
 java.util.Enumeration getKeys()
          Return an enumeration of all key objects.
 java.lang.Object getValueByKey(java.lang.Object key)
          Returns the value objects using the key object as reference.
 java.util.Enumeration getValues()
          Return an enumeration of all value objects.
 void put(java.lang.Object key, java.lang.Object value)
          Put an value object into the hashtable using the key object as reference.
 java.lang.Object removeByKey(java.lang.Object key)
          Remove an element from the hashtable using the key.
 java.lang.Object removeByValue(java.lang.Object value)
          Remove an element from the hashtable using the value as key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TwoWayHashtable

public TwoWayHashtable()
Method Detail

put

public void put(java.lang.Object key,
                java.lang.Object value)
Put an value object into the hashtable using the key object as reference.

Parameters:
key - The key object.
value - The value object.

containsKey

public boolean containsKey(java.lang.Object key)
Check if the hashtable contains the given key object.

Parameters:
key - The key object to check for.
Returns:
True if the object is contained within the hashtable.

containsValue

public boolean containsValue(java.lang.Object value)
Check if the hashtable contains the given value object.

Parameters:
value - The value object to check for.
Returns:
True if the object is contained within the hashtable.

getValueByKey

public java.lang.Object getValueByKey(java.lang.Object key)
Returns the value objects using the key object as reference.

Parameters:
key - The key object.
Returns:
The value object if contained, null else.

getValues

public java.util.Enumeration getValues()
Return an enumeration of all value objects.

Returns:
Enumeration of value objects.

getKeys

public java.util.Enumeration getKeys()
Return an enumeration of all key objects.

Returns:
Enumeration of key objects.

getKeyByValue

public java.lang.Object getKeyByValue(java.lang.Object value)
Return the key of the hashtable using the value object.

Parameters:
value - Value object.
Returns:
The key object.

removeByKey

public java.lang.Object removeByKey(java.lang.Object key)
Remove an element from the hashtable using the key.

Parameters:
key - Key object.
Returns:
True if the object could be removed.

removeByValue

public java.lang.Object removeByValue(java.lang.Object value)
Remove an element from the hashtable using the value as key.

Parameters:
value - Value object.
Returns:
True if the object could be removed.

clear

public void clear()
Removes all elements from the hashtable.