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

java.lang.Objectjava.util.Collections.UnmodifiableCollection
java.util.Collections.UnmodifiableList
- All Implemented Interfaces:
- Collection, java.lang.Iterable, List, java.io.Serializable
- Direct Known Subclasses:
- Collections.UnmodifiableRandomAccessList
- Enclosing class:
- Collections
- private static class Collections.UnmodifiableList
- extends Collections.UnmodifiableCollection
- implements List
- extends Collections.UnmodifiableCollection
The implementation of Collections.unmodifiableList(List) 55 for sequential
lists. This class name is required for compatibility with Sun's JDK
serializability.
| Field Summary | |
(package private) Collection |
c
The wrapped collection. |
(package private) List |
list
The wrapped list; stored both here and in the superclass to avoid excessive casting. |
private static long |
serialVersionUID
Compatible with JDK 1.4. |
| Constructor Summary | |
(package private) |
Collections.UnmodifiableList(List l)
Wrap a given list. |
| Method Summary | |
void |
add(int index,
java.lang.Object o)
Blocks the addition of an element to the underlying list at a specific index. |
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. |
boolean |
addAll(int index,
Collection c)
Blocks the addition of a collection of elements to the underlying list at a specific index. |
void |
clear()
Blocks the clearing of the underlying collection. |
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 an instance of
List with the same size and elements
as the underlying list. |
java.lang.Object |
get(int index)
Retrieves the element at a given index in the underlying list. |
int |
hashCode()
Computes the hash code for the underlying list. |
int |
indexOf(java.lang.Object o)
Obtain the first index at which a given object is to be found in the underlying list. |
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. |
int |
lastIndexOf(java.lang.Object o)
Obtain the last index at which a given object is to be found in the underlying list. |
ListIterator |
listIterator()
Obtains a list iterator over the underlying list, starting at the beginning and maintaining the unmodifiable nature of this list. |
ListIterator |
listIterator(int index)
Obtains a list iterator over the underlying list, starting at the specified index and maintaining the unmodifiable nature of this list. |
java.lang.Object |
remove(int index)
Blocks the removal of the element at the specified index. |
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. |
java.lang.Object |
set(int index,
java.lang.Object o)
Blocks the replacement of the element at the specified index. |
int |
size()
Retrieves the number of elements in the underlying collection. |
List |
subList(int fromIndex,
int toIndex)
Obtain a List view of a subsection of the underlying list, from fromIndex (inclusive) to toIndex (exclusive). |
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.List |
add, addAll, clear, contains, containsAll, 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
list
final List list
- The wrapped list; stored both here and in the superclass to avoid
excessive casting. Package visible for use by subclass.
c
final Collection c
- The wrapped collection. Package visible for use by subclasses.
| Constructor Detail |
Collections.UnmodifiableList
Collections.UnmodifiableList(List l)
- Wrap a given list.
| Method Detail |
add
public void add(int index,
java.lang.Object o)
- Blocks the addition of an element to the underlying
list at a specific index. This method never returns,
throwing an exception instead.
addAll
public boolean addAll(int index,
Collection c)
- Blocks the addition of a collection of elements to the
underlying list at a specific index. This method never
returns, throwing an exception instead.
equals
public boolean equals(java.lang.Object o)
- Returns
trueif the object, o, is an instance ofListwith the same size and elements as the underlying list.
get
public java.lang.Object get(int index)
hashCode
public int hashCode()
- Computes the hash code for the underlying list.
The exact computation is described in the documentation
of the
Listinterface.
indexOf
public int indexOf(java.lang.Object o)
- Obtain the first index at which a given object is to be found in the
underlying list.
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Obtain the last index at which a given object is to be found in the
underlying list.
- Specified by:
lastIndexOfin interfaceList
listIterator
public ListIterator listIterator()
- Obtains a list iterator over the underlying list, starting at the beginning
and maintaining the unmodifiable nature of this list.
- Specified by:
listIteratorin interfaceList
listIterator
public ListIterator listIterator(int index)
- Obtains a list iterator over the underlying list, starting at the specified
index and maintaining the unmodifiable nature of this list. An initial call
to
next()will retrieve the element at the specified index, and an initial call toprevious()will retrieve the element at index - 1.- Specified by:
listIteratorin interfaceList
remove
public java.lang.Object remove(int index)
- Blocks the removal of the element at the specified index.
This method never returns, throwing an exception instead.
set
public java.lang.Object set(int index, java.lang.Object o)
- Blocks the replacement of the element at the specified index.
This method never returns, throwing an exception instead.
subList
public List subList(int fromIndex, int toIndex)
- Obtain a List view of a subsection of the underlying list, from
fromIndex (inclusive) to toIndex (exclusive). If the two indices
are equal, the sublist is empty. The returned list will be
unmodifiable, like this list. Changes to the elements of the
returned list will be reflected in the underlying list. No structural
modifications can take place in either list.
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:
addin interfaceCollection
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:
addAllin interfaceCollection
clear
public void clear()
- Blocks the clearing of the underlying collection. This method never
returns, throwing an exception instead.
- Specified by:
clearin interfaceCollection
contains
public boolean contains(java.lang.Object o)
- Test whether the underlying collection contains a given object as one of its
elements.
- Specified by:
containsin interfaceCollection
containsAll
public boolean containsAll(Collection c1)
- Test whether the underlying collection contains every element in a given
collection.
- Specified by:
containsAllin interfaceCollection
isEmpty
public boolean isEmpty()
- Tests whether the underlying collection is empty, that is,
if size() == 0.
- Specified by:
isEmptyin interfaceCollection
iterator
public Iterator iterator()
- Obtain an Iterator over the underlying collection, which maintains
its unmodifiable nature.
- Specified by:
iteratorin interfaceCollection
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:
removein interfaceCollection
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:
removeAllin interfaceCollection
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:
retainAllin interfaceCollection
size
public int size()
- Retrieves the number of elements in the underlying collection.
- Specified by:
sizein interfaceCollection
toArray
public java.lang.Object[] toArray()
- Copy the current contents of the underlying collection into an array.
- Specified by:
toArrayin interfaceCollection
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:
toArrayin interfaceCollection
toString
public java.lang.String toString()
- A textual representation of the unmodifiable collection.
|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC