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

java.lang.Objectjava.util.Collections.UnmodifiableMap
java.util.Collections.UnmodifiableSortedMap
- All Implemented Interfaces:
- Map, java.io.Serializable, SortedMap
- Enclosing class:
- Collections
- private static class Collections.UnmodifiableSortedMap
- extends Collections.UnmodifiableMap
- implements SortedMap
- extends Collections.UnmodifiableMap
The implementation of Collections.unmodifiableSortedMap(SortedMap) 55 . This
class name is required for compatibility with Sun's JDK serializability.
| Nested Class Summary |
| Nested classes inherited from class java.util.Map |
Map.Entry |
| Field Summary | |
private static long |
serialVersionUID
Compatible with JDK 1.4. |
private SortedMap |
sm
The wrapped map; stored both here and in the superclass to avoid excessive casting. |
| Constructor Summary | |
(package private) |
Collections.UnmodifiableSortedMap(SortedMap sm)
Wrap a given map. |
| Method Summary | |
void |
clear()
Blocks the clearing of entries from the underlying map. |
Comparator |
comparator()
Returns the comparator used in sorting the underlying map, or null if it is the keys' natural ordering. |
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 |
firstKey()
Returns the first (lowest sorted) key in the map. |
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. |
SortedMap |
headMap(java.lang.Object toKey)
Returns a unmodifiable view of the portion of the map strictly less than toKey. |
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 |
lastKey()
Returns the last (highest sorted) key in the 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. |
SortedMap |
subMap(java.lang.Object fromKey,
java.lang.Object toKey)
Returns a unmodifiable view of the portion of the map greater than or equal to fromKey, and strictly less than toKey. |
SortedMap |
tailMap(java.lang.Object fromKey)
Returns a unmodifiable view of the portion of the map greater than or equal to fromKey. |
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 |
| Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Field Detail |
serialVersionUID
private static final long serialVersionUID
- Compatible with JDK 1.4.
- See Also:
- Constant Field Values
sm
private final SortedMap sm
- The wrapped map; stored both here and in the superclass to avoid
excessive casting.
| Constructor Detail |
Collections.UnmodifiableSortedMap
Collections.UnmodifiableSortedMap(SortedMap sm)
- Wrap a given map.
| Method Detail |
comparator
public Comparator comparator()
- Returns the comparator used in sorting the underlying map,
or null if it is the keys' natural ordering.
- Specified by:
comparatorin interfaceSortedMap
firstKey
public java.lang.Object firstKey()
headMap
public SortedMap headMap(java.lang.Object toKey)
- Returns a unmodifiable view of the portion of the map strictly less
than toKey. The view is backed by the underlying map, so changes in
one show up in the other. The submap supports all optional operations
of the original. This operation is equivalent to
subMap(firstKey(), toKey).The returned map throws an IllegalArgumentException any time a key is used which is out of the range of toKey. Note that the endpoint, toKey, is not included; if you want this value to be included, pass its successor object in to toKey. For example, for Integers, you could request
headMap(new Integer(limit.intValue() + 1)).
lastKey
public java.lang.Object lastKey()
subMap
public SortedMap subMap(java.lang.Object fromKey, java.lang.Object toKey)
- Returns a unmodifiable view of the portion of the map greater than or
equal to fromKey, and strictly less than toKey. The view is backed by
the underlying map, so changes in one show up in the other. The submap
supports all optional operations of the original.
The returned map throws an IllegalArgumentException any time a key is used which is out of the range of fromKey and toKey. Note that the lower endpoint is included, but the upper is not; if you want to change the inclusion or exclusion of an endpoint, pass its successor object in instead. For example, for Integers, you could request
subMap(new Integer(lowlimit.intValue() + 1), new Integer(highlimit.intValue() + 1))to reverse the inclusiveness of both endpoints.
tailMap
public SortedMap tailMap(java.lang.Object fromKey)
- Returns a unmodifiable view of the portion of the map greater than or
equal to fromKey. The view is backed by the underlying map, so changes
in one show up in the other. The submap supports all optional operations
of the original.
The returned map throws an IllegalArgumentException any time a key is used which is out of the range of fromKey. Note that the endpoint, fromKey, is included; if you do not want this value to be included, pass its successor object in to fromKey. For example, for Integers, you could request
tailMap(new Integer(limit.intValue() + 1)).
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