org.gcube.data.streams.delegates
Class GuardedStream<E>

java.lang.Object
  extended by org.gcube.data.streams.LookAheadStream<E>
      extended by org.gcube.data.streams.delegates.GuardedStream<E>
Type Parameters:
E - the type of stream element
All Implemented Interfaces:
Iterator<E>, Stream<E>

public class GuardedStream<E>
extends LookAheadStream<E>

A Stream that guards failures with a FaultHandler

Author:
Fabio Simeoni

Field Summary
 
Fields inherited from class org.gcube.data.streams.LookAheadStream
element, hasNext
 
Constructor Summary
GuardedStream(Stream<E> stream, FaultHandler handler)
          Creates an instance with a Stream and a FaultHandler
 
Method Summary
 void close()
          Closes the stream unconditionally, releasing any resources that it may be using.
protected  boolean delegateHasNext()
          Returns true if the underlying stream has more elements.
protected  E delegateNext()
          Returns an element of the underlying stream
 URI locator()
          Returns the stream locator.
 void remove()
           
 
Methods inherited from class org.gcube.data.streams.LookAheadStream
hasNext, next, setHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuardedStream

public GuardedStream(Stream<E> stream,
                     FaultHandler handler)
              throws IllegalArgumentException
Creates an instance with a Stream and a FaultHandler

Parameters:
stream - the stream
handler - the handler
Throws:
IllegalArgumentException - if the stream or the handler are null
Method Detail

delegateNext

protected E delegateNext()
Description copied from class: LookAheadStream
Returns an element of the underlying stream

Specified by:
delegateNext in class LookAheadStream<E>
Returns:
the element

delegateHasNext

protected boolean delegateHasNext()
Description copied from class: LookAheadStream
Returns true if the underlying stream has more elements.

Specified by:
delegateHasNext in class LookAheadStream<E>
Returns:
true if the underlying stream has more elements

close

public void close()
Description copied from interface: Stream
Closes the stream unconditionally, releasing any resources that it may be using.

Subsequent invocations of this method have no effect.
Subsequents invocations of Stream.hasNext() return false.
Subsequent invocations of Stream.next() throw NoSuchElementExceptions.

Failures are logged by implementations and are otherwise suppressed.


locator

public URI locator()
            throws IllegalStateException
Description copied from interface: Stream
Returns the stream locator.

Returns:
the locator
Throws:
IllegalStateException - if the stream is no longer addressable at the time of invocation.

remove

public void remove()


Copyright © 2012. All Rights Reserved.