Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.util
Class Collections.UnmodifiableMap  view Collections.UnmodifiableMap download Collections.UnmodifiableMap.java

java.lang.Object
  extended byjava.util.Collections.UnmodifiableMap
All Implemented Interfaces:
Map, java.io.Serializable
Direct Known Subclasses:
Collections.UnmodifiableSortedMap
Enclosing class:
Collections

private static class Collections.UnmodifiableMap
extends java.lang.Object
implements Map, java.io.Serializable

The implementation of Collections.unmodifiableMap(Map) 55 . This class name is required for compatibility with Sun's JDK serializability.


Nested Class Summary
private static class Collections.UnmodifiableMap.UnmodifiableEntrySet
          The implementation of UnmodifiableMap#entrySet().
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
private  Set entries
          Cache the entry set.
private  Set keys
          Cache the key set.
private  Map m
          The wrapped map.
private static long serialVersionUID
          Compatible with JDK 1.4.
private  Collection values
          Cache the value collection.
 
Constructor Summary
(package private) Collections.UnmodifiableMap(Map m)
          Wrap a given map.
 
Method Summary
 void clear()
          Blocks the clearing of entries from the underlying map.
 boolean containsKey(java.lang.Object key)
          Returns true if the underlying map contains a mapping for the given key.
 boolean containsValue(java.lang.Object value)
          Returns true if the underlying map contains at least one mapping with the given value.
 Set entrySet()
          Returns a unmodifiable set view of the entries in the underlying map.
 boolean equals(java.lang.Object o)
          Returns true if the object, o, is also an instance of Map with an equal set of map entries.
 java.lang.Object get(java.lang.Object key)
          Returns the value associated with the supplied key or null if no such mapping exists.
 int hashCode()
          Computes the hash code for the underlying map, as the sum of the hash codes of all entries.
 boolean isEmpty()
          Returns true if the underlying map contains no entries.
 Set keySet()
          Returns a unmodifiable set view of the keys in the underlying map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Blocks the addition of a new entry to the underlying map.
 void putAll(Map m)
          Blocks the addition of the entries in the supplied map.
 java.lang.Object remove(java.lang.Object o)
          Blocks the removal of an entry from the map.
 int size()
          Returns the number of key-value mappings in the underlying map.
 java.lang.String toString()
          Returns a textual representation of the map.
 Collection values()
          Returns a unmodifiable collection view of the values in the underlying map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Compatible with JDK 1.4.

See Also:
Constant Field Values

m

private final Map m
The wrapped map.


entries

private transient Set entries
Cache the entry set.


keys

private transient Set keys
Cache the key set.


values

private transient Collection values
Cache the value collection.

Constructor Detail

Collections.UnmodifiableMap

Collections.UnmodifiableMap(Map m)
Wrap a given map.

Method Detail

clear

public void clear()
Blocks the clearing of entries from the underlying map. This method never returns, throwing an exception instead.

Specified by:
clear in interface Map

containsKey

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

Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if the underlying map contains at least one mapping with the given value. In other words, it returns true if a value v exists where (value == null ? v == null : value.equals(v)). This usually requires linear time.

Specified by:
containsValue in interface Map

entrySet

public Set entrySet()
Returns a unmodifiable set view of the entries in the underlying map. Each element in the set is a unmodifiable variant of Map.Entry. The set is backed by the map, so that changes in one show up in the other. Modifications made while an iterator is in progress cause undefined behavior. These modifications are again limited to the values of the objects.

Specified by:
entrySet in interface Map

equals

public boolean equals(java.lang.Object o)
Returns true if the object, o, is also an instance of Map with an equal set of map entries.

Specified by:
equals in interface Map

get

public java.lang.Object get(java.lang.Object key)
Returns the value associated with the supplied key or null if no such mapping exists. An ambiguity can occur if null values are accepted by the underlying map. In this case, containsKey() can be used to separate the two possible cases of a null result.

Specified by:
get in interface Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Blocks the addition of a new entry to the underlying map. This method never returns, throwing an exception instead.

Specified by:
put in interface Map

hashCode

public int hashCode()
Computes the hash code for the underlying map, as the sum of the hash codes of all entries.

Specified by:
hashCode in interface Map

isEmpty

public boolean isEmpty()
Returns true if the underlying map contains no entries.

Specified by:
isEmpty in interface Map

keySet

public Set keySet()
Returns a unmodifiable set view of the keys in the underlying map. The set is backed by the map, so that changes in one show up in the other. Modifications made while an iterator is in progress cause undefined behavior. These modifications are again limited to the values of the keys.

Specified by:
keySet in interface Map

putAll

public void putAll(Map m)
Blocks the addition of the entries in the supplied map. This method never returns, throwing an exception instead.

Specified by:
putAll in interface Map

remove

public java.lang.Object remove(java.lang.Object o)
Blocks the removal of an entry from the map. This method never returns, throwing an exception instead.

Specified by:
remove in interface Map

size

public int size()
Returns the number of key-value mappings in the underlying map. If there are more than Integer.MAX_VALUE mappings, Integer.MAX_VALUE is returned.

Specified by:
size in interface Map

toString

public java.lang.String toString()
Returns a textual representation of the map.


values

public Collection values()
Returns a unmodifiable collection view of the values in the underlying map. The collection is backed by the map, so that changes in one show up in the other. Modifications made while an iterator is in progress cause undefined behavior. These modifications are again limited to the values of the keys.

Specified by:
values in interface Map