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

Quick Search    Search Deep

java.util
Class Collections.UnmodifiableSortedMap  view Collections.UnmodifiableSortedMap download Collections.UnmodifiableSortedMap.java

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

private static class Collections.UnmodifiableSortedMap
extends Collections.UnmodifiableMap
implements SortedMap

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:
comparator in interface SortedMap

firstKey

public java.lang.Object firstKey()
Returns the first (lowest sorted) key in the map.

Specified by:
firstKey in interface SortedMap

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

Specified by:
headMap in interface SortedMap

lastKey

public java.lang.Object lastKey()
Returns the last (highest sorted) key in the map.

Specified by:
lastKey in interface SortedMap

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.

Specified by:
subMap in interface SortedMap

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

Specified by:
tailMap in interface SortedMap

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