Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.javatools.util
Class Maps.AbstractCacheMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

java.lang.Object
  extended by oracle.javatools.util.Maps.AbstractHashMap<K,V,E>
      extended by oracle.javatools.util.Maps.AbstractLinkedHashMap<K,V,E>
          extended by oracle.javatools.util.Maps.AbstractCacheMap<K,V,E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
Direct Known Subclasses:
Maps.CacheMap
Enclosing class:
Maps

public abstract static class Maps.AbstractCacheMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>
extends Maps.AbstractLinkedHashMap<K,V,E>

See Also:
Serialized Form

Nested Class Summary
static class Maps.AbstractCacheMap.MappingType
          The types of references to values supported.
static class Maps.AbstractCacheMap.ReferenceType
          The types of references to values supported.
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static Maps.AbstractCacheMap.MappingType CANONICAL
           
static Maps.AbstractCacheMap.ReferenceType HARD
           
static Maps.AbstractCacheMap.MappingType NONCANONICAL
           
static Maps.AbstractCacheMap.ReferenceType SOFT
           
static Maps.AbstractCacheMap.ReferenceType WEAK
           
 
Fields inherited from class oracle.javatools.util.Maps.AbstractHashMap
DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, MAXIMUM_CAPACITY
 
Constructor Summary
Maps.AbstractCacheMap(Maps.CacheStrategy<K,V,E> strategy)
          Constructs an empty cache map.
 
Method Summary
protected abstract  E createDefaultEntry(int hashCode, K key, V value, E next)
           
protected  E createEntry(int hashCode, K key, V value, E next)
          Creates an entry for this map.
protected abstract  E createSoftEntry(int hashCode, K key, V value, E next)
           
protected abstract  E createWeakEntry(int hashCode, K key, V value, E next)
           
protected  void entryAccessed(E entry)
          Invoked when the value of an existing entry is accessed by Maps.AbstractHashMap.get(java.lang.Object).
protected  void entryAdded(E entry)
          Invoked when a new entry is added to this map.
protected  void entryChanged(E oldEntry, V oldValue, E newEntry)
          Invoked when the value of an existing entry is changed.
protected  void entryEvicted(E entry)
          Invoked when an existing entry is evicted by Maps.AbstractLinkedHashMap.evictExistingEntry(E), e.g., because Maps.AbstractLinkedHashMap.removeEldestEntry(E) returned true.
protected  void entryPurged(E entry)
          Invoked when an existing entry is purged by Maps.AbstractHashMap.purgeEntry(E) after its value has been garbage collected.
protected  void entryRemoved(E entry)
          Invoked when an existing entry is removed by a remove method of this map, of a view collection of this map, or of an iterator of a view collection of this map
protected  void evictExistingEntry(E entry)
          Evicts an existing entry from this map.
 Maps.AbstractCacheMap.MappingType getMappingType()
          Gets the mapping type for this map.
 Maps.CacheStrategy<K,V,E> getStrategy()
          Gets the strategy used by this map.
 Maps.AbstractCacheMap.ReferenceType getValueReferenceType()
          Gets the value reference type for this map.
protected  void mapChanged()
          Invoked when the map has changed.
protected  boolean removeEldestEntry(E eldest)
          Gets whether to evict the eldest entry from this map.
 void setStrategy(Maps.CacheStrategy<K,V,E> strategy)
          Sets the strategy used by this map.
 
Methods inherited from class oracle.javatools.util.Maps.AbstractLinkedHashMap
clear, createEntryIterator, createEntrySetIterator, createKeySetIterator, createValuesIterator, getEldestEntry
 
Methods inherited from class oracle.javatools.util.Maps.AbstractHashMap
addEntry, capacity, change, clone, containsKey, containsValue, entrySet, equals, get, getChangeCount, getEntry, getQueue, hashCode, isEmpty, keyEquals, keyHashCode, keySet, loadFactor, mapConstructed, mapInitialized, purge, purgeEntry, put, putAll, remove, removeExistingEntry, removeKey, size, toString, valueEquals, valueHashCode, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HARD

