org.gcube.data.streams
Class LookAheadStream<E>
java.lang.Object
org.gcube.data.streams.LookAheadStream<E>
- Type Parameters:
E - the type of stream elements
- All Implemented Interfaces:
- Iterator<E>, Stream<E>
- Direct Known Subclasses:
- FoldedStream, GuardedStream, MonitoredStream, PipedStream, ResultsetStream, UnfoldedStream
public abstract class LookAheadStream<E>
- extends Object
- implements Stream<E>
Partial Stream implementation based on look-ahead operations over an underlying stream.
The implementation attempts to prefetch the output of next() in hasNext(). If a failure occurs,
hasNext():
keeps consuming the underlying stream as long as the failure is a StreamSkipSignal;
consults a FaultHandler for all the other failures. If the FaultHandler re-throws the same or a
different exception, the implementation throws it at the following next().
- Author:
- Fabio Simeoni
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
hasNext
protected Boolean hasNext
element
protected E element
LookAheadStream
public LookAheadStream()
setHandler
public void setHandler(FaultHandler handler)
throws IllegalArgumentException
- Sets the
FaultHandler for the iteration
- Parameters:
handler - the handler
- Throws:
IllegalArgumentException - if the handler is null
hasNext
public final boolean hasNext()
- Specified by:
hasNext in interface Iterator<E>- Specified by:
hasNext in interface Stream<E>
next
public final E next()
- Specified by:
next in interface Iterator<E>- Specified by:
next in interface Stream<E>
delegateNext
protected abstract E delegateNext()
- Returns an element of the underlying stream
- Returns:
- the element
delegateHasNext
protected abstract boolean delegateHasNext()
- Returns
true if the underlying stream has more elements.
- Returns:
true if the underlying stream has more elements
Copyright © 2012. All Rights Reserved.