org.apache.jdo.util
Class WeakValueHashMap.WeakValue

java.lang.Object
  extended byjava.lang.ref.Reference
      extended byjava.lang.ref.WeakReference
          extended byorg.apache.jdo.util.WeakValueHashMap.WeakValue
Enclosing class:
WeakValueHashMap

private static class WeakValueHashMap.WeakValue
extends java.lang.ref.WeakReference

We need this special class to keep the backward reference from the value to the key, so that we are able to remove the key if the value is garbage collected.


Nested Class Summary
 
Nested classes inherited from class java.lang.ref.Reference
 
Field Summary
private  java.lang.Object key
          It's the same as the key in the map.
 
Fields inherited from class java.lang.ref.Reference
 
Constructor Summary
private WeakValueHashMap.WeakValue(java.lang.Object value)
           
private WeakValueHashMap.WeakValue(java.lang.Object key, java.lang.Object value, java.lang.ref.ReferenceQueue queue)
           
 
Method Summary
private static WeakValueHashMap.WeakValue create(java.lang.Object value)
          Creates a new weak reference without adding it to a ReferenceQueue.
private static WeakValueHashMap.WeakValue create(java.lang.Object key, java.lang.Object value, java.lang.ref.ReferenceQueue queue)
          Creates a new weak reference and adds it to the given queue.
 boolean equals(java.lang.Object obj)
          A WeakValue is equal to another WeakValue iff they both refer to objects that are, in turn, equal according to their own equals methods.
 int hashCode()
           
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, get, isEnqueued
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

private java.lang.Object key
It's the same as the key in the map. We need the key to remove the value if it is garbage collected.

Constructor Detail

WeakValueHashMap.WeakValue

private WeakValueHashMap.WeakValue(java.lang.Object value)

WeakValueHashMap.WeakValue

private WeakValueHashMap.WeakValue(java.lang.Object key,
                                   java.lang.Object value,
                                   java.lang.ref.ReferenceQueue queue)
Method Detail

create

private static WeakValueHashMap.WeakValue create(java.lang.Object value)
Creates a new weak reference without adding it to a ReferenceQueue.


create

private static WeakValueHashMap.WeakValue create(java.lang.Object key,
                                                 java.lang.Object value,
                                                 java.lang.ref.ReferenceQueue queue)
Creates a new weak reference and adds it to the given queue.


equals

public boolean equals(java.lang.Object obj)
A WeakValue is equal to another WeakValue iff they both refer to objects that are, in turn, equal according to their own equals methods.


hashCode

public int hashCode()