gr.uoa.di.madgik.grs.reader
Class ForwardReaderIterator<T extends Record>

java.lang.Object
  extended by gr.uoa.di.madgik.grs.reader.ForwardReaderIterator<T>
Type Parameters:
T - The type of Records as defined in the respective ForwardReader
All Implemented Interfaces:
Iterator<T>

public class ForwardReaderIterator<T extends Record>
extends Object
implements Iterator<T>

An iterator implementing class that can be used to iterate over the Records accessible through a ForwardReader instance

Author:
gpapanikos

Constructor Summary
protected ForwardReaderIterator(ForwardReader<T> reader)
          Creates a new instance that will iterate over the Records that are accessible through the provided ForwardReader.
 
Method Summary
 boolean hasNext()
          
 T next()
          
 void remove()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardReaderIterator

protected ForwardReaderIterator(ForwardReader<T> reader)
Creates a new instance that will iterate over the Records that are accessible through the provided ForwardReader. If some records have been consumed through the ForwardReader provided, then they will not be served again from the iterator

Parameters:
reader - the ForwardReader to use to access the Records
Method Detail

hasNext

public boolean hasNext()

If the status of the reader indicates that there may be more Records available but have not yet reached the current reader through the respective mirroring procedure, then the ForwardReader.waitAvailable(long, java.util.concurrent.TimeUnit) is used with the timeout values defined by ForwardReader.getIteratorTimeout() and ForwardReader.getIteratorTimeUnit()

Specified by:
hasNext in interface Iterator<T extends Record>
See Also:
Iterator.hasNext()

next

public T next()

the ForwardReader.get(long, java.util.concurrent.TimeUnit) method is used to retrieve the next available Record. The timeout values used are the ones defined by ForwardReader.getIteratorTimeout() and ForwardReader.getIteratorTimeUnit(). in case there is some error during the Record retrieval or the timeout expired, null is returned

Specified by:
next in interface Iterator<T extends Record>
Throws:
GRS2UncheckedException - if exception is written in the RS by the writer when the reader reads it it throws is up as an unchecked GRS2UncheckedException exception. The reason that this exception is unchecked is to follow the java.util.Iterator interface
See Also:
Iterator.next()

remove

public void remove()

Operation is not supported. An IllegalStateException is thrown upon invocation

Specified by:
remove in interface Iterator<T extends Record>
See Also:
Iterator.remove()


Copyright © 2012. All Rights Reserved.