Package picard.util
Class AbstractInputParser
java.lang.Object
htsjdk.samtools.util.AbstractIterator<String[]>
picard.util.AbstractInputParser
- All Implemented Interfaces:
htsjdk.samtools.util.CloseableIterator<String[]>
,Closeable
,AutoCloseable
,Iterable<String[]>
,Iterator<String[]>
- Direct Known Subclasses:
BasicInputParser
public abstract class AbstractInputParser
extends htsjdk.samtools.util.AbstractIterator<String[]>
implements Iterable<String[]>, htsjdk.samtools.util.CloseableIterator<String[]>
Class for parsing text files where each line consists of fields separated by whitespace.
Code is abstracted into this class so that we can optimize its performance over time.
This class assumes that every line will have the same number of whitespace-separated "words"
and that lines that start with "#" are comments and should be ignored.
Classes that extend this parser can do so simply by implementing their own constructors and the
readNextLine(), close(), and getFileName() methods.
-
Field Summary
Fields inherited from class htsjdk.samtools.util.AbstractIterator
next
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]
advance()
protected void
calculateWordCount
(byte[] line) Calculates the number of delimiter-separated "words" in a line and sets the value ofwordCount
abstract void
close()
Closes this stream and releases any system resources associated with it.abstract String
protected int
protected boolean
isBlank
(byte[] line) Determines whether a given line is a commentprotected boolean
isComment
(byte[] line) Determines whether a given line is a commentprotected boolean
isDelimiter
(byte b) Determines whether a given character is a delimiterprotected boolean
protected boolean
iterator()
protected abstract byte[]
protected void
setSkipBlankLines
(boolean skipBlankLines) protected void
setTreatGroupedDelimitersAsOne
(boolean treatGroupedDelimitersAsOne) protected void
setWordCount
(int wordCount) Methods inherited from class htsjdk.samtools.util.AbstractIterator
hasNext, isIterating, next, peek, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface htsjdk.samtools.util.CloseableIterator
stream, toList
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Constructor Details
-
AbstractInputParser
public AbstractInputParser()
-
-
Method Details
-
close
public abstract void close()Closes this stream and releases any system resources associated with it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacehtsjdk.samtools.util.CloseableIterator<String[]>
-
readNextLine
protected abstract byte[] readNextLine()- Returns:
- the next line of text from the underlying stream(s) or null if there is no next line
-
getFileName
- Returns:
- the name(s) of the file(s) being parsed, or null if no name is available
-
iterator
-
advance
- Specified by:
advance
in classhtsjdk.samtools.util.AbstractIterator<String[]>
-
calculateWordCount
protected void calculateWordCount(byte[] line) Calculates the number of delimiter-separated "words" in a line and sets the value ofwordCount
- Parameters:
line
- representative line from the file
-
isComment
protected boolean isComment(byte[] line) Determines whether a given line is a comment- Parameters:
line
- the line to evaluate- Returns:
- true if the line is a comment (and should be ignored) otherwise false
-
isBlank
protected boolean isBlank(byte[] line) Determines whether a given line is a comment- Parameters:
line
- the line to evaluate- Returns:
- true if the line is a comment (and should be ignored) otherwise false
-
isDelimiter
protected boolean isDelimiter(byte b) Determines whether a given character is a delimiter- Parameters:
b
- the character to evaluate- Returns:
- true if
b
is a delimiter; otherwise false
-
getWordCount
protected int getWordCount() -
setWordCount
protected void setWordCount(int wordCount) -
isTreatGroupedDelimitersAsOne
protected boolean isTreatGroupedDelimitersAsOne() -
setTreatGroupedDelimitersAsOne
protected void setTreatGroupedDelimitersAsOne(boolean treatGroupedDelimitersAsOne) -
isSkipBlankLines
protected boolean isSkipBlankLines() -
setSkipBlankLines
protected void setSkipBlankLines(boolean skipBlankLines)
-