org.nodal.util
Class CacheMap

java.lang.Object
  extended byorg.nodal.util.CacheMap

public class CacheMap
extends java.lang.Object

A Map useful for caching key/value pairs. Both the key and value side references are weak, so they do not artificially extend the lifetime of the objects stored in the Map.


Constructor Summary
CacheMap()
           
 
Method Summary
 void clear()
          Clear all associations out of the cache.
 java.lang.Object get(java.lang.Object key)
          Find the object referenced by key in the Map.
 java.lang.Object put(java.lang.Object key, java.lang.Object val)
          Place a reference to a key/value pair into the cache.
 void remove(java.lang.Object key)
          Remove an entry from the CacheMap.
 java.util.Iterator values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheMap

public CacheMap()
Method Detail

get

public java.lang.Object get(java.lang.Object key)
Find the object referenced by key in the Map.

Parameters:
key - the key used to look up the value
Returns:
the associated object or null if not found or unreferenceable.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object val)
Place a reference to a key/value pair into the cache.

Parameters:
key - the key used to look up value
val - the value associated with the key
Returns:
the value placed in the cache

clear

public void clear()
Clear all associations out of the cache.


values

public java.util.Iterator values()

remove

public void remove(java.lang.Object key)
Remove an entry from the CacheMap.

Parameters:
key - the Object to be removed from the cache