ix.util.context
Class ContextHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by ix.util.context.ContextHashMap<K,V>
All Implemented Interfaces:
ContextMap<K,V>, java.util.Map<K,V>

public class ContextHashMap<K,V>
extends java.util.AbstractMap<K,V>
implements ContextMap<K,V>

A context-layered version of HashMap. Properties:

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 Class Summary
protected  class ContextHashMap.Entry
          The Map.Entry implementation for a ContextHashMap.
protected  class ContextHashMap.EntrySet
          The Set implementation for a ContextHashMap entrySet.
protected  class ContextHashMap.EntrySetIterator
          The Iterator implementation for a ContextHashMap entrySet.
protected static class ContextHashMap.IteratorContextException
           
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  ContextHolder holder
           
protected  ContextHashMap.Entry keyChain
           
protected  ContextHashMap.Entry keyChainLast
           
protected  java.util.HashMap map
           
protected static java.lang.Object UNDEF
           
 
Constructor Summary
ContextHashMap()
           
ContextHashMap(ContextHolder holder)
           
ContextHashMap(ContextHolder holder, java.util.Map m)
           
ContextHashMap(int initialCapacity)
           
ContextHashMap(int initialCapacity, float loadFactor)
           
ContextHashMap(java.util.Map m)
           
 
Method Summary
 void clear()
           
 void clearCompletely()
          Remove all entries in all contexts.
 boolean containsKey(java.lang.Object key)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object key)
           
 V put(K key, V value)
           
 V 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
 

Field Detail

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
Constructor Detail

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)
Method Detail

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class java.util.AbstractMap<K,V>

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.AbstractMap<K,V>

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>
Specified by:
entrySet in class java.util.AbstractMap<K,V>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<K,V>
Overrides:
containsKey in class java.util.AbstractMap<K,V>

clearCompletely

public void clearCompletely()
Remove all entries in all contexts.

Specified by:
clearCompletely in interface ContextMap<K,V>

remove

public V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<K,V>
Overrides:
remove in class java.util.AbstractMap<K,V>

clear

public void clear()
Specified by:
clear in interface java.util.Map<K,V>
Overrides:
clear in class java.util.AbstractMap<K,V>