com.triactive.jdo.util
Class WeakValueMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by com.triactive.jdo.util.WeakValueMap
All Implemented Interfaces:
java.util.Map

public class WeakValueMap
extends java.util.AbstractMap

A java.util.Map implementation with weak 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.

Author:
Mike Martin
See Also:
WeakReference

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  java.lang.ref.ReferenceQueue refQueue
           
 
Constructor Summary
WeakValueMap()
           
WeakValueMap(int initialCapacity)
           
WeakValueMap(int initialCapacity, float loadFactor)
           
WeakValueMap(java.util.Map m)
           
 
Method Summary
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(java.lang.Object key)
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set keySet()
           
protected  java.lang.ref.Reference newReference(java.lang.Object value)
          Returns a new Reference object to be inserted into the map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 java.lang.String toString()
           
 java.util.Collection values()
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, putAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

refQueue

protected final java.lang.ref.ReferenceQueue refQueue
Constructor Detail

WeakValueMap

public WeakValueMap()

WeakValueMap

public WeakValueMap(int initialCapacity)

WeakValueMap

public WeakValueMap(int initialCapacity,
                    float loadFactor)

WeakValueMap

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

newReference

protected java.lang.ref.Reference newReference(java.lang.Object value)
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.).

Parameters:
value - The associated value to be referenced.
Returns:
A new Reference object to be inserted into the map.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.AbstractMap

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.AbstractMap

size

public int size()
Specified by:
size in interface java.util.Map
Overrides:
size in class java.util.AbstractMap

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class java.util.AbstractMap

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map
Overrides:
containsKey in class java.util.AbstractMap

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map
Overrides:
containsValue in class java.util.AbstractMap

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map
Overrides:
keySet in class java.util.AbstractMap

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map
Overrides:
values in class java.util.AbstractMap

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
Specified by:
entrySet in class java.util.AbstractMap

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.AbstractMap

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.util.AbstractMap

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.util.AbstractMap

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractMap


Copyright ? 2001-2007 The TJDO Project All Rights Reserved.