public class AsciiLineReaderIterator extends java.lang.Object implements LocationAware, LineIterator, java.io.Closeable
AsciiLineReader.
This class is slower than other LineIterators because it is driven by AsciiLineReader, but offers the benefit of
implementing LocationAware, which is required for indexing. If you do not require LocationAware, consider using
LineIteratorImpl as an alternative to this class.
Note an important distinction in the way this class and its inner iterator differ: in the inner iterator, the position stored with
a line is the position at the start of that line. However, getPosition() of the outer class must return the position at the
end of the most-recently-returned line (or the start of the underlying AsciiLineReader, if no line has been read). The latter
bit of logic here is required to conform with the interface described by LocationAware.getPosition().| Constructor and Description |
|---|
AsciiLineReaderIterator(AsciiLineReader asciiLineReader) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getPosition()
Returns the byte position at the end of the most-recently-read line (a.k.a., the beginning of the next line) from
next() in
the underlying AsciiLineReader. |
boolean |
hasNext() |
java.lang.String |
next() |
java.lang.String |
peek()
Peeks at the next line, without expending any elements in the underlying iterator.
|
void |
remove() |
public AsciiLineReaderIterator(AsciiLineReader asciiLineReader)
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic boolean hasNext()
hasNext in interface java.util.Iterator<java.lang.String>public java.lang.String next()
next in interface java.util.Iterator<java.lang.String>public void remove()
remove in interface java.util.Iterator<java.lang.String>public long getPosition()
next() in
the underlying AsciiLineReader.getPosition in interface LocationAwarepublic java.lang.String peek()
LineIteratorpeek in interface LineIterator