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 voidcalculateWordCount(byte[] line) Calculates the number of delimiter-separated "words" in a line and sets the value ofwordCountabstract voidclose()Closes this stream and releases any system resources associated with it.abstract Stringprotected intprotected booleanisBlank(byte[] line) Determines whether a given line is a commentprotected booleanisComment(byte[] line) Determines whether a given line is a commentprotected booleanisDelimiter(byte b) Determines whether a given character is a delimiterprotected booleanprotected booleaniterator()protected abstract byte[]protected voidsetSkipBlankLines(boolean skipBlankLines) protected voidsetTreatGroupedDelimitersAsOne(boolean treatGroupedDelimitersAsOne) protected voidsetWordCount(int wordCount) Methods inherited from class htsjdk.samtools.util.AbstractIterator
hasNext, isIterating, next, peek, removeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface htsjdk.samtools.util.CloseableIterator
stream, toListMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein 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:
advancein 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
bis 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)
-