xxl.cursors
Class ArrayCursor

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

public class ArrayCursor
extends java.lang.Object
implements Cursor

The ArrayCursor constructs a Cursor for a given Array.


Field Summary
protected  java.lang.Object[] array
          Data array.
protected  java.lang.Integer index
          Actual position in the array.
protected  java.util.Iterator indices
          Iterator of indices of the elements that are to be returned by the ArrayCursor.
 
Constructor Summary
ArrayCursor(java.lang.Object[] array)
          Creates a new ArrayCursor.
ArrayCursor(java.lang.Object[] array, java.util.Iterator indices)
          Creates a new ArrayCursor.
 
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).
 void reset()
          Resets the Cursor to its initial state.
 boolean supportsPeek()
          Returns true if the peek operation is supported by this PeekIterator (Always returns false.).
 void update(java.lang.Object object)
          Replaces the object that was returned by the last call to next() or peek().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

protected java.lang.Object[] array
Data array.

indices

protected java.util.Iterator indices
Iterator of indices of the elements that are to be returned by the ArrayCursor.

index

protected java.lang.Integer index
Actual position in the array.
Constructor Detail

ArrayCursor

public ArrayCursor(java.lang.Object[] array,
                   java.util.Iterator indices)
Creates a new ArrayCursor.
Parameters:
array - the Array fow which the Cursor is to be created
indices - Iterator of indices. The indices of this iterator determine which elements will be returned.

ArrayCursor

public ArrayCursor(java.lang.Object[] array)
Creates a new ArrayCursor. The elements from array[0] to array[array.length-1] will be returned by this ArrayCursor.
Parameters:
array - the Array for which the Cursor is to be created
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).
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 (Always returns false.).
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.IllegalStateException
Replaces the object that was returned by the last call to next() or peek(). 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()