gov.nih.nlm.util
Class MultiMap

java.lang.Object
  extended bygov.nih.nlm.util.MultiMap

public class MultiMap
extends Object

Represents a Map that uses two keys. For use in an environment where you want to cache symmetric sets of data but with different top-level keys. e.g. cache the source lists from two different databases.


Constructor Summary
MultiMap()
          Instantiates a MultiMap.
 
Method Summary
 boolean containsKey(Object tk, Object key)
          Determines whether or not it contains the specified key.
 Set entrySet(Object tk)
          Returns the entry set for the specified "top" key.
 Object get(Object top_key, Object key)
          Returns the value for the key, using the specified "top" key.
 Map getMap(Object tk)
          Returns the Map for the key.
 Set keySet(Object tk)
          Returns the key set for the specified "top" key.
 void put(Object top_key, Object key, Object value)
          Puts the key/value pair into the map using the specified "top" key.
 void remove(Object top_key, Object key)
          Removes the entry for the specified keys.
 void setMap(Object tk, Map map)
          Sets the Map for the key.
 Collection values(Object tk)
          Returns the value for the specified "top" key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiMap

public MultiMap()
Instantiates a MultiMap.

Method Detail

put

public void put(Object top_key,
                Object key,
                Object value)
Puts the key/value pair into the map using the specified "top" key.

Parameters:
top_key - the top key
key - the key
value - the value

get

public Object get(Object top_key,
                  Object key)
Returns the value for the key, using the specified "top" key.

Parameters:
top_key - the top key
key - the key
Returns:
the value for the key, using the default "top" key

remove

public void remove(Object top_key,
                   Object key)
Removes the entry for the specified keys.

Parameters:
top_key - the top key
key - the key

values

public Collection values(Object tk)
Returns the value for the specified "top" key.

Parameters:
tk - the top key
Returns:
the value for the key, using the default "top" key

keySet

public Set keySet(Object tk)
Returns the key set for the specified "top" key.

Parameters:
tk - the top key
Returns:
the entry set for the key, using the default "top" key

entrySet

public Set entrySet(Object tk)
Returns the entry set for the specified "top" key.

Parameters:
tk - the top key
Returns:
the entry set for the key, using the default "top" key

containsKey

public boolean containsKey(Object tk,
                           Object key)
Determines whether or not it contains the specified key.

Parameters:
tk - the top key
key - the key to check
Returns:
true if it contains the key; false otherwise

setMap

public void setMap(Object tk,
                   Map map)
Sets the Map for the key.

Parameters:
tk - the top key
map - the map

getMap

public Map getMap(Object tk)
Returns the Map for the key.

Parameters:
tk - the top key
Returns:
the Map for the key, using the default "top" key


Copyright ©2005