com.taco.data
Class SoftValueMap.SoftValue

java.lang.Object
  extended by java.lang.ref.Reference
      extended by java.lang.ref.SoftReference
          extended by com.taco.data.SoftValueMap.SoftValue
Enclosing class:
SoftValueMap

protected class SoftValueMap.SoftValue
extends java.lang.ref.SoftReference

The values actually put into the storage map. This class extends SoftReference so no strong references are kept to the values. It contains a strong reference to the key that was associated with the value, for easy map removal once this reference is cleared.


Field Summary
protected  java.lang.Object _key
          The key that this value is for.
protected  long _version
          Initially, this is set to the version of the map at this instance's creation time.
 
Constructor Summary
SoftValueMap.SoftValue(java.lang.Object key, java.lang.Object referent)
           
 
Method Summary
 void invalidate()
          Invalidate the value, marking it so that the key / value pair won't be removed from the map when the reference is cleared.
 boolean isValid()
          Return true if this value is still part of the map.
 
Methods inherited from class java.lang.ref.SoftReference
get
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, isEnqueued
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_key

protected java.lang.Object _key
The key that this value is for. This helps the removal of the value from the map once the reference is cleared. This can be set to null by invalidate() so that when the value is explicitly removed, a new mapping with the same key won't be removed when the reference is cleared.


_version

protected long _version
Initially, this is set to the version of the map at this instance's creation time. If the map is cleared, its version is incremented, so it won't match this version.

Constructor Detail

SoftValueMap.SoftValue

public SoftValueMap.SoftValue(java.lang.Object key,
                              java.lang.Object referent)
Method Detail

isValid

public boolean isValid()
Return true if this value is still part of the map. This won't be the case if the value was removed or replaced, or if the map was cleared.


invalidate

public void invalidate()
Invalidate the value, marking it so that the key / value pair won't be removed from the map when the reference is cleared.