|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.util.WeakCache
This class provides essentially a map with strongly referenced keys and weakly referenced values. Getting a value whose reference has been cleared gets null.
By default, when the reference to a value is found to have been cleared,
the corresponding key is removed. If the keyRetained
property
is set to true, the key is retained instead.
This class stands in contrast with WeakHashMap
, which is a
map with weakly referenced keys and strongly referenced values.
Nested Class Summary | |
static class |
WeakCache.Entry
A class whose instances wrap a key and its corresponding value. |
Constructor Summary | |
WeakCache()
|
Method Summary | |
void |
clear()
Clear all keys and values from this cache. |
boolean |
containsKey(java.lang.Object key)
|
java.util.List |
entries()
Creates a list of the key/value pairs of this map. |
java.lang.Object |
get(java.lang.Object key)
Gets a value corresponding to a key from this cache, or null if the key is not present or the reference to the value has been cleared. |
boolean |
isKeyRetained()
Gets whether keys are retained once the reference to the corresponding values is cleared. |
java.util.Iterator |
iterator()
Creates an iterator over the values of this map. |
java.util.Set |
keys()
Gets a set containing the keys of this cache. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Puts a value corresponding to a key into this cache. |
java.lang.Object |
remove(java.lang.Object key)
Removes a key and the corresponding value from this cache. |
void |
setKeyRetained(boolean retained)
Sets whether keys are retained once the reference to the corresponding value is cleared. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WeakCache()
Method Detail |
public void setKeyRetained(boolean retained)
public boolean isKeyRetained()
public boolean containsKey(java.lang.Object key)
public java.lang.Object get(java.lang.Object key)
keyRetained
property is false, the key is also removed from
the cache.
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
- value
-
public java.lang.Object remove(java.lang.Object key)
key
- The key to remove.
public java.util.Set keys()
public java.util.Iterator iterator()
public java.util.List entries()
List
of WeakCache.Entry
objects.public void clear()
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.