Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.javatools.util
Class Maps.AbstractLinkedHashMap<K,V,E extends Maps.LinkedEntry<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>

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
Direct Known Subclasses:
Maps.CacheMap, Maps.SoftLinkedHashMap, Maps.StrongLinkedHashMap, Maps.WeakLinkedHashMap
Enclosing class:
Maps

public abstract static class Maps.AbstractLinkedHashMap<K,V,E extends Maps.LinkedEntry<K,V>>
extends Maps.AbstractHashMap<K,V,E>

An abstract, but nearly complete, implementation of the Map interface that is functionally equivalent to LinkedHashMap but is based on Maps.AbstractHashMap and allows subclasses the same customization options. Maps.AbstractLinkedHashMap adds a predictable iteration order to Maps.AbstractHashMap by maintaining a doubly linked list, defining the iteration order, of all the entries in the map. To support this, the entries are required to implement the Maps.LinkedEntry interface (which extends the Maps.BaseEntry interface required by Maps.AbstractHashMap).

The only method that a concrete subclass must override is Maps.AbstractHashMap.createEntry(int, K, V, E).

See Also:
Serialized Form

Nested Class Summary

 

Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>

 

Field Summary

 

Fields inherited from class oracle.javatools.util.Maps.AbstractHashMap
DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, MAXIMUM_CAPACITY

 

Constructor Summary
protected Maps.AbstractLinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder, java.util.Map<? extends K,? extends V> map)
          Constructs a map.
protected Maps.AbstractLinkedHashMap(java.util.Map<? extends K,? extends V> map)
          Constructs an insertion-ordered map with specified initial mappings, initial capacity based on the number of initial mappings, and default load factor.

 

Method Summary
 void clear()
          Removes all mappings from this map.
protected  java.util.Iterator<E> createEntryIterator()
          Gets an iterator through all the entries of the map.
protected  java.util.Iterator<java.util.Map.Entry<K,V>> createEntrySetIterator()
          Gets an iterator through all the entries of the map.
protected  java.util.Iterator<K> createKeySetIterator()
          Gets an iterator through all the keys of all the entries of the map.
protected  java.util.Iterator<V> createValuesIterator()
          Gets an iterator through all the values of all the entries of the map.
protected  void entryEvicted(E entry)
          Invoked when an existing entry is evicted by evictEntry(E), e.g., because removeEldestEntry(E) returned true.
protected  boolean evictEntry(E entry)
          Evicts an existing entry from this map.
protected  E getEldestEntry()
          Gets the eldest entry in this map, or null if the map is empty.
protected  void mapChanged()
          Invoked when the map has changed.
protected  boolean removeEldestEntry(E eldest)
          Gets whether to evict the eldest entry from this map.

 

Methods inherited from class oracle.javatools.util.Maps.AbstractHashMap
addEntry, capacity, change, clone, containsKey, containsValue, createEntry, entryAccessed, entryAdded, entryChanged, entryPurged, entryRemoved, 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

 

Constructor Detail

Maps.AbstractLinkedHashMap

protected Maps.AbstractLinkedHashMap(int initialCapacity,
                                     float loadFactor,
                                     boolean accessOrder,
                                     java.util.Map<? extends K,? extends V> map)
Constructs a map.
Parameters:
initialCapacity - the initial capacity.
loadFactor - The load factor.
accessOrder - The iteration order for this map: insertion-order false, access-order if true.
map - A map providing initial mappings, or null if none.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive.

Maps.AbstractLinkedHashMap

protected Maps.AbstractLinkedHashMap(java.util.Map<? extends K,? extends V> map)
Constructs an insertion-ordered map with specified initial mappings, initial capacity based on the number of initial mappings, and default load factor.
Parameters:
map - A map providing initial mappings.
Throws:
java.lang.NullPointerException - if the specified map is null.
See Also:
Maps.AbstractHashMap.DEFAULT_LOAD_FACTOR

Method Detail

mapChanged

protected void mapChanged()
Invoked when the map has changed. After the map is initialized (see Maps.AbstractHashMap.mapInitialized()), it only changes when the map is cleared or when entries are added, removed, or purged. In the latter cases, this method is invoked before the corresponding Maps.AbstractHashMap.entryAdded(E), Maps.AbstractHashMap.entryRemoved(E) or Maps.AbstractHashMap.entryPurged(E) method.

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. This method is invoked before the associated Maps.AbstractHashMap.entryAccessed(E) method is invoked.

The Maps.AbstractLinkedHashMap implementation does nothing.

Overrides:
mapChanged in class Maps.AbstractHashMap<K,V,E extends Maps.LinkedEntry<K,V>>

entryEvicted

protected void entryEvicted(E entry)
Invoked when an existing entry is evicted by evictEntry(E), e.g., because removeEldestEntry(E) returned true.

The Maps.AbstractLinkedHashMap implementation does nothing.


getEldestEntry

protected E getEldestEntry()
Gets the eldest entry in this map, or null if the map is empty.

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.

The Maps.AbstractLinkedHashMap implementation does nothing.


removeEldestEntry

protected boolean removeEldestEntry(E eldest)
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 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<K, V>).

Parameters:
eldest - The eldest entry in the map.
Returns:
whether the eldest entry should be evicted.

evictEntry

protected boolean evictEntry(E entry)
Evicts an existing entry from this map. This method matches entries using object identity ("==") on them.
Parameters:
entry - The entry to evict.
Returns:
whether the entry was actually evicted.

clear

public void clear()
Removes all mappings from this map.

Overridden to reset the iteration list.

Specified by:
clear in interface java.util.Map<K,V>
Overrides:
clear in class Maps.AbstractHashMap<K,V,E extends Maps.LinkedEntry<K,V>>

createEntryIterator

protected java.util.Iterator<E> createEntryIterator()
Description copied from class: Maps.AbstractHashMap
Gets an iterator through all the entries of the map. The Maps.AbstractHashMap implementation returns an instance of AbstractEntryIterator. A subclass would typically override this only if it had access to a more efficient iterator implementation.
Overrides:
createEntryIterator in class Maps.AbstractHashMap<K,V,E extends Maps.LinkedEntry<K,V>>

createEntrySetIterator

protected java.util.Iterator<java.util.Map.Entry<K,V>> createEntrySetIterator()
Description copied from class: Maps.AbstractHashMap
Gets an iterator through all the entries of the map. The Maps.AbstractHashMap implementation returns an instance of AbstractEntryIterator. A subclass would typically override this only if it had access to a more efficient iterator implementation.
Overrides:
createEntrySetIterator in class Maps.AbstractHashMap<K,V,E extends Maps.LinkedEntry<K,V>>

createKeySetIterator

protected java.util.Iterator<K> createKeySetIterator()
Description copied from class: Maps.AbstractHashMap
Gets an iterator through all the keys of all the entries of the map. The Maps.AbstractHashMap implementation returns an instance of AbstractEntryIterator. A subclass would typically override this only if it had access to a more efficient iterator implementation.
Overrides:
createKeySetIterator in class Maps.AbstractHashMap<K,V,E extends Maps.LinkedEntry<K,V>>

createValuesIterator

protected java.util.Iterator<V> createValuesIterator()
Description copied from class: Maps.AbstractHashMap
Gets an iterator through all the values of all the entries of the map. The Maps.AbstractHashMap implementation returns an instance of AbstractEntryIterator. A subclass would typically override this only if it had access to a more efficient iterator implementation.
Overrides:
createValuesIterator in class Maps.AbstractHashMap<K,V,E extends Maps.LinkedEntry<K,V>>

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


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