com.triactive.jdo.util
Class WeakValueMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended bycom.triactive.jdo.util.ReferenceValueMap
          extended bycom.triactive.jdo.util.WeakValueMap
All Implemented Interfaces:
java.util.Map

public class WeakValueMap
extends com.triactive.jdo.util.ReferenceValueMap

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 inherited from class java.util.Map
java.util.Map.Entry
 
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)
Description copied from class: com.triactive.jdo.util.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.).

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)

get

public java.lang.Object get(java.lang.Object key)

size

public int size()

isEmpty

public boolean isEmpty()

containsKey

public boolean containsKey(java.lang.Object key)

containsValue

public boolean containsValue(java.lang.Object value)

keySet

public java.util.Set keySet()

values

public java.util.Collection values()

entrySet

public java.util.Set entrySet()

remove

public java.lang.Object remove(java.lang.Object key)

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object o)

toString

public java.lang.String toString()


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