org.apache.commons.collections.iterators

Class SingletonListIterator

Implemented Interfaces:
ListIterator

public class SingletonListIterator
extends java.lang.Object
implements ListIterator

SingletonIterator is an ListIterator over a single object instance.
Version:
$Id: SingletonListIterator.java,v 1.2.2.1 2004/05/22 12:14:04 scolebourne Exp $
Author:
Stephen Colebourne
Since:
2.1

Constructor Summary

SingletonListIterator(Object object)
Constructs a new SingletonListIterator.

Method Summary

void
add(Object obj)
Add always throws UnsupportedOperationException.
boolean
hasNext()
Is another object available from the iterator.
boolean
hasPrevious()
Is a previous object available from the iterator.
Object
next()
Get the next object from the iterator.
int
nextIndex()
Returns the index of the element that would be returned by a subsequent call to next.
Object
previous()
Get the previous object from the iterator.
int
previousIndex()
Returns the index of the element that would be returned by a subsequent call to previous.
void
remove()
Remove always throws UnsupportedOperationException.
void
set(Object obj)
Set sets the value of the singleton.

Constructor Details

SingletonListIterator

public SingletonListIterator(Object object)
Constructs a new SingletonListIterator.
Parameters:
object - the single object to return from the iterator

Method Details

add

public void add(Object obj)
Add always throws UnsupportedOperationException.

hasNext

public boolean hasNext()
Is another object available from the iterator.

This returns true if the single object hasn't been returned yet.

Returns:
true if the single object hasn't been returned yet

hasPrevious

public boolean hasPrevious()
Is a previous object available from the iterator.

This returns true if the single object has been returned.

Returns:
true if the single object has been returned

next

public Object next()
Get the next object from the iterator.

This returns the single object if it hasn't been returned yet.

Returns:
the single object

nextIndex

public int nextIndex()
Returns the index of the element that would be returned by a subsequent call to next.
Returns:
0 or 1 depending on current state.

previous

public Object previous()
Get the previous object from the iterator.

This returns the single object if it has been returned.

Returns:
the single object

previousIndex

public int previousIndex()
Returns the index of the element that would be returned by a subsequent call to previous. A return value of -1 indicates that the iterator is currently at the start.
Returns:
0 or -1 depending on current state.

remove

public void remove()
Remove always throws UnsupportedOperationException.

set

public void set(Object obj)
Set sets the value of the singleton.
Parameters:
obj - the object to set

Copyright © 2001-2004 Apache Software Foundation. Documenation generated ${TODAY}.