org.gcube.data.streams.delegates
Class PipedStream<E1,E2>

java.lang.Object
  extended by org.gcube.data.streams.LookAheadStream<E2>
      extended by org.gcube.data.streams.delegates.PipedStream<E1,E2>
Type Parameters:
E1 - the type of elements of the input stream
E2 - the type of stream elements
All Implemented Interfaces:
Iterator<E2>, Stream<E2>

public class PipedStream<E1,E2>
extends LookAheadStream<E2>

A Stream of elements generated by the elements of an input Stream

Author:
Fabio Simeoni

Field Summary
 
Fields inherited from class org.gcube.data.streams.LookAheadStream
element, hasNext
 
Constructor Summary
PipedStream(Stream<E1> stream, Generator<E1,E2> generator)
          Creates an instance with a Stream and an element Generator.
 
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  E2 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

PipedStream

public PipedStream(Stream<E1> stream,
                   Generator<E1,E2> generator)
            throws IllegalArgumentException
Creates an instance with a Stream and an element Generator.

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

delegateNext

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

Specified by:
delegateNext in class LookAheadStream<E2>
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<E2>
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.