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

Quick Search    Search Deep

java.util
Class Collections.SingletonList  view Collections.SingletonList download Collections.SingletonList.java

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Collections.SingletonList
All Implemented Interfaces:
Collection, java.lang.Iterable, List, RandomAccess, java.io.Serializable
Enclosing class:
Collections

private static final class Collections.SingletonList
extends AbstractList
implements java.io.Serializable, RandomAccess

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


Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
private  java.lang.Object element
          The single element.
private static long serialVersionUID
          Compatible with JDK 1.4.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
(package private) Collections.SingletonList(java.lang.Object o)
          Construct a singleton.
 
Method Summary
 boolean contains(java.lang.Object o)
          The set only contains one element.
 boolean containsAll(Collection c)
          This is true if the other collection only contains the element.
 java.lang.Object get(int index)
          Only index 0 is valid.
 int hashCode()
          Speed up the hashcode computation.
 int indexOf(java.lang.Object o)
          Either the list has it or not.
 int lastIndexOf(java.lang.Object o)
          Either the list has it or not.
 int size()
          The size: always 1!
 List subList(int from, int to)
          Sublists are limited in scope.
 java.lang.Object[] toArray()
          Returning an array is simple.
 java.lang.String toString()
          Obvious string.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, iterator, listIterator, listIterator, remove, removeRange, set
 
Methods inherited from class java.util.AbstractCollection
addAll, equals, hashCode, isEmpty, remove, removeAll, removeAllInternal, retainAll, retainAllInternal, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, isEmpty, remove, removeAll, retainAll, toArray
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Compatible with JDK 1.4.

See Also:
Constant Field Values

element

private final java.lang.Object element
The single element.

Constructor Detail

Collections.SingletonList

Collections.SingletonList(java.lang.Object o)
Construct a singleton.

Method Detail

size

public int size()
The size: always 1!

Specified by:
size in interface List
Specified by:
size in class AbstractCollection

get

public java.lang.Object get(int index)
Only index 0 is valid.

Specified by:
get in interface List
Specified by:
get in class AbstractList

contains

public boolean contains(java.lang.Object o)
The set only contains one element.

Specified by:
contains in interface List
Overrides:
contains in class AbstractCollection

containsAll

public boolean containsAll(Collection c)
This is true if the other collection only contains the element.

Specified by:
containsAll in interface List
Overrides:
containsAll in class AbstractCollection

hashCode

public int hashCode()
Speed up the hashcode computation.

Specified by:
hashCode in interface List
Overrides:
hashCode in class AbstractList

indexOf

public int indexOf(java.lang.Object o)
Either the list has it or not.

Specified by:
indexOf in interface List
Overrides:
indexOf in class AbstractList

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Either the list has it or not.

Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class AbstractList

subList

public List subList(int from,
                    int to)
Sublists are limited in scope.

Specified by:
subList in interface List
Overrides:
subList in class AbstractList

toArray

public java.lang.Object[] toArray()
Returning an array is simple.

Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection

toString

public java.lang.String toString()
Obvious string.

Overrides:
toString in class AbstractCollection