|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.javatools.util.WeakCache<K,V>
public class WeakCache<K,V>
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<K,V> 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<WeakCache.Entry<K,V>> |
entries() Creates a list of the key/value pairs of this map. |
V |
get(K 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<V> |
iterator() Creates an iterator over the values of this map. |
java.util.Set<K> |
keys() Gets a set containing the keys of this cache. |
V |
put(K key, V value) Puts a value corresponding to a key into this cache. |
V |
remove(K 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 V get(K key)
keyRetained
property is false, the key is also removed from the cache.public V put(K key, V value)
key
-value
-public V remove(K key)
key
- The key to remove.public java.util.Set<K> keys()
public java.util.Iterator<V> iterator()
Iterator.remove()
on the returned Iterator
will throw UnsupportedOperationException
.public java.util.List<WeakCache.Entry<K,V>> entries()
List
of WeakCache.Entry
objects.public void clear()
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |