com.triactive.jdo.util
Class SoftValueMap

java.lang.Object
  extended by com.triactive.jdo.util.ReferenceValueMap
      extended by com.triactive.jdo.util.SoftValueMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map

public class SoftValueMap
extends ReferenceValueMap

A java.util.Map implementation with soft values.

The values are stored as soft references. If map entry value object is not actively being used, i.e. no other object has a strong reference to it, it may become garbage collected at the discretion of the garbage collector (typically if the VM is low on memory). If this happens, the entry in the SoftValueMap corresponding to the value object will also be removed.

Author:
Mike Martin
See Also:
SoftReference

Nested Class Summary
 
Nested classes/interfaces inherited from class com.triactive.jdo.util.ReferenceValueMap
ReferenceValueMap.ValueReference
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
SoftValueMap()
           
SoftValueMap(int initialCapacity)
           
SoftValueMap(int initialCapacity, float loadFactor)
           
SoftValueMap(java.util.Map m)
           
 
Method Summary
protected  ReferenceValueMap.ValueReference newValueReference(java.lang.Object key, java.lang.Object value, java.lang.ref.ReferenceQueue queue)
          Returns a new Reference object to be inserted into the map.
 
Methods inherited from class com.triactive.jdo.util.ReferenceValueMap
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, reap, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftValueMap

public SoftValueMap()

SoftValueMap

public SoftValueMap(int initialCapacity)

SoftValueMap

public SoftValueMap(int initialCapacity,
                    float loadFactor)

SoftValueMap

public SoftValueMap(java.util.Map m)
Method Detail

newValueReference

protected ReferenceValueMap.ValueReference newValueReference(java.lang.Object key,
                                                             java.lang.Object value,
                                                             java.lang.ref.ReferenceQueue queue)
Description copied from class: ReferenceValueMap
Returns a new Reference object to be inserted into the map. Subclasses must implement this method to construct Reference objects of the desired type (e.g. SoftReference, etc.).

Specified by:
newValueReference in class ReferenceValueMap
Parameters:
key - The key that will be inserted.
value - The associated value to be referenced.
queue - The ReferenceQueue with which to register the new Reference object.


Copyright ? 2001 TriActive, Inc. All Rights Reserved.