com.jniwrapper.util
Class SoftCache

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--com.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 un-reachable.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
SoftCache()
           
SoftCache(int initialCapacity)
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Lookups cache for the key
 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.

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.HashMap
Parameters:
key - key with which the specified value is to be associated.
value - 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)
Lookups cache for the key

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.HashMap
Parameters:
key - key for which 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 null value was associated with the key.