Package picard.util
Class BasicInputParser
- java.lang.Object
-
- htsjdk.samtools.util.AbstractIterator<String[]>
-
- picard.util.AbstractInputParser
-
- picard.util.BasicInputParser
-
- All Implemented Interfaces:
htsjdk.samtools.util.CloseableIterator<String[]>
,Closeable
,AutoCloseable
,Iterable<String[]>
,Iterator<String[]>
- Direct Known Subclasses:
CsvInputParser
,TabbedInputParser
public class BasicInputParser extends AbstractInputParser
TextFileParser which reads a single text file.
-
-
Constructor Summary
Constructors Constructor Description BasicInputParser(boolean treatGroupedDelimitersAsOne, int wordCount, File... files)
Constructor.BasicInputParser(boolean treatGroupedDelimitersAsOne, int wordCount, InputStream... inputStreams)
BasicInputParser(boolean treatGroupedDelimitersAsOne, File... files)
Constructor.BasicInputParser(boolean treatGroupedDelimitersAsOne, InputStream... inputStreams)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
advanceFile()
void
close()
Closes the underlying streamString
getCurrentLine()
Provides access to the current (just parsed) line in pre-parsed format.int
getCurrentLineNumber()
NOTE: Because AbstractInputParser pre-fetches the next line, this method actually returns the next line, not the most recent line returned by next().String
getFileName()
Gets the name of the file being parsedprotected byte[]
readNextLine()
Workhorse method that reads the next line from the underlying reader-
Methods inherited from class picard.util.AbstractInputParser
advance, calculateWordCount, getWordCount, isBlank, isComment, isDelimiter, isSkipBlankLines, isTreatGroupedDelimitersAsOne, iterator, setSkipBlankLines, setTreatGroupedDelimitersAsOne, setWordCount
-
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 java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
-
-
-
Constructor Detail
-
BasicInputParser
public BasicInputParser(boolean treatGroupedDelimitersAsOne, InputStream... inputStreams)
Constructor. Opens up a buffered reader and reads the first line.- Parameters:
inputStreams
- the file(s) to parse, in order
-
BasicInputParser
public BasicInputParser(boolean treatGroupedDelimitersAsOne, int wordCount, InputStream... inputStreams)
-
BasicInputParser
public BasicInputParser(boolean treatGroupedDelimitersAsOne, File... files)
Constructor. Opens up a buffered reader and reads the first line.- Parameters:
files
- the file(s) to parse, in order
-
BasicInputParser
public BasicInputParser(boolean treatGroupedDelimitersAsOne, int wordCount, File... files)
Constructor. In addition to opening and priming the files, it sets the number of whitespace-separated "words" per line.- Parameters:
files
- the file(s) to parsewordCount
- number of whitespace-separated "words" per line
-
-
Method Detail
-
readNextLine
protected byte[] readNextLine()
Workhorse method that reads the next line from the underlying reader- Specified by:
readNextLine
in classAbstractInputParser
- Returns:
- String or null if there is no next line
-
advanceFile
protected void advanceFile()
-
close
public void close()
Closes the underlying stream- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacehtsjdk.samtools.util.CloseableIterator<String[]>
- Specified by:
close
in classAbstractInputParser
-
getFileName
public String getFileName()
Gets the name of the file being parsed- Specified by:
getFileName
in classAbstractInputParser
- Returns:
- the name of the file being parsed
-
getCurrentLine
public String getCurrentLine()
Provides access to the current (just parsed) line in pre-parsed format. NOTE: Because AbstractInputParser pre-fetches the next line, this method actually returns the next line, not the most recent line returned by next().
-
getCurrentLineNumber
public int getCurrentLineNumber()
NOTE: Because AbstractInputParser pre-fetches the next line, this method actually returns the next line, not the most recent line returned by next().
-
-