|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--FileTable
This class reads data from files and writes data to files. It also reads tab-delimited data from a file into a Table (tRows,tCols,tFields,tData). It can be used to create an empty table (not associated with a file).
This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file.
| Field Summary | |
int |
bufSize
size of input buffer |
private static boolean |
DBUG_FILE_TABLE
Local debugging switch |
java.lang.String |
errMsgLog
error message log it not null |
static int |
estFieldsRowNbr
estimated row number where Fields are listed |
static int |
estLinesInFile
number of lines found in file |
static int |
estMaxColsInFile
estimated max number Cols in file |
static int |
estMaxGridsInFile
estimated max number Grids found in file |
static int |
estMaxNbrField
estimated number of Fields |
static int |
estMaxRowsInFile
estimated max number Rows in file |
static int |
estRowWithData
estimated row where data starts |
static int |
estSamplesRowNbr
estimated row number where Samples are listed |
private java.io.File |
file
file descriptor for I/O |
java.lang.String |
fileName
file to read or write I/O |
int |
tCols
number of columns/row |
java.lang.String[][] |
tData
row vectors [0:tRows-1][0:tCols-1] |
java.lang.String[] |
tFields
names of table fields |
java.lang.String |
tName
Table name |
int |
tRows
number of rows. |
| Constructor Summary | |
FileTable(java.lang.String tableName)
FileTable() - generic Constructor, set some defaults to 0. |
|
FileTable(java.lang.String tableName,
int rows,
int cols)
FileTable() - Constructor to make empty table of known size |
|
| Method Summary | |
boolean |
checkForBadTable()
checkForBadTable() - verify that it is a well formed table with all field names present and with no duplicate entries. |
private boolean |
computeTableSize(java.lang.String rawData)
computeTableSize() - setup the (tRows,tCols) of table data. |
static int |
countLinesAndTabCountsInFile(Cvt2Mae cvt,
java.lang.String fileName,
boolean lookForSampleTabsFlag,
java.lang.String msg,
java.awt.Color color)
countLinesAndTabCountsInFile() - open file and count number of lines & tabs Set estLinesInFile to # lines found. Set estSamplesRowNbr to estimated row # where Samples are listed. Set estFieldsRowNbr to estimated row # where Fields are listed. |
static int |
countLinesInFile(java.lang.String fileName)
countLinesInFile() - open file and count # of lines in the file. |
static int |
countNonNullTabData(java.lang.String sLine)
countNonNullTabData() - count Non-Null data tabs in line Do not count tabs after reach field with no data. |
boolean |
cvtStrToTable(java.lang.String sData)
cvtStrToTable() - convert tab-delim String data to Table data structure. |
static boolean |
findMaxGridRowColInFile(Cvt2Mae cvt,
java.lang.String fileName,
java.lang.String msg,
java.awt.Color color,
int rowWithFields,
int rowNbrDataStarts)
findMaxGridRowColInFile() - open file and find Max Grid Row Col in file This assumes that ("grid, grid_row, and grid_col") are in the FieldMap. |
static int |
findRowWithKeywordsInFile(Cvt2Mae cvt,
java.lang.String fileName,
java.lang.String[] keyWords,
boolean needAllKeywordsFlag,
int maxLinesToCheck,
java.lang.String msg,
java.awt.Color color)
findRowWithKeywordsInFile() - open file and look for first line with keywords (case-independent) in it. |
void |
freeTable()
freeTable() - free Table tData[][] and tFields so can garbage collect it Also zero tRows, tCols |
int |
lookupFieldIdx(java.lang.String fieldName)
lookupFieldIdx() - lookup index of field if exists. |
static int |
lookupSubstringFieldIdx(java.lang.String[] tblFields,
java.lang.String fieldName)
lookupSubstringFieldIdx() - lookup index of case independent field substring if exists and startsWith tblField[]. |
java.lang.String |
promptFileName(java.lang.String promptDir,
java.lang.String msg)
promptFileName() - prompt for file name |
java.lang.String |
readFileAsString(java.io.File f)
readFileAsString() - Will read file from disk & returns as String |
java.lang.String |
readFileAsString(java.lang.String fileName)
readFileAsString() - read file from disk and return data as String |
boolean |
readFileAsTable(java.lang.String fileName)
readFileAsTable() - read file and tab-delim data as Table. |
java.lang.String[] |
readTableFieldsFromFile(java.lang.String fileName,
int r)
readTableFieldsFromFile() - open file and read row r tab-delim data. |
private boolean |
storeDataBufParser(java.lang.String rawData)
storeDataBufParser() - Put data into Table tData[r][c] and tFields[c], given a raw data String from the whole file. |
boolean |
writeData(java.lang.String fileName,
java.lang.String data)
writeData() - write string data to file |
boolean |
writeStringToFile(java.lang.String fileName,
java.lang.String data)
writeStringToFile() - write data to disk file |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static boolean DBUG_FILE_TABLE
public static int estLinesInFile
public static int estSamplesRowNbr
public static int estFieldsRowNbr
public static int estMaxNbrField
public static int estMaxGridsInFile
public static int estMaxRowsInFile
public static int estMaxColsInFile
public static int estRowWithData
public int bufSize
public int tCols
public int tRows
public java.lang.String errMsgLog
public java.lang.String fileName
public java.lang.String tName
public java.lang.String[] tFields
public java.lang.String[][] tData
private java.io.File file
| Constructor Detail |
public FileTable(java.lang.String tableName)
tableName - String name of table
public FileTable(java.lang.String tableName,
int rows,
int cols)
tableName - String name of tablerows - max rows in tablecols - max columns in table| Method Detail |
public java.lang.String promptFileName(java.lang.String promptDir,
java.lang.String msg)
promptDir - default dirmsg - message to display in file dialogpublic boolean checkForBadTable()
public java.lang.String[] readTableFieldsFromFile(java.lang.String fileName,
int r)
fileName - file namer - row to readpublic static int countLinesInFile(java.lang.String fileName)
fileName - of file to read
public static int countLinesAndTabCountsInFile(Cvt2Mae cvt,
java.lang.String fileName,
boolean lookForSampleTabsFlag,
java.lang.String msg,
java.awt.Color color)
Try to estimate row numbers for Samples row and for Field row If lookForSampleTabsFlag is FALSE, it assumes that the first row with initial max number tabs with non-null data is the Fields row, otherwise] it is the Samples row.
Note that the Samples row may contain fewer tabs than the Fields row - but it is assumed that both contain more tabs than any other row. When we have satisfied the initial counts, just stop analyzing the tab counts to make it run MUCH MUCH faster.
cvt - instance of Cvt2MaefileName - file to countlookForSampleTabsFlag - if true, look for sample tabsmsg - message for logMsgcolor - is the logMsg colorUtilCM.logMsg(java.lang.String, java.awt.Color),
countNonNullTabData(java.lang.String)
public static boolean findMaxGridRowColInFile(Cvt2Mae cvt,
java.lang.String fileName,
java.lang.String msg,
java.awt.Color color,
int rowWithFields,
int rowNbrDataStarts)
estMaxGridsInFile as estimated max # Grids found in file
estMaxRowsInFile as estimated max # Rows in file
estMaxColsInFile as estimated max # Cols in file
cvt - instance of Cvt2MaefileName - file to countmsg - message for logMsgcolor - logMsg colorrowNbrDataStarts - row that data startsFileTable,
readTableFieldsFromFile(java.lang.String, int),
ParseTable,
ParseTable.getDelimTokens(java.lang.String, boolean[], java.lang.String[], boolean, java.lang.String),
UtilCM.cvs2i(java.lang.String, int),
UtilCM.logMsg(java.lang.String, java.awt.Color),
countNonNullTabData(java.lang.String)public static int countNonNullTabData(java.lang.String sLine)
sLine - line to count lines on
public static int findRowWithKeywordsInFile(Cvt2Mae cvt,
java.lang.String fileName,
java.lang.String[] keyWords,
boolean needAllKeywordsFlag,
int maxLinesToCheck,
java.lang.String msg,
java.awt.Color color)
cvt - instance of Cvt2MaefileName - file to open and searchkeyWords - array of keywords to searchneedAllKeywordsFlag - boolean look at all keywords flagmaxLinesToCheck - only look at max number of linesmsg - Not used, Futurecolor - Not used, Futurepublic boolean cvtStrToTable(java.lang.String sData)
sData - data to convert to tablecomputeTableSize(java.lang.String),
storeDataBufParser(java.lang.String)public boolean readFileAsTable(java.lang.String fileName)
fileName - to open and read to get data to convertcomputeTableSize(java.lang.String),
readFileAsString(java.lang.String),
storeDataBufParser(java.lang.String)
public boolean writeData(java.lang.String fileName,
java.lang.String data)
fileName - file to write data to diskdata - write data to diskwriteStringToFile(java.lang.String, java.lang.String)public java.lang.String readFileAsString(java.lang.String fileName)
fileName - file name to read datapublic java.lang.String readFileAsString(java.io.File f)
f - File to read
public boolean writeStringToFile(java.lang.String fileName,
java.lang.String data)
fileName - is name of the file to writedata - to write to the fileprivate boolean storeDataBufParser(java.lang.String rawData)
rawData - is raw data string read from file to convert into Tableprivate boolean computeTableSize(java.lang.String rawData)
rawData - raw data representing string table to analyzepublic int lookupFieldIdx(java.lang.String fieldName)
fieldName -
public static int lookupSubstringFieldIdx(java.lang.String[] tblFields,
java.lang.String fieldName)
fieldName - field name to look uptblFields - array of fieldspublic void freeTable()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||