| 
 | Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.4.0) E17493-05 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectoracle.javatools.util.Maps.AbstractHashMap<K,V,E>
public abstract static class Maps.AbstractHashMap<K,V,E extends Maps.BaseEntry<K,V>>
An abstract, but nearly complete, implementation of the Map
 interface that is functionally equivalent to HashMap
 but that allows subclasses to do any or all of the following:
 
Map.Entry instances used so
 long as they extend Maps.BaseEntry (see createEntry(int, K, V, E));
 keyHashCode(java.lang.Object) and keyEquals(java.lang.Object, java.lang.Object));
 valueHashCode(java.lang.Object) and valueEquals(java.lang.Object, java.lang.Object));
 mapConstructed(), mapInitialized(), and mapChanged()).
 entryAdded(E), entryChanged(E, V, E), entryAccessed(E), 
 entryRemoved(E)).
 entryPurged(E)).
 
 The only method that a concrete subclass must override is
 createEntry(int, K, V, E).
 
 Notes
 If a subclass maintains state which is updated when entries are added
 and that state requires initialization of any kind, that initialization
 should be done in mapConstructed(), not in the subclass constructor.
 
 If overriding any of the value or key hashCode and equals 
 methods, be aware that the usual consistency requirements between hash
 code and equality continue to apply. Also, while the entrySet 
 view uses the map's overridden implementations, invoking hashCode
 or equals directly on an entry obtained from the entry set will
 not use the overridden implementations (the entry does not have a
 reference to the map to gain access to them).
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from interface java.util.Map | 
|---|
| java.util.Map.Entry<K,V> | 
| Field Summary | |
|---|---|
| static int | DEFAULT_INITIAL_CAPACITYThe default initial capacity. | 
| static float | DEFAULT_LOAD_FACTORThe default load factor. | 
| static int | MAXIMUM_CAPACITYThe maximum capacity, used if a higher value is explicitly specified by either of the constructors with arguments. | 
| Constructor Summary | |
|---|---|
| protected  | Maps.AbstractHashMap(int initialCapacity,
                     float loadFactor,
                     java.util.Map<? extends K,? extends V> map)Constructs a map. | 
| protected  | Maps.AbstractHashMap(java.util.Map<? extends K,? extends V> map)Constructs a map with specified initial mappings, initial capacity based on the number of initial mappings, and default load factor. | 
| Method Summary | |
|---|---|
| protected  V | addEntry(K key,
         V value)Creates an entry and add it to the map. | 
| protected  int | capacity() | 
| protected  void | change()Increment the change count. | 
|  void | clear()Removes all mappings from this map. | 
|  java.lang.Object | clone()Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned. | 
|  boolean | containsKey(java.lang.Object key)Returns true if this map contains a mapping for the specified key. | 
|  boolean | containsValue(java.lang.Object value)Gets whether this map maps at least one key to the specified value. | 
| protected abstract  E | createEntry(int hashCode,
            K key,
            V value,
            E next)Creates an entry for 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 | entryAccessed(E entry)Invoked when the value of an existing entry is accessed by 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 | entryPurged(E entry)Invoked when an existing entry is purged by 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 | 
|  java.util.Set<java.util.Map.Entry<K,V>> | entrySet()Gets a collection view of the mappings contained in this map. | 
|  boolean | equals(java.lang.Object object)Compares the specified object with this map for equality. | 
|  V | get(java.lang.Object key)Gets the value from the mapping for a key in this map, or null if the key is not mapped. | 
| protected  int | getChangeCount()Gets the current change count. | 
| protected  E | getEntry(java.lang.Object key)Gets the entry from the map with the specified key, or null if none. | 
| protected  java.lang.ref.ReferenceQueue<V> | getQueue()Gets the reference queue used by purge(). | 
|  int | hashCode()Returns the hash code value for this map. | 
|  boolean | isEmpty()Gets whether this map is empty. | 
| protected  boolean | keyEquals(java.lang.Object key1,
          java.lang.Object key2)Gets whether two keys are equal. | 
