org.archive.io
Class ArchiveReader.ArchiveRecordIterator

java.lang.Object
  extended by org.archive.io.ArchiveReader.ArchiveRecordIterator
All Implemented Interfaces:
java.util.Iterator<ArchiveRecord>
Enclosing class:
ArchiveReader

protected class ArchiveReader.ArchiveRecordIterator
extends java.lang.Object
implements java.util.Iterator<ArchiveRecord>

Inner ArchiveRecord Iterator class. Throws RuntimeExceptions in hasNext() and next() if trouble pulling record from underlying stream.

Author:
stack

Constructor Summary
protected ArchiveReader.ArchiveRecordIterator()
           
 
Method Summary
protected  ArchiveRecord exceptionNext()
          A next that throws exceptions and has handling of recoverable exceptions moving us to next record.
 boolean hasNext()
           
protected  boolean innerHasNext()
           
protected  ArchiveRecord innerNext()
           
 ArchiveRecord next()
          Tries to move to next record if we get RecoverableIOException.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArchiveReader.ArchiveRecordIterator

protected ArchiveReader.ArchiveRecordIterator()
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<ArchiveRecord>
Returns:
True if we have more records to read.
Throws:
java.lang.RuntimeException - Can throw an IOException wrapped in a RuntimeException if a problem reading underlying stream (Corrupted gzip, etc.).

innerHasNext

protected boolean innerHasNext()

next

public ArchiveRecord next()
Tries to move to next record if we get RecoverableIOException. If not strict tries to move to next record if we get an IOException.

Specified by:
next in interface java.util.Iterator<ArchiveRecord>
Returns:
Next object.
Throws:
java.lang.RuntimeException - Throws a runtime exception, usually a wrapping of an IOException, if trouble getting a record (Throws exception rather than return null).

exceptionNext

protected ArchiveRecord exceptionNext()
                               throws java.io.IOException,
                                      java.lang.RuntimeException
A next that throws exceptions and has handling of recoverable exceptions moving us to next record. Can call hasNext which itself may throw exceptions.

Returns:
Next record.
Throws:
java.io.IOException
java.lang.RuntimeException - Thrown when we've reached maximum retries.

innerNext

protected ArchiveRecord innerNext()
                           throws java.io.IOException
Throws:
java.io.IOException

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<ArchiveRecord>


Copyright © 2003-2011 Internet Archive. All Rights Reserved.