org.erights.e.elib.tables
Class WeakValue

java.lang.Object
  |
  +--org.erights.e.elib.tables.WeakValue
All Implemented Interfaces:
Runnable

class WeakValue
extends Object
implements Runnable

Used to implement a key in a WeakValueMap implementation by being a value in a FlexMap.

Holds on to the actual value weakly. Is an HONORARY Selfless object, so it compares based on its equals() and hashCode() methods. A WeakValue is also a Runnable, since it stores itself as the reactor to be informed when its value is collected.

WeakValue's implementation of equals and hashCode does not satisfy the contract specified for HONORARY Selfless objects, but that's ok since the WeakValue class is only used in the implementation of WeakValueMap.

Author:
Mark Miller

Field Summary
private  Object myKey
          So I can remove the association that maps to me.
private  FlexMap myOptMap
          the map I'm in, that I need to remove myself from
private  WeakPtr myWeakPtr
          weakly holds the actual value
 
Constructor Summary
(package private) WeakValue(Object key, Object value, FlexMap map)
           
 
Method Summary
(package private)  Object getOptActual()
          If the actual value is still around, return it; else null.
 void run()
          Invoked sometime after the actual value has been gced.
 String toString()
          Suppressed: Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myKey

private final Object myKey
So I can remove the association that maps to me.


myWeakPtr

private final WeakPtr myWeakPtr
weakly holds the actual value


myOptMap

private FlexMap myOptMap
the map I'm in, that I need to remove myself from

Constructor Detail

WeakValue

WeakValue(Object key,
          Object value,
          FlexMap map)
Method Detail

run

public void run()
Invoked sometime after the actual value has been gced.

Specified by:
run in interface Runnable
See Also:
java.lang.Thread#run()

getOptActual

Object getOptActual()
If the actual value is still around, return it; else null.


toString

public String toString()
Description copied from class: Object
Suppressed: Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?