Package htsjdk.tribble.readers
Class AsciiLineReaderIterator
- java.lang.Object
-
- htsjdk.tribble.readers.AsciiLineReaderIterator
-
- All Implemented Interfaces:
LocationAware
,LineIterator
,Closeable
,AutoCloseable
,Iterator<String>
public class AsciiLineReaderIterator extends Object implements LocationAware, LineIterator, Closeable
A class that iterates over the lines and line positions in anAsciiLineReader
. This class is slower than otherLineIterator
s because it is driven byAsciiLineReader
, but offers the benefit of implementingLocationAware
, which is required for indexing. If you do not requireLocationAware
, consider usingLineIteratorImpl
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 underlyingAsciiLineReader
, if no line has been read). The latter bit of logic here is required to conform with the interface described byLocationAware.getPosition()
.
-
-
Constructor Summary
Constructors Constructor Description AsciiLineReaderIterator(AsciiLineReader asciiLineReader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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) fromnext()
in the underlyingAsciiLineReader
.boolean
hasNext()
String
next()
String
peek()
Peeks at the next line, without expending any elements in the underlying iterator.void
remove()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
AsciiLineReaderIterator
public AsciiLineReaderIterator(AsciiLineReader asciiLineReader)
-
-
Method Detail
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getPosition
public long getPosition()
Returns the byte position at the end of the most-recently-read line (a.k.a., the beginning of the next line) fromnext()
in the underlyingAsciiLineReader
.- Specified by:
getPosition
in interfaceLocationAware
-
peek
public String peek()
Description copied from interface:LineIterator
Peeks at the next line, without expending any elements in the underlying iterator.- Specified by:
peek
in interfaceLineIterator
-
-