public class TSVFile extends java.lang.Object implements TSVFileConstants
TSV (Tab Separated Values) file format parser. A TSV file is a spreadsheet, where the rows are separated by new line characters (i.e. each line of the file is a row), and the columns are separated by tab characters. Thus an example of a TSV file would be:
Name Phone Num Birthday John 555-5123 Apr. 30, 1937 Jane 555-4352 Feb. 13, 1976 Sam 555-6333 Jan. 7, 1961 Tom 555-7777 Aug. 4, 1943
Where name, phone number, and birthday are all separated by tab characters and are each columns of a spreadsheet.
NOTE: fields may be double or single quoted. In such cases, the single or double quotes character may be escaped by doubling it (e.g. "AB""C" will be read as AB"C).
Modifier and Type | Field and Description |
---|---|
static java.lang.String[][] |
DBL_EST
An empty 2D string array for calling the List.toArray method.
|
static java.lang.String[] |
EST
An empty 1D string array for calling the List.toArray method.
|
Token |
jj_nt
Next token.
|
Token |
token
Current token.
|
TSVFileTokenManager |
token_source
Generated Token Manager.
|
static javax.swing.filechooser.FileFilter |
TSV_FILTER
TSV file format filter (for file chooser objects).
|
Constructor and Description |
---|
TSVFile(java.io.InputStream stream)
Constructor with InputStream.
|
TSVFile(java.io.InputStream stream,
java.lang.String encoding)
Constructor with InputStream and supplied encoding
|
TSVFile(java.io.Reader stream)
Constructor.
|
TSVFile(TSVFileTokenManager tm)
Constructor with generated Token Manager.
|
Modifier and Type | Method and Description |
---|---|
void |
disable_tracing()
Disable tracing.
|
void |
enable_tracing()
Enable tracing.
|
ParseException |
generateParseException()
Generate ParseException.
|
Token |
getNextToken()
Get the next Token.
|
Token |
getToken(int index)
Get the specific Token.
|
boolean |
isFormat(java.io.Reader test)
Used to auto-detect BioLegato table canvas formats.
|
java.lang.String |
parseColumn()
Parses a column of the TSV data.
|
java.lang.String[][] |
parseDoubleArray()
Parse TSV data into a table canvas.
|
java.lang.String[] |
parseRow()
Parses a row of the TSV data.
|
void |
parseTSV(TableCanvas table)
Parse TSV data into a table canvas.
|
static void |
readFile(TableCanvas table,
java.io.Reader currentFile,
boolean overwrite,
boolean forceall)
Reads TSV data from a Reader object into a table canvas.
|
static java.lang.String[][] |
readTSV(java.io.Reader currentFile)
Reads TSV data from a Reader object into a 2D string array.
|
void |
ReInit(java.io.InputStream stream)
Reinitialise.
|
void |
ReInit(java.io.InputStream stream,
java.lang.String encoding)
Reinitialise.
|
void |
ReInit(java.io.Reader stream)
Reinitialise.
|
void |
ReInit(TSVFileTokenManager tm)
Reinitialise.
|
static void |
writeFile(java.lang.Appendable writer,
java.lang.String[][] data)
Writes a 2D string array as TSV data into an Appendable object.
|
public static final java.lang.String[] EST
public static final java.lang.String[][] DBL_EST
public static final javax.swing.filechooser.FileFilter TSV_FILTER
public TSVFileTokenManager token_source
public Token token
public Token jj_nt
public TSVFile(java.io.InputStream stream)
public TSVFile(java.io.InputStream stream, java.lang.String encoding)
public TSVFile(java.io.Reader stream)
public TSVFile(TSVFileTokenManager tm)
public boolean isFormat(java.io.Reader test)
test
- the reader to attempt to detect the format of.public static void readFile(TableCanvas table, java.io.Reader currentFile, boolean overwrite, boolean forceall) throws java.io.IOException
table
- the table canvas to read the TSV file into.currentFile
- the Reader object to parsed the TSV data from.overwrite
- whether to overwrite the currently selected content
in the table canvas with the data parsed by this
function.java.io.IOException
- thrown if there is any exception while
reading from the Reader object.public static java.lang.String[][] readTSV(java.io.Reader currentFile) throws java.io.IOException
currentFile
- the Reader object to parsed the TSV data from.java.io.IOException
- thrown if there is any exception while
reading from the Reader object.public static void writeFile(java.lang.Appendable writer, java.lang.String[][] data) throws java.io.IOException
writer
- the Appendable object to write the TSV data to.data
- the 2D string array to parse into TSV data.java.io.IOException
- thrown if there is any exception while
writing to the Appendable object.public final void parseTSV(TableCanvas table) throws ParseException
table
- the table canvas to parse the data into.ParseException
TableCanvas.namedHeaders
public final java.lang.String[][] parseDoubleArray() throws ParseException
table
- the table canvas to parse the data into.ParseException
public final java.lang.String[] parseRow() throws ParseException
ParseException
public final java.lang.String parseColumn() throws ParseException
ParseException
public void ReInit(java.io.InputStream stream)
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
public void ReInit(java.io.Reader stream)
public void ReInit(TSVFileTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()
Copyright © 2008-2022 University of Manitoba.