xxl.cursors
Class Enumerator

java.lang.Object
  |
  +--xxl.cursors.Enumerator

public class Enumerator
extends java.lang.Object
implements Cursor

The Enumerator-iterator returns a sequence of Integer-objects of a given range.


Field Summary
protected  int from
          Start of the sequence (inclusive).
protected  int next
          The value returned by the next call to next() or peek().
protected  int to
          End of the sequence (exclusive).
protected  boolean up
          If true the sequence is ascending else the sequence is descending.
 
Constructor Summary
Enumerator()
          Creates an Enumerator object.
Enumerator(int number)
          Creates an Enumerator object.
Enumerator(int from, int to)
          Creates an Enumerator object.
 
Method Summary
 void close()
          Closes the Cursor.
 boolean hasNext()
          Returns true if the iteration has more elements.
 java.lang.Object next()
          Returns the next element in the iteration.
 java.lang.Object peek()
          Shows the next element in the iteration without removing it.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation/This method always throws an UnsupportedOperationException).
 void reset()
          Resets the Cursor to its initial state.
 boolean supportsPeek()
          Returns true if the peek operation is supported by this PeekIterator (This method returns true.).
 void update(java.lang.Object object)
          Replaces the object that was returned by the last call to next() or peek() (This method always throws an UnsupportedOperationException).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

from

protected int from
Start of the sequence (inclusive).

to

protected int to
End of the sequence (exclusive).

next

protected int next
The value returned by the next call to next() or peek().

up

protected boolean up
If true the sequence is ascending else the sequence is descending.
Constructor Detail

Enumerator

public Enumerator(int from,
                  int to)
Creates an Enumerator object.
Parameters:
from - start of the sequence (inclusive)
to - end of the sequence (inclusive)

Enumerator

public Enumerator(int number)
Creates an Enumerator object. start = 0. end = number.
Parameters:
number - end of the sequence (exclusive)

Enumerator

public Enumerator()
Creates an Enumerator object. start = 0. end = Integer.MAX_VALUE.
Method Detail

close

public void close()
Closes the Cursor. Signals the cursor to cleanup resources, close files, etc. After a call to close() calls to methods like next() or peek() are not guarantied to yield proper results.
Specified by:
close in interface Cursor

hasNext

public boolean hasNext()
Returns true if the iteration has more elements.
Specified by:
hasNext in interface Cursor
Returns:
true if the iterator has more elements.

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Returns the next element in the iteration.
Specified by:
next in interface Cursor
Returns:
the next element in the iteration.
Throws:
java.util.NoSuchElementException - iteration has no more elements.

peek

public java.lang.Object peek()
                      throws java.lang.UnsupportedOperationException
Shows the next element in the iteration without removing it.
Specified by:
peek in interface Cursor
Returns:
the next element in the iteration.
Throws:
java.util.NoSuchElementException - iteration has no more elements.
java.lang.UnsupportedOperationException - if the peek operation is not supported by this PeekIterator.

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Removes from the underlying collection the last element returned by the iterator (optional operation/This method always throws an UnsupportedOperationException).
Specified by:
remove in interface Cursor
Throws:
java.lang.IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.
java.lang.UnsupportedOperationException - if the remove operation is not supported by this PeekIterator.

reset

public void reset()
           throws java.lang.UnsupportedOperationException
Resets the Cursor to its initial state.
Specified by:
reset in interface Cursor

supportsPeek

public boolean supportsPeek()
Returns true if the peek operation is supported by this PeekIterator (This method returns true.).
Specified by:
supportsPeek in interface Cursor
Returns:
true if the peek operation is supported by this PeekIterator.

update

public void update(java.lang.Object object)
            throws java.lang.UnsupportedOperationException
Replaces the object that was returned by the last call to next() or peek() (This method always throws an UnsupportedOperationException). This operation must not be called after a call to hasNext(). It should follow a call to next() or peek().
Specified by:
update in interface Cursor
Parameters:
object - the object that replaces the object returned by the last call to next() or peek()