net.sf.swan.xml.input.util
Class ContextMap
java.lang.Object
|
+--net.sf.swan.xml.input.util.ContextMap
- public final class ContextMap
- extends java.lang.Object
Utility for maintaining stacked contexts of key/value mappings. This uses a
HashMap
-like implementation, but has been optimized for
the purpose of maintaining stacked contexts of mappings.
This class is used internally by
EventContext components
,
but is made public here because of its reasonably general utility.
Method Summary |
void |
clear()
Clear the entries from this map. |
java.lang.Object |
get(java.lang.Object key)
|
java.util.Enumeration |
keys()
Enumerate all of the map's keys. |
ContextMap |
popContext()
Releases this child ContextMap and return its parent. |
ContextMap |
pushContext()
Create a new ContextMap that is a child of this one. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Add or change an entry. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ContextMap
public ContextMap()
ContextMap
public ContextMap(int initialCapacity)
ContextMap
public ContextMap(int initialCapacity,
float loadFactor)
get
public java.lang.Object get(java.lang.Object key)
pushContext
public ContextMap pushContext()
- Create a new
ContextMap
that is a child of this one.
The new ContextMap
will be initialized with
the same key/value mappings as this one, but modifications
in the child will not be reflected in the parent.
This ContextMap
will become read-only until
all children have been released
.
- Returns:
- the new child
ContextMap
popContext
public ContextMap popContext()
- Releases this child
ContextMap
and return its parent.
- Returns:
- the parent
ContextMap
of this one - Throws:
java.lang.IllegalStateException
- if this ContextMap
is not a child of another
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Add or change an entry.
- Throws:
java.lang.IllegalStateException
- if this ContextMap
has
child context maps that have not been released
.
clear
public void clear()
- Clear the entries from this map.
- Throws:
java.lang.IllegalStateException
- if this ContextMap
has
child context maps that have not been released
.
keys
public java.util.Enumeration keys()
- Enumerate all of the map's keys. We return an
Enumeration
for this rather than an Iterator
so that there is no
ambiguity about the ability to remove keys (you can't).