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

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

public class RandomReaderIterator<T extends Record>
extends Object
implements ListIterator<T>

A list iterator implementing class that can be used to iterate over the Records accessible through a RandomReader instance

Author:
gpapanikos

Constructor Summary
protected RandomReaderIterator(RandomReader<T> reader)
          Creates a new instance that will iterate over the Records that are accessible through the provided RandomReader.
 
Method Summary
 void add(T o)
          
 boolean hasNext()
          
 boolean hasPrevious()
          
 T next()
          
 int nextIndex()
          
 T previous()
          
 int previousIndex()
          
 void remove()
          
 void set(T o)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomReaderIterator

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

Parameters:
reader - the RandomReader 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 RandomReader.getIteratorTimeout() and RandomReader.getIteratorTimeUnit()

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

next

public T next()

the RandomReader.get(long, java.util.concurrent.TimeUnit) method is used to retrieve the next available Record. The timeout values used are the ones defined by RandomReader.getIteratorTimeout() and RandomReader.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>
Specified by:
next in interface ListIterator<T extends Record>
See Also:
Iterator.next()

hasPrevious

public boolean hasPrevious()

If the status of the reader indicates that there are previous Records true is returned. Otherwise false

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

previous

public T previous()

The RandomReader.seek(long) method is used to move back the necessary number of records so that the next call to RandomReader.get() will return the previous record. If some error occurs during the record retrieval, null is returned

Specified by:
previous in interface ListIterator<T extends Record>
See Also:
ListIterator.previous()

nextIndex

public int nextIndex()

Operation is not supported. An IllegalStateException is thrown upon invocation

Specified by:
nextIndex in interface ListIterator<T extends Record>
See Also:
ListIterator.nextIndex()

previousIndex

public int previousIndex()

Operation is not supported. An IllegalStateException is thrown upon invocation

Specified by:
previousIndex in interface ListIterator<T extends Record>
See Also:
ListIterator.previousIndex()

remove

public void remove()

Operation is not supported. An IllegalStateException is thrown upon invocation

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

set

public void set(T o)

Operation is not supported. An IllegalStateException is thrown upon invocation

Specified by:
set in interface ListIterator<T extends Record>
See Also:
ListIterator.set(java.lang.Object)

add

public void add(T o)

Operation is not supported. An IllegalStateException is thrown upon invocation

Specified by:
add in interface ListIterator<T extends Record>
See Also:
ListIterator.add(java.lang.Object)


Copyright © 2012. All Rights Reserved.