com.jniwrapper.util
Class SoftCache

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended bycom.jniwrapper.util.SoftCache
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class SoftCache
extends java.util.HashMap

SoftCache is a Map that provides caching and retrieving of objects via SoftReference. Entries put in the cache are cleared when the value objects become unreachable.

See Also:
Serialized Form

Constructor Summary
SoftCache()
           
SoftCache(int initialCapacity)
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Looks for the key in the cache.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates the passed key with the value via SoftReference.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

SoftCache

public SoftCache(int initialCapacity)

SoftCache

public SoftCache()
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Associates the passed key with the value via SoftReference.

Parameters:
key - a key with which the specified value is to be associated.
value - a value to be associated with the key.
Returns:
previously associated value or null if there was no value associated, or if it became unreachable. A null value can also be returned, if it was previously associated with the key.

get

public java.lang.Object get(java.lang.Object key)
Looks for the key in the cache.

Parameters:
key - a key for which the value should be returned.
Returns:
a cached object or null if the entry for the passed key is missing, or if the value become unreachable, or if the null value was associated with the key.