ix.util.context
Class ContextHashMap
java.lang.Object
java.util.AbstractMap
ix.util.context.ContextHashMap
- All Implemented Interfaces:
- ContextMap, java.util.Map
public class ContextHashMap
- extends java.util.AbstractMap
- implements ContextMap
A context-layered version of HashMap. Properties:
- Entries cannot be removed. The remove() and clear() methods,
and the entry set's remove(), removeAll(), retainAll(), and clear()
methods, are not supported. However, there is a method that
will remove all entries in all contexts:
clearCompletely()
.
- Iterators over the entry-set, key-set, or values return items
in the order in which the keys were first added to the map.
- The entry-set and its iterators must be used in the context
in which the entry-set was created by a call to
entrySet()
.
- Like the java.util classes WeakHashMap and IdentityHashMap,
it is not a subclass of HashMap.
As of I-X 3.3, entires can be removed by calling the remove(Object)
method, but still not in any other way. If a key is removed, then
used again with a put, it regains its original position in the
iteration order. However, the order is forgotten after a
clearCompletely().
As of I-X 4.1, clear() is also supported. It removes all entries
in the current context.
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Method Summary |
void |
clear()
|
void |
clearCompletely()
Remove all entries in all contexts. |
boolean |
containsKey(java.lang.Object key)
|
java.util.Set |
entrySet()
|
java.lang.Object |
get(java.lang.Object key)
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
java.lang.Object |
remove(java.lang.Object key)
|
Methods inherited from class java.util.AbstractMap |
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
containsValue, equals, hashCode, isEmpty, keySet, putAll, size, values |
UNDEF
protected static final java.lang.Object UNDEF
holder
protected ContextHolder holder
map
protected java.util.HashMap map
keyChain
protected ContextHashMap.Entry keyChain
keyChainLast
protected ContextHashMap.Entry keyChainLast
ContextHashMap
public ContextHashMap()
ContextHashMap
public ContextHashMap(int initialCapacity)
ContextHashMap
public ContextHashMap(int initialCapacity,
float loadFactor)
ContextHashMap
public ContextHashMap(java.util.Map m)
ContextHashMap
public ContextHashMap(ContextHolder holder)
ContextHashMap
public ContextHashMap(ContextHolder holder,
java.util.Map m)
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Specified by:
put
in interface java.util.Map
- Overrides:
put
in class java.util.AbstractMap
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
get
in interface java.util.Map
- Overrides:
get
in class java.util.AbstractMap
entrySet
public java.util.Set entrySet()
- Specified by:
entrySet
in interface java.util.Map
- Specified by:
entrySet
in class java.util.AbstractMap
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interface java.util.Map
- Overrides:
containsKey
in class java.util.AbstractMap
clearCompletely
public void clearCompletely()
- Remove all entries in all contexts.
- Specified by:
clearCompletely
in interface ContextMap
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
remove
in interface java.util.Map
- Overrides:
remove
in class java.util.AbstractMap
clear
public void clear()
- Specified by:
clear
in interface java.util.Map
- Overrides:
clear
in class java.util.AbstractMap