org.gcube.data.streams.adapters
Class IteratorStream<E>

java.lang.Object
  extended by org.gcube.data.streams.adapters.IteratorStream<E>
Type Parameters:
E - the type of stream elements
All Implemented Interfaces:
Iterator<E>, Stream<E>

public class IteratorStream<E>
extends Object
implements Stream<E>

A Stream adapter for Iterators.

Author:
Fabio Simeoni

Constructor Summary
IteratorStream(Iterator<E> iterator)
          Creates an instance that adapts a given Iterator with a default IteratorAdapter.
IteratorStream(IteratorAdapter<E> adapter)
          Creates an instance that adapts a given Iterator with a given IteratorAdapter.
 
Method Summary
 void close()
          Closes the stream unconditionally, releasing any resources that it may be using.
 boolean hasNext()
          Returns true if the stream has more elements.
 URI locator()
          Returns the stream locator.
 E next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorStream

public IteratorStream(IteratorAdapter<E> adapter)
Creates an instance that adapts a given Iterator with a given IteratorAdapter.

Parameters:
iterator - the iterator
adapter - the adapter

IteratorStream

public IteratorStream(Iterator<E> iterator)
Creates an instance that adapts a given Iterator with a default IteratorAdapter.

Parameters:
iterator - the iterator
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: Stream
Returns true if the stream has more elements.

Specified by:
hasNext in interface Iterator<E>
Specified by:
hasNext in interface Stream<E>
Returns:
true if the stream has more elements and has not been closed.

next

public E next()
Specified by:
next in interface Iterator<E>
Specified by:
next in interface Stream<E>

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.

Specified by:
close in interface Stream<E>

locator

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

Specified by:
locator in interface Stream<E>
Returns:
the locator

remove

public void remove()
Specified by:
remove in interface Iterator<E>


Copyright © 2012. All Rights Reserved.