ix.util.context
Class ContextHashMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by 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:

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  class ContextHashMap.IteratorContextException
           
 
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 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
 

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