org.datanucleus.util
Class WeakValueMap

java.lang.Object
  extended by org.datanucleus.util.ReferenceValueMap
      extended by org.datanucleus.util.WeakValueMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map

public class WeakValueMap
extends ReferenceValueMap

A java.util.Map implementation using weak reference values.

The values are stored in the map as weak references. If the garbage collector clears the reference, the corresponding key is automatically removed from the map.

See Also:
WeakReference

Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.util.ReferenceValueMap
ReferenceValueMap.ValueReference
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
WeakValueMap()
          Default Constructor
WeakValueMap(int initialCapacity)
          Constructor taking the initial capacity.
WeakValueMap(int initialCapacity, float loadFactor)
          Constructor taking the initial capacity and load factor.
WeakValueMap(java.util.Map m)
          Constructor taking a Map for definition.
 
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 org.datanucleus.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

WeakValueMap

public WeakValueMap()
Default Constructor


WeakValueMap

public WeakValueMap(int initialCapacity)
Constructor taking the initial capacity.

Parameters:
initialCapacity - The Initial capacity of the collection

WeakValueMap

public WeakValueMap(int initialCapacity,
                    float loadFactor)
Constructor taking the initial capacity and load factor.

Parameters:
initialCapacity - The Initial capacity of the collection
loadFactor - The Load Factor of the collection

WeakValueMap

public WeakValueMap(java.util.Map m)
Constructor taking a Map for definition.

Parameters:
m - The Map
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.
Returns:
The new ValueReference


Copyright © 2009. All Rights Reserved.