org.gcube.data.streams.adapters
Class ResultsetStream<E extends gr.uoa.di.madgik.grs.record.Record>

java.lang.Object
  extended by org.gcube.data.streams.LookAheadStream<E>
      extended by org.gcube.data.streams.adapters.ResultsetStream<E>
All Implemented Interfaces:
Iterator<E>, Stream<E>

public class ResultsetStream<E extends gr.uoa.di.madgik.grs.record.Record>
extends LookAheadStream<E>

A Stream adapter for gRS2 resultsets.

This implementation is not thread safe.

Author:
Fabio Simeoni

Field Summary
static int default_timeout
           
static TimeUnit default_timeout_unit
           
 
Fields inherited from class org.gcube.data.streams.LookAheadStream
element, hasNext
 
Constructor Summary
ResultsetStream(URI locator)
          Creates a new instance with a result set locator.
 
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
 boolean isClosed()
          Returns true if the stream has been closed.
 URI locator()
          Returns the stream locator.
 void remove()
           
 void setTimeout(long timeout, TimeUnit unit)
           
 
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
 

Field Detail

default_timeout

public static final int default_timeout
See Also:
Constant Field Values

default_timeout_unit

public static final TimeUnit default_timeout_unit
Constructor Detail

ResultsetStream

public ResultsetStream(URI locator)
                throws IllegalArgumentException
Creates a new instance with a result set locator.

Parameters:
locator - the locator.
Throws:
IllegalArgumentException - if the locator is null.
Method Detail

setTimeout

public void setTimeout(long timeout,
                       TimeUnit unit)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

delegateNext

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

Specified by:
delegateNext in class LookAheadStream<E extends gr.uoa.di.madgik.grs.record.Record>
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 extends gr.uoa.di.madgik.grs.record.Record>
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 suppressed otherwise.


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()

isClosed

public boolean isClosed()
Description copied from interface: Stream
Returns true if the stream has been closed.

Returns:
true if the stream has been closed


Copyright © 2012. All Rights Reserved.