org.archive.util.iterator
Class LookaheadIterator<T>

java.lang.Object
  extended by org.archive.util.iterator.LookaheadIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>
Direct Known Subclasses:
LineReadingIterator, TransformingIteratorWrapper

public abstract class LookaheadIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

Superclass for Iterators which must probe ahead to know if a 'next' exists, and thus have a cached next between a call to hasNext() and next().

Author:
gojomo

Field Summary
protected  T next
           
 
Constructor Summary
LookaheadIterator()
           
 
Method Summary
 boolean hasNext()
          Test whether any items remain; loads next item into holding 'next' field.
protected abstract  boolean lookahead()
          Caches the next item if available.
 T next()
          Return the next item.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

next

protected T next
Constructor Detail

LookaheadIterator

public LookaheadIterator()
Method Detail

hasNext

public boolean hasNext()
Test whether any items remain; loads next item into holding 'next' field.

Specified by:
hasNext in interface java.util.Iterator<T>
See Also:
Iterator.hasNext()

lookahead

protected abstract boolean lookahead()
Caches the next item if available.

Returns:
true if there was a next item to cache, false otherwise

next

public T next()
Return the next item.

Specified by:
next in interface java.util.Iterator<T>
See Also:
Iterator.next()

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<T>


Copyright © 2003-2011 Internet Archive. All Rights Reserved.