| protected  int | keyHashCode(java.lang.Object key)Gets the hash code for a key. | 
|  java.util.Set<K> | keySet()Gets a set view of the keys contained in this map. | 
| protected  float | loadFactor() | 
| protected  void | mapChanged()Invoked when the map has changed. | 
| protected  void | mapConstructed()Invoked after the map has been constructed but before initial mappings, if any, are added. | 
| protected  void | mapInitialized()Invoked after the map has been constructed and initial mappings have been added. | 
| protected  void | purge()Purges stale entries from the map. | 
| protected  void | purgeEntry(E entry)Purges an existing entry from this map. | 
|  V | put(K key,
    V value)Puts a mapping from key to value into this map. | 
|  void | putAll(java.util.Map<? extends K,? extends V> map)Puts all the mappings of a map into this map. | 
|  V | remove(java.lang.Object key)Removes the mapping for a key from this map and gets the value that was mapped from the key, or null if none. | 
| protected  void | removeExistingEntry(E entry)Removes an existing entry from this map. | 
| protected  E | removeKey(java.lang.Object key,
          java.util.Map.Entry<K,V> optionalEntryWithValue)Removes the entry with a key from this map and returns the entry removed, or null if no entry is removed. | 
|  int | size()Gets the number of mappings in this map. | 
|  java.lang.String | toString() | 
| protected  boolean | valueEquals(java.lang.Object value1,
            java.lang.Object value2)Gets whether two values are equal. | 
| protected  int | valueHashCode(java.lang.Object value)Gets the hash code for a value. | 
|  java.util.Collection<V> | values()Gets a collection view of the values contained in this map. | 
| Methods inherited from class java.lang.Object | 
|---|
| finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public static final int DEFAULT_INITIAL_CAPACITY
public static final int MAXIMUM_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
| Constructor Detail | 
|---|
protected Maps.AbstractHashMap(int initialCapacity,
                               float loadFactor,
                               java.util.Map<? extends K,? extends V> map)
initialCapacity - The initial capacity. A reasonable default is
                        DEFAULT_INITIAL_CAPACITY.loadFactor - The load factor. A reasonable default is 
                        DEFAULT_LOAD_FACTORmap - A map providing initial mappings. Use null or an
                        empty map if none specified.
java.lang.IllegalArgumentException - if the initial capacity is negative
                        or the load factor is nonpositive.protected Maps.AbstractHashMap(java.util.Map<? extends K,? extends V> map)
default load factor.
map - A map providing initial mappings.
java.lang.NullPointerException - if the specified map is null.| Method Detail | 
|---|
protected abstract E createEntry(int hashCode,
                                 K key,
                                 V value,
                                 E next)
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.protected int keyHashCode(java.lang.Object key)
Maps.AbstractHashMap implementation 
 returns key.hashCode().
key - A non-null key object.
protected boolean keyEquals(java.lang.Object key1,
                            java.lang.Object key2)
Maps.AbstractHashMap
 implementation returns key1 == key2 || key1.equals(key2).
key1 - A non-null key object.key2 - A potentially null key object.protected int valueHashCode(java.lang.Object value)
Maps.AbstractHashMap
 implementation returns value.hashCode().
value - A non-null value object.
protected boolean valueEquals(java.lang.Object value1,
                              java.lang.Object value2)
Maps.AbstractHashMap
 implementation returns value1 == value2 || value1.equals(value2).
value1 - A non-null value object.value2 - A potentially null value object.protected void purge()
 The Maps.AbstractHashMap implementation removes any entries that have
 been enqueued on the reference queue returned by getQueue().
protected final java.lang.ref.ReferenceQueue<V> getQueue()
purge().
protected void mapConstructed()
 Subclass state that is accessed by, for example put(K, V), should
 be initialized in the subclass mapConstructed() method instead of
 in the subclass constructor, because mapConstructed() is called 
 before the initial entries are added to the map, whereas the subclass 
 constructor does not get invoked until afterwards (i.e., too late).
 
 The Maps.AbstractHashMap implementation does nothing.
protected void mapInitialized()
added or changed by put(K, V).  Beware, this 
 method is called before the subclass constructor is called.
 
 The Maps.AbstractHashMap implementation does nothing.
protected void mapChanged()
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 entryAdded(E), 
 entryRemoved(E) or entryPurged(E) method.
 
 The Maps.AbstractHashMap implementation does nothing.
