polyglot.util
Class NestedMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by polyglot.util.NestedMap
All Implemented Interfaces:
java.util.Map

public class NestedMap
extends java.util.AbstractMap
implements java.util.Map

A NestedMap is a map which, when it cannot find an element in itself, defers to another map. Modifications, however, are not passed on to the supermap. A NestedMap and its backing collections and iterators support all operations except 'remove' and 'clear', since operations to a NestedMap must not affect the backing map. Instead, use the 'release' method. It is used to implement nested namespaces, such as those which store local-variable bindings.


Nested Class Summary
 class NestedMap.KeySet
           
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
NestedMap(java.util.Map containing)
          Creates a new nested map, which defers to .
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
           
 java.util.Map getContainingMap()
          Returns the map to which this map defers, or null for none.
 java.util.Map getInnerMap()
          Returns the map containing the elements for this level of nesting.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void release(java.lang.Object key)
          Removes any binding in this for , returning to the binding (if any) from the supermap.
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, 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, values
 

Constructor Detail

NestedMap

public NestedMap(java.util.Map containing)
Creates a new nested map, which defers to . If containing is null, it defaults to a NilMap.

Method Detail

getContainingMap

public java.util.Map getContainingMap()
Returns the map to which this map defers, or null for none.


release

public void release(java.lang.Object key)
Removes any binding in this for , returning to the binding (if any) from the supermap.


getInnerMap

public java.util.Map getInnerMap()
Returns the map containing the elements for this level of nesting.


entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
Specified by:
entrySet in class java.util.AbstractMap

size

public int size()
Specified by:
size in interface java.util.Map
Overrides:
size 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

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

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

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