org.sqlorm.metadatadumper
Class ThreeDHashMap<K1,K2,K3,V>

java.lang.Object
  extended by org.sqlorm.metadatadumper.ThreeDHashMap<K1,K2,K3,V>

public class ThreeDHashMap<K1,K2,K3,V>
extends Object

helper classes lended from the spiffy framework as we don't want to tie into using the official spiffyframework.jar just yet...

A 3-dimensional hashmap is a HashMap that enables you to refer to values via three keys rather than one. The underlying implementation is simply a HashMap containing HashMap containing a HashMap, each of which maps to values.


// TODO eventually some day, switch to the spiffy framework instead of having this class in the sqlorm.jar

Author:
Kasper B. Graversen

Constructor Summary
ThreeDHashMap()
           
 
Method Summary
 boolean containsKey(K1 firstKey, K2 secondKey)
          Existence check of a value (or null) mapped to the keys.
 boolean containsKey(K1 firstKey, K2 secondKey, K3 thirdKey)
          Existence check of a value (or null) mapped to the keys.
 HashMap<K2,HashMap<K3,V>> get(K1 firstKey)
          Fetch the outermost Hashmap .
 HashMap<K3,V> get(K1 firstKey, K2 secondKey)
          Fetch the innermost Hashmap .
 V get(K1 firstKey, K2 secondKey, K3 thirdKey)
          Fetch a value from the Hashmap .
 Set<K1> keySet()
          Returns a set of the keys of the outermost map.
 Object set(K1 firstKey, K2 secondKey, K3 thirdKey, V value)
          Insert a value
 int size()
          Returns the number of key-value mappings in this map for the first key.
 int size(K1 firstKey)
          Returns the number of key-value mappings in this map for the second key.
 int size(K1 firstKey, K2 secondKey)
          Returns the number of key-value mappings in this map for the third key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreeDHashMap

public ThreeDHashMap()
Method Detail

containsKey

public boolean containsKey(K1 firstKey,
                           K2 secondKey)
Existence check of a value (or null) mapped to the keys.

Parameters:
firstKey - first key
secondKey - second key
Returns:
true when an element (or null) has been stored with the keys

containsKey

public boolean containsKey(K1 firstKey,
                           K2 secondKey,
                           K3 thirdKey)
Existence check of a value (or null) mapped to the keys.

Parameters:
firstKey - first key
secondKey - second key
thirdKey - third key
Returns:
true when an element (or null) has been stored with the keys

get

public HashMap<K2,HashMap<K3,V>> get(K1 firstKey)
Fetch the outermost Hashmap .

Parameters:
firstKey - first key
Returns:
the the innermost hashmap

get

public HashMap<K3,V> get(K1 firstKey,
                         K2 secondKey)
Fetch the innermost Hashmap .

Parameters:
firstKey - first key
secondKey - second key
Returns:
the the innermost hashmap

get

public V get(K1 firstKey,
             K2 secondKey,
             K3 thirdKey)
Fetch a value from the Hashmap .

Parameters:
firstKey - first key
secondKey - second key
thirdKey - third key
Returns:
the element or null.

set

public Object set(K1 firstKey,
                  K2 secondKey,
                  K3 thirdKey,
                  V value)
Insert a value

Parameters:
firstKey - first key
secondKey - second key
thirdKey - third key
value - the value to be inserted. null may be inserted as well.
Returns:
null or the value the insert is replacing.

size

public int size()
Returns the number of key-value mappings in this map for the first key.

Returns:
Returns the number of key-value mappings in this map for the first key.

size

public int size(K1 firstKey)
Returns the number of key-value mappings in this map for the second key.

Returns:
Returns the number of key-value mappings in this map for the second key.

size

public int size(K1 firstKey,
                K2 secondKey)
Returns the number of key-value mappings in this map for the third key.

Returns:
Returns the number of key-value mappings in this map for the third key.

keySet

public Set<K1> keySet()
Returns a set of the keys of the outermost map.