|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
net.nutch.util.SoftHashMap
A Map which uses SoftReference
s to keep track of values.
This class is suitable for use as a best-effort caching mechanism.
Under the hood, it is simply a HashMap
, which wraps it's
values with SoftReferences. Unlike HashMap
,
however, null values should not be used- they will be
indistinguisable from values which have been garbage collected.
Values should implement SoftHashMap.FinalizationNotifier
, so keys
can be cleaned up as values are garbage collected. If values are added
which do not support this interface, the associated keys will continue to be
referenced by this data structure until explicitly removed.
Expiration policy is determined by the JVM's implementation of
SoftReference
.
Nested Class Summary | |
static interface |
SoftHashMap.FinalizationListener
An interface for Object which accept notification when an another Object is finalized. |
static interface |
SoftHashMap.FinalizationNotifier
An interface for a Objects which can notify an object when they are finalized. |
Nested classes inherited from class java.util.Map |
Map.Entry |
Constructor Summary | |
SoftHashMap()
|
Method Summary | |
void |
clear()
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Not Implemented Note that the finalizer may invalidate the result an implementation would return. |
Set |
entrySet()
Not Implemented |
Object |
get(Object key)
|
boolean |
isEmpty()
|
Set |
keySet()
|
protected void |
purgeQueuedKeys()
|
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map. |
protected void |
queueKeyForDeletion(Object key)
|
Object |
remove(Object key)
|
int |
size()
|
Collection |
values()
Not Implemented |
Methods inherited from class java.util.AbstractMap |
clone, equals, hashCode, putAll, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode, putAll |
Constructor Detail |
public SoftHashMap()
Method Detail |
public void clear()
clear
in interface Map
protected void queueKeyForDeletion(Object key)
protected void purgeQueuedKeys()
public boolean containsKey(Object key)
get()
can be issued.
containsKey
in interface Map
public boolean containsValue(Object value) throws UnsupportedOperationException
containsValue
in interface Map
UnsupportedOperationException
public Set entrySet() throws UnsupportedOperationException
entrySet
in interface Map
UnsupportedOperationException
public Object get(Object key)
get
in interface Map
public boolean isEmpty()
isEmpty
in interface Map
public Set keySet()
keySet
in interface Map
public Object put(Object key, Object value)
Note:
value
must implemnt FinalizationNotifier
for keys to be freed properly when values are garbage collected.
public Object remove(Object key)
remove
in interface Map
public int size()
size
in interface Map
public Collection values() throws UnsupportedOperationException
values
in interface Map
UnsupportedOperationException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |