org.intermine.util
Class WeakReferenceMap<K,V>

java.lang.Object
  extended by org.intermine.util.ReferenceMap<K,V>
      extended by org.intermine.util.WeakReferenceMap<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Implemented Interfaces:
java.util.Map<K,V>
Direct Known Subclasses:
WeakReferenceHashMap

public abstract class WeakReferenceMap<K,V>
extends ReferenceMap<K,V>

This is a Map implementation designed specifically for people intending to create a cache. The keys are held strongly, but the values are held weakly, so the values can be garbage-collected. When an entry is garbage-collected, its key is removed from the Map on the next Map activity. Subclasses of this map are required to provide the actual Map functionality.

The entrySet() and values() methods of this class do not work.

See Also:
WeakReference

Nested Class Summary
 
Nested classes/interfaces inherited from class org.intermine.util.ReferenceMap
ReferenceMap.ReferenceWithKey<K>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.intermine.util.ReferenceMap
name, NULL_VALUE, queue, subMap
 
Constructor Summary
WeakReferenceMap()
           
 
Method Summary
protected  org.intermine.util.WeakReferenceMap.WeakReferenceWithKey<K> newRef(java.lang.Object value, java.lang.ref.ReferenceQueue<java.lang.Object> queue, K key)
          Returns a new WeakReferenceWithKey object for the given objects.
 
Methods inherited from class org.intermine.util.ReferenceMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakReferenceMap

public WeakReferenceMap()
Method Detail

newRef

protected org.intermine.util.WeakReferenceMap.WeakReferenceWithKey<K> newRef(java.lang.Object value,
                                                                             java.lang.ref.ReferenceQueue<java.lang.Object> queue,
                                                                             K key)
Returns a new WeakReferenceWithKey object for the given objects.

Specified by:
newRef in class ReferenceMap<K,V>
Parameters:
value - an Object
queue - a ReferenceQueue
key - an Object
Returns:
a WeakReferenceWithKey object