protected void entryAdded(E entry)
mapInitialized()), entries are only added
 by put(K, V).
 
 The Maps.AbstractHashMap implementation does nothing.
protected void entryChanged(E oldEntry,
                            V oldValue,
                            E newEntry)
mapInitialized()), entries are only changed 
 by 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.
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.protected void entryAccessed(E entry)
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.
protected void entryRemoved(E entry)
 The Maps.AbstractHashMap implementation never invokes entryRemoved(E) when entries are removed by the clear() method of 
 this map, or of a view collection of this map.
 
 The Maps.AbstractHashMap implementation does nothing.
protected void entryPurged(E entry)
purgeEntry(E) 
 after its value has been garbage collected. 
 
 The Maps.AbstractHashMap implementation only ever invokes
 entryPurged(E) for entries which extend SoftReference or 
 WeakReference and which register themselves with the 
 ReferenceQueue returned by getQueue(). Maps 
 provides four such classes: Maps.SoftEntry, Maps.WeakEntry, Maps.SoftLinkedEntry, and Maps.WeakLinkedEntry.
 
 The Maps.AbstractHashMap implementation does nothing.
public int size()
size in interface java.util.Map<K,V>public boolean isEmpty()
isEmpty in interface java.util.Map<K,V>public V get(java.lang.Object key)
containsKey(java.lang.Object).
get in interface java.util.Map<K,V>key - A key mapped in this map.
public V put(K key,
             V value)
put in interface java.util.Map<K,V>key - The key to map.value - The value to which to map the key.
public void putAll(java.util.Map<? extends K,? extends V> map)
putAll in interface java.util.Map<K,V>map - mappings to put into this map.
java.lang.NullPointerException - if the map is null.public V remove(java.lang.Object key)
remove in interface java.util.Map<K,V>key - A key mapped in this map.
public void clear()
clear in interface java.util.Map<K,V>public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<K,V>key - The key whose presence in this map is to be tested
public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<K,V>value - value for which to test.public java.util.Set<K> keySet()
keySet in interface java.util.Map<K,V>public java.util.Collection<V> values()
values in interface java.util.Map<K,V>public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet in interface java.util.Map<K,V>Map.Entrypublic java.lang.Object clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object object)
This implementation first checks if the specified object is this map; if so it returns true. Then, it checks if the specified object is a map whose size is identical to the size of this set; if not, it returns false. If so, it iterates over this map's entrySet collection, and checks that the specified map contains each mapping that this map contains. If the specified map fails to contain such a mapping, false is returned. If the iteration completes, true is returned.
equals in interface java.util.Map<K,V>equals in class java.lang.Objectobject - object to be compared for equality with this map.
public int hashCode()
This implementation iterates over entrySet(), calling hashCode on each element (entry) in the Collection, and adding up the results.
hashCode in interface java.util.Map<K,V>hashCode in class java.lang.ObjectMap.Entry#hashCode(), 
Object.hashCode(), 
Object.equals(Object), 
Set.equals(Object)public java.lang.String toString()
toString in class java.lang.Objectprotected void change()
getChangeCount(), 
mapChanged()protected int getChangeCount()
change();protected java.util.Iterator<E> createEntryIterator()
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.
protected java.util.Iterator<java.util.Map.Entry<K,V>> createEntrySetIterator()
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.
protected java.util.Iterator<K> createKeySetIterator()
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.
protected java.util.Iterator<V> createValuesIterator()
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.
protected V addEntry(K key,
                     V value)
key - The key for the entry to create.value - The value for the entry to create.protected E getEntry(java.lang.Object key)
protected E removeKey(java.lang.Object key,
                      java.util.Map.Entry<K,V> optionalEntryWithValue)
EntrySet#remove 
 method, if entry is not null, then the entry values must 
 additionally be equal, as determined by the valueEquals(java.lang.Object, java.lang.Object) method, 
 for an entry to be removed.
key - The key for the entry to remove.optionalEntryWithValue - An entry containing the value to match, 
                                or null if none.
protected void removeExistingEntry(E entry)
entry - The entry to remove.protected void purgeEntry(E entry)
entry - The entry to remove.protected int capacity()
protected float loadFactor()
| 
 | Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.4.0) E17493-05 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||