public class NestedMap
extends java.lang.Object
implements java.util.Map, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected java.util.Map |
local
The local map.
|
protected java.util.Map[] |
parents
The parent maps.
|
Modifier | Constructor and Description |
---|---|
|
NestedMap(java.util.Map parent)
Create a nested map, referring to the specified parent map.
|
|
NestedMap(java.util.Map[] parents)
Create a nested map, referring to the specified parent maps.
|
protected |
NestedMap(java.util.Map[] parents,
java.util.Map local)
Create a nested map, referring to the specified parent map,
using the given map for storing local mappings.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all mappings from this map (optional operation).
|
boolean |
containsKey(java.lang.Object key)
Returns
|
boolean |
containsValue(java.lang.Object value)
Returns
|
java.util.Set |
entrySet()
Returns a set view of the mappings contained in this map.
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this map for equality.
|
java.lang.Object |
get(java.lang.Object key)
Returns the value to which this map maps the specified key.
|
java.util.Map |
getLocalMap()
Get the map containing the local mappings.
|
int |
hashCode()
Returns the hash code value for this map.
|
boolean |
isEmpty()
Returns
|
java.util.Set |
keySet()
Returns a set view of the keys contained in this map.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map
(optional operation).
|
void |
putAll(java.util.Map t)
Copies all of the mappings from the specified map to this map
(optional operation).
|
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this map if it is present
(optional operation).
|
int |
size()
Returns the number of key-value mappings in this map.
|
java.lang.String |
toString()
Create a string representation of this map.
|
java.util.Collection |
values()
Returns a collection view of the values contained in this map.
|
protected java.util.Map local
protected java.util.Map[] parents
public NestedMap(java.util.Map parent)
parent
- The parent map.public NestedMap(java.util.Map[] parents)
parents
- The parent maps.protected NestedMap(java.util.Map[] parents, java.util.Map local)
parents
- The parent map.local
- The map for local mappings.public java.util.Map getLocalMap()
public int size()
size
in interface java.util.Map
public boolean isEmpty()
isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
key
- key whose presence in this map is to be tested.java.lang.ClassCastException
- if the key is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- if the key is
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
value
- value whose presence in this map is to be tested.java.lang.ClassCastException
- if the value is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- if the value is
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
key
- key whose associated value is to be returned.java.lang.ClassCastException
- if the key is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- key is
containsKey(Object)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
m.containsKey(k)
would return
put
in interface java.util.Map
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.java.lang.UnsupportedOperationException
- if the
java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.java.lang.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.java.lang.NullPointerException
- this map does not permit
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
key
- key whose mapping is to be removed from the map.java.lang.ClassCastException
- if the key is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- if the key is
java.lang.UnsupportedOperationException
- if the
public void putAll(java.util.Map t)
put(k, v)
on this map once
for each mapping from key
putAll
in interface java.util.Map
t
- Mappings to be stored in this map.java.lang.UnsupportedOperationException
- if the
java.lang.ClassCastException
- if the class of a key or value in the
specified map prevents it from being stored in this map.java.lang.IllegalArgumentException
- some aspect of a key or value in the
specified map prevents it from being stored in this map.java.lang.NullPointerException
- the specified map is
public void clear()
clear
in interface java.util.Map
java.lang.UnsupportedOperationException
- if clear is not supported by this
map.public java.util.Set keySet()
keySet
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map
equals
in class java.lang.Object
o
- object to be compared for equality with this map.public int hashCode()
hashCode
in interface java.util.Map
hashCode
in class java.lang.Object
Object.hashCode()
,
Object.equals(Object)
,
equals(Object)
public java.lang.String toString()
toString
in class java.lang.Object