|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.util
Class Collections.UnmodifiableMap

java.lang.Objectjava.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
- extends java.lang.Object
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.
containsKey
public boolean containsKey(java.lang.Object key)
- Returns
trueif the underlying map contains a mapping for the given key.- Specified by:
containsKeyin interfaceMap
containsValue
public boolean containsValue(java.lang.Object value)
- Returns
trueif the underlying map contains at least one mapping with the given value. In other words, it returnstrueif a value v exists where(value == null ? v == null : value.equals(v)). This usually requires linear time.- Specified by:
containsValuein interfaceMap
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.
equals
public boolean equals(java.lang.Object o)
- Returns
trueif the object, o, is also an instance ofMapwith an equal set of map entries.
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.
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.
hashCode
public int hashCode()
- Computes the hash code for the underlying map, as the sum
of the hash codes of all entries.
isEmpty
public boolean isEmpty()
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.
putAll
public void putAll(Map m)
- Blocks the addition of the entries in the supplied map.
This method never returns, throwing an exception instead.
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.
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.
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.
|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.util.Collections.UnmodifiableMap