public static final Maps.AbstractCacheMap.ReferenceType HARD

SOFT

public static final Maps.AbstractCacheMap.ReferenceType SOFT

WEAK

public static final Maps.AbstractCacheMap.ReferenceType WEAK

CANONICAL

public static final Maps.AbstractCacheMap.MappingType CANONICAL

NONCANONICAL

public static final Maps.AbstractCacheMap.MappingType NONCANONICAL
Constructor Detail

Maps.AbstractCacheMap

public Maps.AbstractCacheMap(Maps.CacheStrategy<K,V,E> strategy)
Constructs an empty cache map.

Method Detail

setStrategy

public void setStrategy(Maps.CacheStrategy<K,V,E> strategy)
Sets the strategy used by this map. The capacity, load factor, value reference type, and mapping type will not be changed.


getStrategy

public Maps.CacheStrategy<K,V,E> getStrategy()
Gets the strategy used by this map.


getValueReferenceType

public Maps.AbstractCacheMap.ReferenceType getValueReferenceType()
Gets the value reference type for this map.


getMappingType

public Maps.AbstractCacheMap.MappingType getMappingType()
Gets the mapping type for this map.


createEntry

protected final E createEntry(int hashCode,
                              K key,
                              V value,
                              E next)
Creates an entry for this map.

The Maps.AbstractCacheMap implementation delegates to createDefaultEntry(int, K, V, E), createSoftEntry(int, K, V, E), or createWeakEntry(int, K, V, E) as indicated by getValueReferenceType().

Specified by:
createEntry in class Maps.AbstractHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>
Parameters:
hashCode - The hashCode of the key for this entry.
key - The key for this entry.
value - The value for this entry.
next - The entry to follow this entry in the entry chain.

createDefaultEntry

protected abstract E createDefaultEntry(int hashCode,
                                        K key,
                                        V value,
                                        E next)

createSoftEntry

protected abstract E createSoftEntry(int hashCode,
                                     K key,
                                     V value,
                                     E next)

createWeakEntry

protected abstract E createWeakEntry(int hashCode,
                                     K key,
                                     V value,
                                     E next)

mapChanged

protected final void mapChanged()
Description copied from class: Maps.AbstractLinkedHashMap
Invoked when the map has changed. After the map is initialized (see Maps.AbstractHashMap.mapInitialized()), it only changes when entries are added or removed. This method is invoked before the associated Maps.AbstractHashMap.entryAdded(E), Maps.AbstractHashMap.entryRemoved(E), or Maps.AbstractHashMap.entryAccessed(E) method is invoked.

The Maps.AbstractHashMap implementation does nothing.

For subclasses of Maps.AbstractLinkedHashMap, this method is also invoked when iteration order is by access and an entry is accessed.

The Maps.AbstractLinkedHashMap implementation does nothing.

Overrides:
mapChanged in class Maps.AbstractLinkedHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

entryAdded

protected final void entryAdded(E entry)
Description copied from class: Maps.AbstractHashMap
Invoked when a new entry is added to this map. After the map is initialized (see Maps.AbstractHashMap.mapInitialized()), entries are only added by Maps.AbstractHashMap.put(K, V).

The Maps.AbstractHashMap implementation does nothing.

Overrides:
entryAdded in class Maps.AbstractHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

entryChanged

protected final void entryChanged(E oldEntry,
                                  V oldValue,
                                  E newEntry)
Description copied from class: Maps.AbstractHashMap
Invoked when the value of an existing entry is changed. After the map is initialized (see Maps.AbstractHashMap.mapInitialized()), entries are only changed by Maps.AbstractHashMap.put(K, V).

If the entry to change was mutable, its value is changed with Map.Entry#setValue and oldEntry and newEntry are the same object. If the entry to change was not mutable, a new entry must be created and oldEntry and newEntry are different objects.

When a client directly invokes the Map.Entry#setValue method of any of the Map.Entry implementations provided in this class, this method is not invoked (while this could be addressed, it would require each entry instance to hold a reference to its map).

