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

Quick Search    Search Deep

org.mortbay.util
Class SingletonList  view SingletonList download SingletonList.java

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byorg.mortbay.util.SingletonList
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable, java.util.List

public class SingletonList
extends java.util.AbstractList

Singleton List. This simple efficient implementation of a List with a single element is provided for JDK 1.2 JVMs, which do not provide the Collections.singletonList method.

Version:
$Revision: 1.2 $

Nested Class Summary
private  class SingletonList.SIterator
           
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
private  java.lang.Object o
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
private SingletonList(java.lang.Object o)
           
 
Method Summary
 java.lang.Object get(int i)
          Returns the elements at the specified position in the list.
 java.util.Iterator iterator()
          Obtain an Iterator over this list, whose sequence is the list order.
 java.util.ListIterator listIterator()
          Obtain a ListIterator over this list, starting at the beginning.
 java.util.ListIterator listIterator(int i)
          Obtain a ListIterator over this list, starting at a given position.
static SingletonList newSingletonList(java.lang.Object o)
           
 int size()
          Get the number of elements in this list.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

o

private java.lang.Object o
Constructor Detail

SingletonList

private SingletonList(java.lang.Object o)
Method Detail

newSingletonList

public static SingletonList newSingletonList(java.lang.Object o)

get

public java.lang.Object get(int i)
Description copied from class: java.util.AbstractList
Returns the elements at the specified position in the list.


size

public int size()
Description copied from interface: java.util.List
Get the number of elements in this list. If the list contains more than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.


listIterator

public java.util.ListIterator listIterator()
Description copied from class: java.util.AbstractList
Obtain a ListIterator over this list, starting at the beginning. This implementation returns listIterator(0).


listIterator

public java.util.ListIterator listIterator(int i)
Description copied from class: java.util.AbstractList
Obtain a ListIterator over this list, starting at a given position. A first call to next() would return the same as get(index), and a first call to previous() would return the same as get(index - 1).

This implementation uses size(), get(int), set(int, Object), add(int, Object), and remove(int) of the backing list, and does not support remove, set, or add unless the list does. This implementation is fail-fast if you correctly maintain modCount.


iterator

public java.util.Iterator iterator()
Description copied from class: java.util.AbstractList
Obtain an Iterator over this list, whose sequence is the list order. This implementation uses size(), get(int), and remove(int) of the backing list, and does not support remove unless the list does. This implementation is fail-fast if you correctly maintain modCount. Also, this implementation is specified by Sun to be distinct from listIterator, although you could easily implement it as return listIterator(0).