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

Quick Search    Search Deep

java.util
Class Collections.UnmodifiableSortedSet  view Collections.UnmodifiableSortedSet download Collections.UnmodifiableSortedSet.java

java.lang.Object
  extended byjava.util.Collections.UnmodifiableCollection
      extended byjava.util.Collections.UnmodifiableSet
          extended byjava.util.Collections.UnmodifiableSortedSet
All Implemented Interfaces:
Collection, java.lang.Iterable, java.io.Serializable, Set, SortedSet
Enclosing class:
Collections

private static class Collections.UnmodifiableSortedSet
extends Collections.UnmodifiableSet
implements SortedSet

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


Field Summary
(package private)  Collection c
          The wrapped collection.
private static long serialVersionUID
          Compatible with JDK 1.4.
private  SortedSet ss
          The wrapped set; stored both here and in the superclass to avoid excessive casting.
 
Constructor Summary
(package private) Collections.UnmodifiableSortedSet(SortedSet ss)
          Wrap a given set.
 
Method Summary
 boolean add(java.lang.Object o)
          Blocks the addition of elements to the underlying collection.
 boolean addAll(Collection c)
          Blocks the addition of a collection of elements to the underlying collection.
 void clear()
          Blocks the clearing of the underlying collection.
 Comparator comparator()
          Returns the comparator used in sorting the underlying set, or null if it is the elements' natural ordering.
 boolean contains(java.lang.Object o)
          Test whether the underlying collection contains a given object as one of its elements.
 boolean containsAll(Collection c1)
          Test whether the underlying collection contains every element in a given collection.
 boolean equals(java.lang.Object o)
          Returns true if the object, o, is also an instance of Set of the same size and with the same entries.
 java.lang.Object first()
          Returns the first (lowest sorted) element in the underlying set.
 int hashCode()
          Computes the hash code of this set, as the sum of the hash codes of all elements within the set.
 SortedSet headSet(java.lang.Object toElement)
          Returns a unmodifiable view of the portion of the set strictly less than toElement.
 boolean isEmpty()
          Tests whether the underlying collection is empty, that is, if size() == 0.
 Iterator iterator()
          Obtain an Iterator over the underlying collection, which maintains its unmodifiable nature.
 java.lang.Object last()
          Returns the last (highest sorted) element in the underlying set.
 boolean remove(java.lang.Object o)
          Blocks the removal of an object from the underlying collection.
 boolean removeAll(Collection c)
          Blocks the removal of a collection of objects from the underlying collection.
 boolean retainAll(Collection c)
          Blocks the removal of all elements from the underlying collection, except those in the supplied collection.
 int size()
          Retrieves the number of elements in the underlying collection.
 SortedSet subSet(java.lang.Object fromElement, java.lang.Object toElement)
          Returns a unmodifiable view of the portion of the set greater than or equal to fromElement, and strictly less than toElement.
 SortedSet tailSet(java.lang.Object fromElement)
          Returns a unmodifiable view of the portion of the set greater than or equal to fromElement.
 java.lang.Object[] toArray()
          Copy the current contents of the underlying collection into an array.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Copy the current contents of the underlying collection into an array.
 java.lang.String toString()
          A textual representation of the unmodifiable collection.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Compatible with JDK 1.4.

See Also:
Constant Field Values

ss

private SortedSet ss
The wrapped set; stored both here and in the superclass to avoid excessive casting.


c

final Collection c
The wrapped collection. Package visible for use by subclasses.

Constructor Detail

Collections.UnmodifiableSortedSet

Collections.UnmodifiableSortedSet(SortedSet ss)
Wrap a given set.

Method Detail

comparator

public Comparator comparator()
Returns the comparator used in sorting the underlying set, or null if it is the elements' natural ordering.

Specified by:
comparator in interface SortedSet

first

public java.lang.Object first()
Returns the first (lowest sorted) element in the underlying set.

Specified by:
first in interface SortedSet

headSet

public SortedSet headSet(java.lang.Object toElement)
Returns a unmodifiable view of the portion of the set strictly less than toElement. The view is backed by the underlying set, so changes in one show up in the other. The subset supports all optional operations of the original. This operation is equivalent to subSet(first(), toElement).