The Maps.AbstractHashMap implementation does nothing.

Overrides:
entryChanged in class Maps.AbstractHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>
Parameters:
oldEntry - The existing entry that changed.
oldValue - The old value of the entry.
newEntry - The new entry, which may be the same as the old.

entryAccessed

protected final void entryAccessed(E entry)
Description copied from class: Maps.AbstractHashMap
Invoked when the value of an existing entry is accessed by Maps.AbstractHashMap.get(java.lang.Object). Access to an entry by iterating a view collection of this map does not cause this method to be invoked.

The Maps.AbstractHashMap implementation does nothing.

Overrides:
entryAccessed in class Maps.AbstractHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

entryRemoved

protected final void entryRemoved(E entry)
Description copied from class: Maps.AbstractHashMap
Invoked when an existing entry is removed by a remove method of this map, of a view collection of this map, or of an iterator of a view collection of this map

The Maps.AbstractHashMap implementation never invokes Maps.AbstractHashMap.entryRemoved(E) when entries are removed by the Maps.AbstractHashMap.clear() method of this map, or of a view collection of this map.

The Maps.AbstractHashMap implementation does nothing.

Overrides:
entryRemoved in class Maps.AbstractHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

entryPurged

protected final void entryPurged(E entry)
Description copied from class: Maps.AbstractHashMap
Invoked when an existing entry is purged by Maps.AbstractHashMap.purgeEntry(E) after its value has been garbage collected.

The Maps.AbstractHashMap implementation only ever invokes Maps.AbstractHashMap.entryPurged(E) for entries which extend SoftReference or WeakReference and which register themselves with the ReferenceQueue returned by Maps.AbstractHashMap.getQueue(). Maps provides four such classes: Maps.SoftEntry, Maps.WeakEntry, Maps.SoftLinkedEntry, and Maps.WeakLinkedEntry.

The Maps.AbstractHashMap implementation does nothing.

Overrides:
entryPurged in class Maps.AbstractHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

entryEvicted

protected final void entryEvicted(E entry)
Description copied from class: Maps.AbstractLinkedHashMap
Invoked when an existing entry is evicted by Maps.AbstractLinkedHashMap.evictExistingEntry(E), e.g., because Maps.AbstractLinkedHashMap.removeEldestEntry(E) returned true.

The Maps.AbstractLinkedHashMap implementation does nothing.

Overrides:
entryEvicted in class Maps.AbstractLinkedHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>

removeEldestEntry

protected boolean removeEldestEntry(E eldest)
Description copied from class: Maps.AbstractLinkedHashMap
Gets whether to evict the eldest entry from this map. Invoked when an entry is added to the cache, after Maps.AbstractHashMap.entryAdded(E) is invoked. If Maps.AbstractHashMap.entryAdded(E) modifies the map, however, this method is not invoked. The removal of the entry, if requested, causes the Maps.AbstractLinkedHashMap.entryEvicted(E) method to be invoked, rather than the Maps.AbstractHashMap.entryRemoved(E) method.

The Maps.AbstractLinkedHashMap implementation returns false.

In an insertion-ordered map, the eldest entry is the least recently inserted one; in an access-ordered map, it is the least recently accessed entry.

This method is provided for compatibility with LinkedHashMap.removeEldestEntry(java.util.Map.Entry).

Overrides:
removeEldestEntry in class Maps.AbstractLinkedHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>
Parameters:
eldest - The eldest entry in the map.
Returns:
whether the eldest entry should be evicted.

evictExistingEntry

protected void evictExistingEntry(E entry)
Evicts an existing entry from this map. This method matches entries using object identity ("==") on them.

The Maps.AbstractCacheMap implementation ensures that, if this map is canonical, the mapping represented by the evicted entry is retained for as long as an external reference to the value exists.

Overrides:
evictExistingEntry in class Maps.AbstractLinkedHashMap<K,V,E extends Maps.AbstractLinkedEntry<K,V>>
Parameters:
entry - The entry to evict.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.