APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.beans

public final Class WeakCache<K, V>

extends Object
Class Inheritance
Imports
java.lang.ref.Reference, .WeakReference, java.util.Map, .WeakHashMap

A hashtable-based cache with weak keys and weak values. An entry in the map will be automatically removed when its key is no longer in the ordinary use. A value will be automatically removed as well when it is no longer in the ordinary use.
Author
Sergey A. Malenkov
Since
1.7

Field Summary

Modifier and TypeField and Description
private final Map<K, Reference<V>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Removes all of the mappings from this cache.

public V

Returns:

a value to which the specified key is mapped
get
(K
the key whose associated value is returned
key
)

Returns a value to which the specified key is mapped, or null if this map contains no mapping for the key.

public void
put(K
the key with which the specified value is associated
key
,
V
the value to be associated with the specified key
value
)

Associates the specified value with the specified key.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapback to summary
private final Map<K, Reference<V>> map

Constructor Detail

WeakCacheback to summary
public WeakCache()

Method Detail

clearback to summary
public void clear()

Removes all of the mappings from this cache.

getback to summary
public V get(K key)

Returns a value to which the specified key is mapped, or null if this map contains no mapping for the key.

Parameters
key:K

the key whose associated value is returned

Returns:V

a value to which the specified key is mapped

putback to summary
public void put(K key, V value)

Associates the specified value with the specified key. Removes the mapping for the specified key from this cache if it is present and the specified value is null. If the cache previously contained a mapping for the key, the old value is replaced by the specified value.

Parameters
key:K

the key with which the specified value is associated

value:V

the value to be associated with the specified key