com.aliasi.util
Class Iterators.Buffered<E>

java.lang.Object
  extended by com.aliasi.util.Iterators.Buffered<E>
Type Parameters:
E - the type of objects returned by the iterator
All Implemented Interfaces:
Iterator<E>
Enclosing class:
Iterators

public abstract static class Iterators.Buffered<E>
extends Object
implements Iterator<E>

An Iterators.Buffered uses a single method to return objects, buffering the result and returning it as the next element if it is non-null. This class does not support null return values for next(). The remove() operation is unsupported, but may be overridden.

Since:
LingPipe1.0
Version:
3.0
Author:
Bob Carpenter

Constructor Summary
protected Iterators.Buffered()
          Construct a buffered iterator.
 
Method Summary
protected abstract  E bufferNext()
          Returns the next object for this iterator, or null if there are no more objects.
 boolean hasNext()
          Returns true if the next call to next() will return a non-null value.
 E next()
          Returns the next object for this iterator.
 void remove()
          Throws an unsupported operation exception unless overridden by a subclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Iterators.Buffered

protected Iterators.Buffered()
Construct a buffered iterator. This constructor does not do anything.

Method Detail

bufferNext

protected abstract E bufferNext()
Returns the next object for this iterator, or null if there are no more objects.

Returns:
Next object for this iterator.

hasNext

public boolean hasNext()
Returns true if the next call to next() will return a non-null value.

Specified by:
hasNext in interface Iterator<E>
Returns:
true if the next call to next() will return a non-null value.

next

public E next()
Returns the next object for this iterator.

Specified by:
next in interface Iterator<E>
Returns:
The next object for this iterator.
Throws:
NoSuchElementException - If there are no more elements.

remove

public void remove()
Throws an unsupported operation exception unless overridden by a subclass.

Specified by:
remove in interface Iterator<E>
Throws:
UnsupportedOperationException - Always.