Package jadex.commons.collection
Class NestedMap
- java.lang.Object
- 
- jadex.commons.collection.NestedMap
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.util.Map
 
 public class NestedMap extends java.lang.Object implements java.util.Map, java.io.SerializableA nested map refers to parent maps for entries not found in this map. Modifications of this map do not affect the parent maps.- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Modifier Constructor 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.protectedNestedMap(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.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all mappings from this map (optional operation).booleancontainsKey(java.lang.Object key)ReturnsbooleancontainsValue(java.lang.Object value)Returnsjava.util.SetentrySet()Returns a set view of the mappings contained in this map.booleanequals(java.lang.Object o)Compares the specified object with this map for equality.java.lang.Objectget(java.lang.Object key)Returns the value to which this map maps the specified key.java.util.MapgetLocalMap()Get the map containing the local mappings.inthashCode()Returns the hash code value for this map.booleanisEmpty()Returnsjava.util.SetkeySet()Returns a set view of the keys contained in this map.java.lang.Objectput(java.lang.Object key, java.lang.Object value)Associates the specified value with the specified key in this map (optional operation).voidputAll(java.util.Map t)Copies all of the mappings from the specified map to this map (optional operation).java.lang.Objectremove(java.lang.Object key)Removes the mapping for this key from this map if it is present (optional operation).intsize()Returns the number of key-value mappings in this map.java.lang.StringtoString()Create a string representation of this map.java.util.Collectionvalues()Returns a collection view of the values contained in this map.
 
- 
- 
- 
Constructor Detail- 
NestedMappublic NestedMap(java.util.Map parent) Create a nested map, referring to the specified parent map.- Parameters:
- parent- The parent map.
 
 - 
NestedMappublic NestedMap(java.util.Map[] parents) Create a nested map, referring to the specified parent maps.- Parameters:
- parents- The parent maps.
 
 - 
NestedMapprotected 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.- Parameters:
- parents- The parent map.
- local- The map for local mappings.
 
 
- 
 - 
Method Detail- 
getLocalMappublic java.util.Map getLocalMap() Get the map containing the local mappings.
 - 
sizepublic int size() Returns the number of key-value mappings in this map. If the map contains more than- Specified by:
- sizein interface- java.util.Map
- Returns:
- the number of key-value mappings in this map.
 - 
isEmptypublic boolean isEmpty() Returns- Specified by:
- isEmptyin interface- java.util.Map
- Returns:
 - 
containsKeypublic boolean containsKey(java.lang.Object key) Returns- Specified by:
- containsKeyin interface- java.util.Map
- Parameters:
- key- key whose presence in this map is to be tested.
- Returns:
- 
- Throws:
java.lang.ClassCastException- if the key is of an inappropriate type for this map (optional).java.lang.NullPointerException- if the key is
 - 
containsValuepublic boolean containsValue(java.lang.Object value) Returns- Specified by:
- containsValuein interface- java.util.Map
- Parameters:
- value- value whose presence in this map is to be tested.
- Returns:
- 
- Throws:
java.lang.ClassCastException- if the value is of an inappropriate type for this map (optional).java.lang.NullPointerException- if the value is
 - 
getpublic java.lang.Object get(java.lang.Object key) Returns the value to which this map maps the specified key. Returns- Specified by:
- getin interface- java.util.Map
- Parameters:
- key- key whose associated value is to be returned.
- Returns:
- the value to which this map maps the specified key, or
               
- Throws:
java.lang.ClassCastException- if the key is of an inappropriate type for this map (optional).java.lang.NullPointerException- key is
- See Also:
containsKey(Object)
 - 
putpublic 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). If the map previously contained a mapping for this key, the old value is replaced by the specified value. (A mapm.containsKey(k)would return- Specified by:
- putin interface- java.util.Map
- Parameters:
- key- key with which the specified value is to be associated.
- value- value to be associated with the specified key.
- Returns:
- previous value associated with specified key, or 
- Throws:
java.lang.UnsupportedOperationException- if thejava.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
 - 
removepublic java.lang.Object remove(java.lang.Object key) Removes the mapping for this key from this map if it is present (optional operation). More formally, if this map contains a mapping from key (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can contain at most one such mapping.)- Specified by:
- removein interface- java.util.Map
- Parameters:
- key- key whose mapping is to be removed from the map.
- Returns:
- previous value associated with specified key, or 
- Throws:
java.lang.ClassCastException- if the key is of an inappropriate type for this map (optional).java.lang.NullPointerException- if the key isjava.lang.UnsupportedOperationException- if the
 - 
putAllpublic void putAll(java.util.Map t) Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of callingput(k, v)on this map once for each mapping from key- Specified by:
- putAllin interface- java.util.Map
- Parameters:
- t- Mappings to be stored in this map.
- Throws:
- 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
 - 
clearpublic void clear() Removes all mappings from this map (optional operation).- Specified by:
- clearin interface- java.util.Map
- Throws:
- java.lang.UnsupportedOperationException- if clear is not supported by this map.
 
 - 
keySetpublic java.util.Set keySet() Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the- Specified by:
- keySetin interface- java.util.Map
- Returns:
- a set view of the keys contained in this map.
 - 
valuespublic java.util.Collection values() Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the- Specified by:
- valuesin interface- java.util.Map
- Returns:
- a collection view of the values contained in this map.
 - 
entrySetpublic java.util.Set entrySet() Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the- Specified by:
- entrySetin interface- java.util.Map
- Returns:
- a set view of the mappings contained in this map.
 - 
equalspublic boolean equals(java.lang.Object o) Compares the specified object with this map for equality. Returns- Specified by:
- equalsin interface- java.util.Map
- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- object to be compared for equality with this map.
- Returns:
 - 
hashCodepublic int hashCode() Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hashCodes of each entry in the map's entrySet view. This ensures that- Specified by:
- hashCodein interface- java.util.Map
- Overrides:
- hashCodein class- java.lang.Object
- Returns:
- the hash code value for this map.
- See Also:
- Object.hashCode(),- Object.equals(Object),- equals(Object)
 - 
toStringpublic java.lang.String toString() Create a string representation of this map.- Overrides:
- toStringin class- java.lang.Object
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
 
-