The returned set throws an IllegalArgumentException any time an element is used which is out of the range of toElement. Note that the endpoint, toElement, is not included; if you want this value included, pass its successor object in to toElement. For example, for Integers, you could request headSet(new Integer(limit.intValue() + 1)).

Specified by:
headSet in interface SortedSet

last

public java.lang.Object last()
Returns the last (highest sorted) element in the underlying set.

Specified by:
last in interface SortedSet

subSet

public SortedSet subSet(java.lang.Object fromElement,
                        java.lang.Object toElement)
Returns a unmodifiable view of the portion of the set greater than or equal to fromElement, and strictly less than toElement. The view is backed by the underlying set, so changes in one show up in the other. The subset supports all optional operations of the original.

The returned set throws an IllegalArgumentException any time an element is used which is out of the range of fromElement and toElement. 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 can request subSet(new Integer(lowlimit.intValue() + 1), new Integer(highlimit.intValue() + 1)) to reverse the inclusiveness of both endpoints.

Specified by:
subSet in interface SortedSet

tailSet

public SortedSet tailSet(java.lang.Object fromElement)
Returns a unmodifiable view of the portion of the set greater than or equal to fromElement. The view is backed by the underlying set, so changes in one show up in the other. The subset supports all optional operations of the original.

The returned set throws an IllegalArgumentException any time an element is used which is out of the range of fromElement. Note that the endpoint, fromElement, is included; if you do not want this value to be included, pass its successor object in to fromElement. For example, for Integers, you could request tailSet(new Integer(limit.intValue() + 1)).

Specified by:
tailSet in interface SortedSet

equals

public boolean equals(java.lang.Object o)
Returns true if the object, o, is also an instance of Set of the same size and with the same entries.

Specified by:
equals in interface Set

hashCode

public int hashCode()
Computes the hash code of this set, as the sum of the hash codes of all elements within the set.

Specified by:
hashCode in interface Set

add

public boolean add(java.lang.Object o)
Blocks the addition of elements to the underlying collection. This method never returns, throwing an exception instead.

Specified by:
add in interface Collection

addAll

public boolean addAll(Collection c)
Blocks the addition of a collection of elements to the underlying collection. This method never returns, throwing an exception instead.

Specified by:
addAll in interface Collection

clear

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

Specified by:
clear in interface Collection

contains

public boolean contains(java.lang.Object o)
Test whether the underlying collection contains a given object as one of its elements.

Specified by:
contains in interface Collection

containsAll

public boolean containsAll(Collection c1)
Test whether the underlying collection contains every element in a given collection.

Specified by:
containsAll in interface Collection

isEmpty

public boolean isEmpty()
Tests whether the underlying collection is empty, that is, if size() == 0.

Specified by:
isEmpty in interface Collection

iterator

public Iterator iterator()
Obtain an Iterator over the underlying collection, which maintains its unmodifiable nature.

Specified by:
iterator in interface Collection

remove

public boolean remove(java.lang.Object o)
Blocks the removal of an object from the underlying collection. This method never returns, throwing an exception instead.

Specified by:
remove in interface Collection

removeAll

public boolean removeAll(Collection c)
Blocks the removal of a collection of objects from the underlying collection. This method never returns, throwing an exception instead.

Specified by:
removeAll in interface Collection

retainAll

public boolean retainAll(Collection c)
Blocks the removal of all elements from the underlying collection, except those in the supplied collection. This method never returns, throwing an exception instead.

Specified by:
retainAll in interface Collection

size

public int size()
Retrieves the number of elements in the underlying collection.

Specified by:
size in interface Collection

toArray

public java.lang.Object[] toArray()
Copy the current contents of the underlying collection into an array.

Specified by:
toArray in interface Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Copy the current contents of the underlying collection into an array. If the array passed as an argument has length less than the size of the underlying collection, an array of the same run-time type as a, with a length equal to the size of the underlying collection, is allocated using reflection. Otherwise, a itself is used. The elements of the underlying collection are copied into it, and if there is space in the array, the following element is set to null. The resultant array is returned. Note: The fact that the following element is set to null is only useful if it is known that this collection does not contain any null elements.

Specified by:
toArray in interface Collection

toString

public java.lang.String toString()
A textual representation of the unmodifiable collection.