Oracle® Coherence Java API Reference
v3.5.3

E15583-01

com.tangosol.util
Class RestrictedCollections.RestrictedMap

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.RestrictedCollections.RestrictedMap
All Implemented Interfaces:
java.io.Serializable, java.util.Map
Direct Known Subclasses:
RestrictedCollections.RestrictedSortedMap
Enclosing class:
RestrictedCollections

public static class RestrictedCollections.RestrictedMap
extends Base
implements java.util.Map, java.io.Serializable

A restricted Map that requires its keys and values to be of specified classes.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry
 
Field Summary
protected  java.lang.Class m_clzKey
          The class of key stored in the Map.
protected  java.lang.Class m_clzVal
          The class of value stored in the Map.
protected  java.util.Map m_map
          The underlying Map.
protected  java.util.Set m_set
          The Entry Set.
 
Constructor Summary
RestrictedCollections.RestrictedMap(java.util.Map map, java.lang.Class clzKey, java.lang.Class clzVal)
          Constructor.
 
Method Summary
protected  void checkKey(java.lang.Object o)
          Check the passed object to verify that it passes the "key" restriction of this Map.
protected  void checkValue(java.lang.Object o)
          Check the passed object to verify that it passes the "value" restriction of this Map.
 void clear()
          Removes all mappings from this map.
 boolean containsKey(java.lang.Object key)
          Returns true if this map contains a mapping for the specified key.
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more keys to the specified value.
 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.
 int hashCode()
          Returns the hash code value for this map.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 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.
 void putAll(java.util.Map map)
          Copies all of the mappings from the specified map to this map.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from this map if present.
 int size()
          Returns the number of key-value mappings in this map.
 java.lang.String toString()
          Return a String description for this Map.
 java.util.Collection values()
          Returns a collection view of the values contained in this map.
 

Field Detail

m_map

protected java.util.Map m_map
The underlying Map.


m_clzKey

protected java.lang.Class m_clzKey
The class of key stored in the Map.


m_clzVal

protected java.lang.Class m_clzVal
The class of value stored in the Map.


m_set

protected java.util.Set m_set
The Entry Set.

Constructor Detail

RestrictedCollections.RestrictedMap

public RestrictedCollections.RestrictedMap(java.util.Map map,
                                           java.lang.Class clzKey,
                                           java.lang.Class clzVal)
Constructor.

Parameters:
map - the underlying Map
clzKey - the class of keys that may be stored in the Map
clzVal - the class of values that may be stored in the Map
Method Detail

size

public int size()
Returns the number of key-value mappings in this map.

Specified by:
size in interface java.util.Map
Returns:
the number of key-value mappings in this map

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.

Specified by:
isEmpty in interface java.util.Map
Returns:
true if this map contains no key-value mappings

containsKey

public boolean containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface java.util.Map
Parameters:
key - key whose presence in this map is to be tested
Returns:
true if this map contains a mapping for the specified key

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value.

Specified by:
containsValue in interface java.util.Map
Parameters:
value - value whose presence in this map is to be tested
Returns:
true if this map maps one or more keys to the specified value.

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key.

Specified by:
get in 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 null if the map contains no mapping for this key.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Associates the specified value with the specified key in this map.

Specified by:
put in 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 null if there was no mapping for key
Throws:
java.lang.ClassCastException - if the class of the specified key or value prevents it from being stored in this map.

remove

public java.lang.Object remove(java.lang.Object key)
Removes the mapping for this key from this map if present.

Specified by:
remove in interface java.util.Map
Parameters:
key - key whose mapping is to be removed from the map
Returns:
previous value associated with specified key, or null if there was no mapping for key

putAll

public void putAll(java.util.Map map)
Copies all of the mappings from the specified map to this map.

Specified by:
putAll in interface java.util.Map
Parameters:
map - Mappings to be stored in this map
Throws:
java.lang.ClassCastException - if the class of a key or value in the specified map prevents it from being stored in this map

clear

public void clear()
Removes all mappings from this map.

Specified by:
clear in interface java.util.Map

keySet

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

Specified by:
keySet in interface java.util.Map
Returns:
a set view of the keys contained in this map

values

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

Specified by:
values in interface java.util.Map
Returns:
a collection view of the values contained in this map

entrySet

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

Specified by:
entrySet in interface java.util.Map
Returns:
a set view of the mappings contained in this map

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this map for equality. Obeys the general contract of Map.equals.

Specified by:
equals in interface java.util.Map
Parameters:
o - object to be compared for equality with this map
Returns:
true if the specified object is equal to this map

hashCode

public int hashCode()
Returns the hash code value for this map. Obeys the general contract of Map.hashCode.

Specified by:
hashCode in interface java.util.Map
Returns:
the hash code value for this map

toString

public java.lang.String toString()
Return a String description for this Map.

Returns:
a String description of the Map

checkKey

protected void checkKey(java.lang.Object o)
Check the passed object to verify that it passes the "key" restriction of this Map.

Parameters:
o - the Object to check
Throws:
java.lang.ClassCastException - if the class of the passed Object prevents it from being used as a key in this Map

checkValue

protected void checkValue(java.lang.Object o)
Check the passed object to verify that it passes the "value" restriction of this Map.

Parameters:
o - the Object to check
Throws:
java.lang.ClassCastException - if the class of the passed Object prevents it from being used as a value in this Map

Oracle® Coherence Java API Reference
v3.5.3

E15583-01

Copyright © 2000, 2010, Oracle. All rights reserved.