Cache will automatically be removed
when its key or value is no longer in ordinary use.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| public static enum | Cache.
Represents a reference kind. |
| private static interface |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final Cache. | |
| private static final int | |
| private final ReferenceQueue | |
| private int | |
| private volatile Cache | |
| private int | |
| private final Cache. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final void | |
| public abstract V | Returns: a corresponding value for the specified keya key that can be used to create a value key)Creates a corresponding value for the specified key. |
| public final V | Returns: a value to which the specified key is mapped, ornull if there is no mapping for keythe key whose cached value is to be returned key)Returns the value to which the specified key is mapped,
or |
| private V | |
| private int | |
| private static int | |
| private Cache | Returns: a new array for the cache entriesrequested capacity MUST be a power of two size)Creates a new array for the cache entries. |
| public final void | remove(K
the key whose mapping is to be removed from this cache key)Removes the cached value that corresponds to the specified key. |
| private void | |
| private void |
| identity | back to summary |
|---|---|
| private final boolean identity | |
| keyKind | back to summary |
|---|---|
| private final Cache. | |
| MAXIMUM_CAPACITY | back to summary |
|---|---|
| private static final int MAXIMUM_CAPACITY | |
| queue | back to summary |
|---|---|
| private final ReferenceQueue<Object> queue | |
| size | back to summary |
|---|---|
| private int size | |
| table | back to summary |
|---|---|
| private volatile Cache<K, V>. | |
| threshold | back to summary |
|---|---|
| private int threshold | |
| valueKind | back to summary |
|---|---|
| private final Cache. | |
| Cache | back to summary |
|---|---|
| public Cache(Cache. Constructs an empty
| |
| Cache | back to summary |
|---|---|
| public Cache(Cache. Constructs an empty
| |
| clear | back to summary |
|---|---|
| public final void clear() Removes all of the mappings from this cache. It will be empty after this call returns. | |
| create | back to summary |
|---|---|
| public abstract V create(K key) Creates a corresponding value for the specified key.
| |
| get | back to summary |
|---|---|
| public final V get(K key) Returns the value to which the specified key is mapped,
or
| |
| getEntryValue | back to summary |
|---|---|
| private V getEntryValue(K key, int hash, Cache<K, V>. | |
| hash | back to summary |
|---|---|
| private int hash(Object key) Retrieves object hash code and applies a supplemental hash function
to the result hash, which defends against poor quality hash functions.
This is critical because
| |
| index | back to summary |
|---|---|
| private static int index(int hash, Object[] table) Returns index of the specified hash code in the given table. Note that the table size must be a power of two.
| |
| newTable | back to summary |
|---|---|
| private Cache Creates a new array for the cache entries.
| |
| remove | back to summary |
|---|---|
| public final void remove(K key) Removes the cached value that corresponds to the specified key.
| |
| removeStaleEntries | back to summary |
|---|---|
| private void removeStaleEntries() | |
| transfer | back to summary |
|---|---|
| private void transfer(Cache<K, V>. | |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final Cache. | |
| private volatile Cache | |
| private final Cache. |
| Access | Constructor and Description |
|---|---|
| private | CacheEntry(int
the hash code calculated for the entry key hash, K the entry key key, V the initial value of the entry value, Cache<K, V>.the next entry in a chain nextConstructs an entry for the cache. |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| private void |
| hash | back to summary |
|---|---|
| private final int hash | |
| key | back to summary |
|---|---|
| private final Cache. | |
| next | back to summary |
|---|---|
| private volatile Cache<K, V>. | |
| value | back to summary |
|---|---|
| private final Cache. | |
| CacheEntry | back to summary |
|---|---|
| private CacheEntry(int hash, K key, V value, Cache<K, V>. Constructs an entry for the cache.
| |
| matches | back to summary |
|---|---|
| private boolean matches(int hash, Object object) Determines whether the entry has the given key with the given hash code.
| |
| unlink | back to summary |
|---|---|
| private void unlink() Marks the entry as actually removed from the cache. | |
| Modifier and Type | Class and Description |
|---|---|
| private static class | Cache.
the type of object to refer T>This is an implementation of the |
| private static class | Cache.
the type of object to refer T>This is an implementation of the |
| private static class | Cache.
the type of object to refer T>This is an implementation of the |
| Modifier and Type | Field and Description |
|---|---|
| public static final Cache. | |
| public static final Cache. | |
| public static final Cache. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract < the type of object to refer T> Cache. | Returns: the reference to the specified objectthe owner of the reference, if needed owner, T the object to refer referent, ReferenceQueue<? super T> the queue to register the reference with,
or queue)null if registration is not requiredCreates a reference to the specified object. |
| public static Cache. | |
| public static Cache. |
| SOFT | back to summary |
|---|---|
| public static final Cache. | |
| STRONG | back to summary |
|---|---|
| public static final Cache. | |
| WEAK | back to summary |
|---|---|
| public static final Cache. | |
| Kind | back to summary |
|---|---|
| private Kind() | |
| create | back to summary |
|---|---|
| pack-priv abstract <T> Cache. Creates a reference to the specified object.
| |
| valueOf | back to summary |
|---|---|
| public static Cache. | |
| values | back to summary |
|---|---|
| public static Cache. | |
Cache.Ref interface
that uses the soft references that are cleared at the discretion
of the garbage collector in response to a memory request.
java.lang.ref.SoftReference
| Access | Constructor and Description |
|---|---|
| private | Soft(Object
the owner of the reference, if needed owner, T the non-null object to refer referent, ReferenceQueue<? super T> the queue to register the reference with,
or queue)null if registration is not requiredCreates a soft reference to the specified object. |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: the owner of the reference ornull if the owner is unknownImplements com. Returns the object that possesses information about the reference. |
| public T | Returns: the referred object ornull if it was collectedImplements com. Returns the object to refer. |
| public boolean | Returns: true if the referred object was collectedImplements com. Determines whether the referred object was taken by the garbage collector or not. |
| public void | removeOwner()
Implements com. Marks this reference as removed from the cache. |
| owner | back to summary |
|---|---|
| private Object owner | |
| Soft | back to summary |
|---|---|
| private Soft(Object owner, T referent, ReferenceQueue<? super T> queue) Creates a soft reference to the specified object.
| |
| getOwner | back to summary |
|---|---|
| public Object getOwner() Implements com. Returns the object that possesses information about the reference. | |
| getReferent | back to summary |
|---|---|
| public T getReferent() Implements com. Returns the object to refer.
| |
| isStale | back to summary |
|---|---|
| public boolean isStale() Implements com. Determines whether the referred object was taken by the garbage collector or not.
| |
| removeOwner | back to summary |
|---|---|
| public void removeOwner() Implements com. Marks this reference as removed from the cache.
| |
Cache.Ref interface
that uses the strong references that prevent their referents
from being made finalizable, finalized, and then reclaimed.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: the owner of the reference ornull if the owner is unknownImplements com. Returns the object that possesses information about the reference. |
| public T | Returns: the referred objectImplements com. Returns the object to refer. |
| public boolean | Returns: true if the referred object was collectedImplements com. Determines whether the referred object was taken by the garbage collector or not. |
| public void | removeOwner()
Implements com. Marks this reference as removed from the cache. |
| owner | back to summary |
|---|---|
| private Object owner | |
| referent | back to summary |
|---|---|
| private final T referent | |
| Strong | back to summary |
|---|---|
| private Strong(Object owner, T referent) Creates a strong reference to the specified object.
| |
| getOwner | back to summary |
|---|---|
| public Object getOwner() Implements com. Returns the object that possesses information about the reference. | |
| getReferent | back to summary |
|---|---|
| public T getReferent() Implements com. Returns the object to refer.
| |
| isStale | back to summary |
|---|---|
| public boolean isStale() Implements com. Determines whether the referred object was taken by the garbage collector or not.
| |
| removeOwner | back to summary |
|---|---|
| public void removeOwner() Implements com. Marks this reference as removed from the cache.
| |
Cache.Ref interface
that uses the weak references that do not prevent their referents
from being made finalizable, finalized, and then reclaimed.
java.lang.ref.WeakReference
| Access | Constructor and Description |
|---|---|
| private | Weak(Object
the owner of the reference, if needed owner, T the non-null object to refer referent, ReferenceQueue<? super T> the queue to register the reference with,
or queue)null if registration is not requiredCreates a weak reference to the specified object. |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: the owner of the reference ornull if the owner is unknownImplements com. Returns the object that possesses information about the reference. |
| public T | Returns: the referred object ornull if it was collectedImplements com. Returns the object to refer. |
| public boolean | Returns: true if the referred object was collectedImplements com. Determines whether the referred object was taken by the garbage collector or not. |
| public void | removeOwner()
Implements com. Marks this reference as removed from the cache. |
| owner | back to summary |
|---|---|
| private Object owner | |
| Weak | back to summary |
|---|---|
| private Weak(Object owner, T referent, ReferenceQueue<? super T> queue) Creates a weak reference to the specified object.
| |
| getOwner | back to summary |
|---|---|
| public Object getOwner() Implements com. Returns the object that possesses information about the reference. | |
| getReferent | back to summary |
|---|---|
| public T getReferent() Implements com. Returns the object to refer.
| |
| isStale | back to summary |
|---|---|
| public boolean isStale() Implements com. Determines whether the referred object was taken by the garbage collector or not.
| |
| removeOwner | back to summary |
|---|---|
| public void removeOwner() Implements com. Marks this reference as removed from the cache.
| |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: the owner of the reference ornull if the owner is unknownReturns the object that possesses information about the reference. |
| public T | |
| public boolean | Returns: true if the referred object was collectedDetermines whether the referred object was taken by the garbage collector or not. |
| public void |
| getOwner | back to summary |
|---|---|
| public Object getOwner() Returns the object that possesses information about the reference.
| |
| getReferent | back to summary |
|---|---|
| public T getReferent() Returns the object to refer.
| |
| isStale | back to summary |
|---|---|
| public boolean isStale() Determines whether the referred object was taken by the garbage collector or not.
| |
| removeOwner | back to summary |
|---|---|
| public void removeOwner() Marks this reference as removed from the cache. | |