Class FileTable

java.lang.Object
  extended by FileIO
      extended by FileTable

public class FileTable
extends FileIO

This class reads tab-delimited data from files into a Table and can write data to files. The term Table (upper case 'T') denotes the FileTable data structure. The class also parses tab-delimited data with or without a header (1 to n-lines of header) from a file into a Table (tRows,tCols,tHdrRows,tPreface,tHeader,tFields,tData).

If there are multiple header lines, it uses the last header line as the tFields[] data. You can optionally check for duplicate files and ignore them otherwise it is a parsing error.

You can optionally search the input file for a blank line after which the actually header appears. You can also specify a keyword in the header line to denote where the Table starts. You can remove blank lines at the end of the file to shorten the table length. It can be used to create an empty table (not associated with a file).

 List of Methods
 FileTable() - Constructor, set some defaults. 
 FileTable(tableName) - Constructor, set some defaults. 
 FileTable(tableName, rows, cols) - Constructor, set some defaults.
 clearTable() - set to empty table. Generally called from Constructor
 cloneTable() - clone the current Table. Copy data by value.
 setNbrTableHdrLines() - number of lines of the Table header.
 setHasTableHeaderFlag() - set Has Table Header Flag.
 setDuplicateFieldsFlag() - set duplicate fields Flag.
 setHasEmptyLineBeforeTableFlag() - set look for empty line(s) BEFORE table
 setRmvTrailingBlankLinesFlag() - remove trailing blank lines in the Table
 setRmvTrailingEmptyColumnsFlag() - set remove empty trailing columns flag.
 setStartTableAtColStr() - start Table at string known to be in header.
 setColNameIndexMapKeys() - set column names keys for ftIdxMap index-map.
 setUseOnlyLastHeaderLineFlag() - set use only last header line flag
 readTableRowFromFile() - random access read row r tokens from indexed file.
 readLineRowFromFile() - random access read row r data from indexed file.
 checkForBadTable() - verify that it is a well formed table
 checkForBadTableHeader() - verify that is a well formed tField Table
 parseTableFromString() - convert tab-delim string to Table structure.
 readAndParseTableIndexMap() - read tab-delim file to Table Index-Map.
 readAndParseTableAll() - read & convert tab-delim file to Table & ftIdxMap.
 readAndParseTable() - read & convert tab-delim file to Table structure.
 readAndParseTableFields() - read tab-delim file to tFields Table structure.
 readAndParseTableFieldsAndIndexMap - read tab-delim file tFields & ftIdxMap
 readAndParseTableData() - read & convert tab-delim file to Table structure.
 computeFileLineTermSize() - compute a file's line terminator size.
 cvtTableToTabDelimStr() - convert table to tab delimited string
 rmvTrailingBlankLinesFromTable() - remove Table trailing blank lines.  
 deleteTableColumnByName() - delete a column from the Table.
 deleteTableColumnByColIdx() - delete a column from table by column index
 lookupFieldIdx() - lookup column index of field if exists.
 lookupRowFromColumnData() - lookup row index from column data if exists.
 lookupCol2DataFromCol1DataRow() - lookup col2 data from row w/col1 data match
 appendRowToTable() - append row of data to table.
 removeRowFromTable() - remove row of data from table.
 deleteRowsFromTable() - delete rows from the Table and resize the Table.
 deleteTrailingEmptyColumnsFromTable() - removes empty trailing columns
 mapHeaderColNames() - map tField & tHeaders old to new names in map list.
 setFieldsToTable() - set the Fields list to the Table and set tCols.
 setHeadersToTable() - set the Headers list to the Table and set tHdrRows.
 addEmptyColumnToExistingTable() - add empty column to existing Table.
 addColumnToTable() - add a new column to Table with  specified field name. 
 replaceColumnData() - replace data in a column in the Table.
 setColumnDataByValue() - set all data in a column in Table to a value.
 getColumnData() - lookup the column name and then return all column data.
 reorderRowsBySortIndex() - reorder the entire table rows by the sortIdx.
 reorderColumnsInTable() - reorder Table tFields & tData by column index
 joinTableToCurrentTable() - join another Table ftJoin to current Table.
 trimTableEnclWhitespace() - trim (clean) enclosing white space in Table.
 trimArrayEnclWhitespace() - trim (clean) enclosing white space in a 1D array.
 sortTableRowsByField() - sort table rows by field.
 limitMaxRows() - keep max nbr rows in front of the Table.
 limitMaxRowsSortedByField() - sort Table by field, then keep max nbr rows
 

This code is available at the HTMLtools project on SourceForge at http://htmltools.sourceforge.org/ under the "Common Public License Version 1.0" http://www.opensource.org/licenses/cpl1.0.php.

It was derived and refactored from the open source MAExplorer (http://maexplorer.sourceforge.org/), and Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules.

$Date: 2009/11/23 11:45:56 $ $Revision: 1.37 $
Copyright 2008, 2009 by Peter Lemkin E-Mail: lemkin@users.sourceforge.net http://lemkingroup.com/


Field Summary
 int bufSize
          size of input buffer
 java.lang.String[] colNameIndexMap
          List of column names to be used in the left side of the ftIdxMap Table if it is built.
 java.lang.String fileName
          file to read or write I/O
 int firstDataRowCharIdx
          Char index of input buffer first row with table data (Table Fields or Data if no Fields).
 int firstDataRowLineNbr
          Line number of the first row with table data (Table Fields or Data if no Fields)
 FileTable ftIdxMap
          FileTable index map where save the {colNames, "StartByte", "EndByte") The colNames is a list with arbitrary names that can not be either "StartByte" or "EndByte".
 boolean hasEmptyLineBeforeTableFlag
          Set to true to look for empty line(s) BEFORE the table data
 boolean hasTableHeaderRowFlag
          Set to true (default) if has table header).
 boolean ignoreDuplicateFieldsFlag
          Set to true if has table may have duplicate fields.
 long[] lineEndDataBytePtr
          Index-map byte pointers of the start of data lines synced with tData rows.
 long[] lineEndHeaderBytePtr
          Index-map byte pointers of the start of header lines synced with tHeader rows.
 long[] lineStartDataBytePtr
          Index-map byte pointers of the start of data lines synced with tData rows.
 long[] lineStartHeaderBytePtr
          Index-map byte pointers of the start of header lines synced with tHeader rows.
 int nbrTableHdrLines
          Number of lines of the Table header "-hdr:{nbr of lines in header}" switches.
 boolean needToSortTableAgainFlag
          [HACK] If the table is sorted by sortTableRowsByField for numeric values with the useAbsValueFlag set true, and both + and - changes were found, it will set the needToSortTableAgainFlag so the calling program can resort one more time if it wants to keep the data in numeric order.
 int nUnmodifiedFieldNames
          Size of unmodifiedFieldNames[], the list of unmodified tField[] names.
 boolean rmvTrailingBlankLinesFlag
          Set to true if remove trailing blank lines from the table
 boolean rmvTrailingEmptyColumnsFlag
          Set to true to remove empty trailing columns defined as columns in a Table with a header as null column names.
 java.lang.String startTblColStr
          Set to string known to be in header.
 int tCols
          number of columns/row in the table.
 java.lang.String[][] tData
          row data cell vectors [0:tRows-1][0:tCols-1]
 java.lang.String[][] tDataFull
          This is the (sorted) full table data BEFORE the length of the table was limited using limitMaxRowsXXX() methods.
 java.lang.String[] tFields
          names of table fields.
 int tHdrRows
          number of header rows (default is 1)
 java.lang.String[][] tHeader
          names of table headers of size [0:tHdrRows-1][0:tCols-1].
 java.lang.String tName
          Table name if any
 java.lang.String tPreface
          Table preface if any.
 int tRows
          number of rows.
 java.lang.String[] unmodifiedFieldNames
          List of unmodified tField names, if not null with size nUnmodifiedFieldNames.
 boolean useOnlyLastHeaderLineFlag
          Reduce the number of header lines to 1 even if there are more than 1 header line.
 UtilCM util
          Global utilities UtilCM instance
 
Fields inherited from class FileIO
errMsgLog, lastErrMsgLog, raf, rafBuffer, rafFileName, rafLastSeekPtr, zipFile
 
Constructor Summary
FileTable()
          FileTable() - generic Constructor, set some defaults to 0.
FileTable(java.lang.String tableName)
          FileTable() - generic Constructor, set some defaults.
FileTable(java.lang.String tableName, int rows, int cols)
          FileTable() - Constructor to make empty table of known size
 
Method Summary
 boolean addColumnToTable(java.lang.String newFieldName, java.lang.String[] colData)
          addColumnToTable() - add a new column to the Table with the specified field name.
 boolean addColumnToTable(java.lang.String newFieldName, java.lang.String[] newHdrCols, java.lang.String[] colData)
          addColumnToTable() - add a new column to the Table with the specified field name.
 boolean addColumnToTable(java.lang.String newFieldName, java.lang.String[] newHdrCols, java.lang.String[] colData, boolean hasColDataFlag)
          addColumnToTable() - add a new column to the Table with the specified field name.
 boolean addEmptyColumnToExistingTable(java.lang.String newFieldName)
          addEmptyColumnToExistingTable() - add empty column to existing Table.
 boolean appendRowToTable(java.lang.String[] rowData)
          appendRowToTable() - append row of data to and grow the Table.
 boolean checkForBadTable()
          checkForBadTable() - verify that it is a well formed Table with all field names present and with no null, "" or duplicate entries, and tRows EQ tData.length.
 boolean checkForBadTableHeader()
          checkForBadTableHeader() - verify that is a well formed tField Table with all field names present and with no null, "" or duplicate entries.
 void clearTable()
          clearTable() - set to empty table.
 FileTable cloneTable(java.lang.String cloneTableName)
          cloneTable() - clone the current Table.
 int computeFileLineTermSize(java.io.RandomAccessFile rafL, long setSeekPtr)
          computeFileLineTermSize() - compute a file's line terminator size.
 java.lang.String cvtTableToTabDelimStr(boolean addHdrFlag)
          cvtTableToTabDelimStr() - convert Table to tab delimited string.
 boolean deleteRowsFromTable(int[] rowsToDelete)
          deleteRowsFromTable() - delete rows from the table and resize the table.
 boolean deleteTableColumnByColIdx(int cIdx)
          deleteTableColumnByColIdx() - delete a column from table by column index where (column 1 has index 0).
 boolean deleteTableColumnByName(java.lang.String columnName)
          deleteTableColumnByName() - delete a column from the table.
 boolean deleteTrailingEmptyColumnsFromTable()
          deleteTrailingEmptyColumnsFromTable() - removes empty trailing columns from defined as columns in a Table with a header as null column names.
 java.lang.String[] getColumnData(java.lang.String colName)
          getColumnData() - lookup the column name and then return all data in the column from tData[][c] if the column exists.
 boolean joinTables(FileTable ftJoin)
          joinTableToCurrentTable() - join another Table ftJoin to current Table.
 boolean limitMaxRows(int maxRowsToKeep, boolean useAbsValueFlag)
          limitMaxRows() - keep max nbr rows in front of the Table.
 boolean limitMaxRowsSortedByField(java.lang.String sortField, boolean sortTblAscendingFlag, int maxRowsToKeep, boolean doSortFirstFlag, boolean useAbsValueFlag)
          limitMaxRowsSortedByField() - sort Table by field, then keep max nbr rows.
 int lookupFieldIdx(java.lang.String fieldName)
          lookupFieldIdx() - lookup column index of field if exists.
 java.lang.String lookupRowDataFromColumnData(java.lang.String col1Name, java.lang.String col1Value, java.lang.String col2Name)
          lookupCol2DataFromCol1DataRow() - lookup col2 data from row with col1 data match.
 int lookupRowFromColumnData(java.lang.String colName, java.lang.String colValue)
          lookupRowFromColumnData() - lookup row index from column data if exists.
 boolean mapHeaderColNames(java.lang.String[] oldHdrMapNames, java.lang.String[] newHdrMapNames, int nHdrMapNames)
          mapHeaderColNames() - map tField & tHeaders old to new names in map list.
 boolean parseTableFromString(java.lang.String tblStr)
          parseTableFromString() - convert tab-delim string to Table structure.
 boolean readAndParseTable(java.lang.String inputFile)
          readAndParseTable() - read & convert tab-delim file to Table structure.
 boolean readAndParseTableAll(java.lang.String inputFile)
          readAndParseTableAll() - read & convert tab-delim file to Table structure.
 boolean readAndParseTableData(java.lang.String inputFile, boolean onlyReadHeaderFlag, boolean saveTblRowDataFlag, boolean makeIndexMapFlag)
          readAndParseTableData() - read & convert tab-delim file to Table structure.
 boolean readAndParseTableFields(java.lang.String inputFile)
          readAndParseTableFields() - read tab-delim file to tFields Table structure.
 boolean readAndParseTableFieldsAndIndexMap(java.lang.String inputFile)
          readAndParseTableFieldsAndIndexMap - read tab-delim file to tFields and ftIdxMap Table.
 boolean readAndParseTableIndexMap(java.lang.String inputFile)
          readAndParseTableIndexMap() - read tab-delim file to Table Index-Map.
 java.lang.String readLineRowFromFile(java.lang.String fileName, int r, FileTable ftIdxMap)
          readLineRowFromFile() - random access read row r data from indexed file.
 java.lang.String[] readTableLineRowFromFile(java.lang.String fileName, int r, FileTable ftIdxMap, java.lang.String nullFillStr)
          readTableRowFromFile() - random access read row r token list from indexed file.
 boolean removeRowFromTable(int rowToDelete)
          removeRowFromTable() - remove row of data from table.
 boolean reorderColumnsInTable(java.lang.String[] reordColName, int[] reordColNbr, int nReorderColName, boolean reorderRemainingColsFlag)
          reorderColumnsInTable() - reorder Table tFields and tData by column index of the Table based on the list of column header names reordColName[0:nReorderColName-1] to be reordered by a corresponding list of new column numbers in reordColNbr[].
 boolean reorderRowsBySortIndex(int[] sortIdx)
          reorderRowsBySortIndex() - reorder the entire table rows by the sortIdx.
 boolean replaceColumnData(int colIdx, java.lang.String[] colData, boolean replaceByValueFlag)
          replaceColumnData() - replace data in a column in the Table.
 boolean replaceColumnData(java.lang.String fieldName, java.lang.String[] colData)
          replaceColumnData() - replace Table data in a column by reference.
 boolean replaceColumnDataByValue(java.lang.String fieldName, java.lang.String[] colData)
          replaceColumnData() - replace Table data in a column by value.
 boolean rmvTrailingBlankLinesFromTable()
          rmvTrailingBlankLinesFromTable() - remove Table trailing blank lines by shortening the table from the bottom of the table.
 void setColNameIndexMapKeys(java.lang.String[] colNameIndexMap)
          setColNameIndexMapKeys() - set column names keys for ftIdxMap index-map.
 boolean setColumnDataByValue(int colIdx, java.lang.String colValue)
          setColumnDataByValue() - set all data in a column in Table to a value.
 boolean setColumnDataByValue(java.lang.String fieldName, java.lang.String colValue)
          setColumnDataByValue() - set all data in a column in Table to a value.
 void setDuplicateFieldsFlag(boolean ignoreDuplicateFieldsFlag)
          setDuplicateFieldsFlag() - set duplicate fields Flag.
 boolean setFieldsToTable(java.lang.String[] fieldNames)
          setFieldsToTable() - set the Fields list to the Table and set tCols.
 void setHasEmptyLineBeforeTableFlag(boolean hasEmptyLineBeforeTableFlag)
          setHasEmptyLineBeforeTableFlag() - set look for empty line(s) BEFORE table data flag
 void setHasTableHeaderFlag(boolean hasTableHeaderRowFlag)
          setHasTableHeaderFlag() - set Has Table Header Flag.
 boolean setHeadersToTable(java.lang.String[][] hdrNames, int nHeaders, int nCols)
          setHeadersToTable() - set the Headers list to the Table and set tHdrRows.
 void setNbrTableHdrLines(int nbrTableHdrLines)
          setNbrTableHdrLines() - number of lines of the Table header.
 void setRmvTrailingBlankLinesFlag(boolean rmvTrailingBlankLinesFlag)
          setRmvTrailingBlankLinesFlag() - remove trailing blank lines in the table by shortening the end of the table.
 void setRmvTrailingEmptyColumnsFlag(boolean rmvTrailingEmptyColumnsFlag)
          setRmvTrailingEmptyColumnsFlag() - set remove empty trailing columns flag.
 void setStartTableAtColStr(java.lang.String startTblColStr)
          setStartTableAtColStr() - start Table at string known to be in header.
 void setUseOnlyLastHeaderLineFlag(boolean useOnlyLastHeaderLineFlag)
          setUseOnlyLastHeaderLineFlag() - set reduce number of header lines to 1 even if there are more than 1 header lines.
 boolean sortTableRowsByField(int idxSortField, java.lang.String sortField, boolean sortTblAscendingFlag, boolean useAbsValueFlag)
          sortTableRowsByField() - sort table rows by idxSortField field index.
 boolean sortTableRowsByField(java.lang.String sortField, boolean sortTblAscendingFlag, boolean useAbsValueFlag)
          sortTableRowsByField() - sort table rows by field.
 void trimTableEnclWhitespace(boolean cleanHeaderFlag, boolean cleanDataFlag)
          trimTableEnclWhitespace() - trim (clean) enclosing white space in Table.
 boolean writeTableToTabDelimFile(java.lang.String fileName, boolean addHdrFlag)
          writeTableToTabDelimFile() - convert Table to tab delimited file.
 
Methods inherited from class FileIO
closeRandomAccessFile, copyDirectoryTree, copyDirectoryTree, copyFile, cvtRelDirToHyphenStr, deleteFile, fileExists, getAllZipEntries, getAllZipEntryData, getAllZipEntryNames, getDirOfFile, getDirPathByDirBrowser, getFilesInDir, getLineSeparatorFromFile, getLineSeparatorFromString, getSubDirsInDir, getTopLevelBackLink, getZipEntryData, getZipEntryName, initFileIO, makeDirectory, makePathSubDirs, mapPathFileSeparators, promptFileName, readAllZipEntries, readBytesFromURL, readFileAsString, readFileAsString, readFileZipEntries, readRandomAccessData, readRandomAccessLine, readStringFromURL, testDir, testFile, writeStringToFile, writeZipFile, zipDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

util

public UtilCM util
Global utilities UtilCM instance


hasTableHeaderRowFlag

public boolean hasTableHeaderRowFlag
Set to true (default) if has table header).


ignoreDuplicateFieldsFlag

public boolean ignoreDuplicateFieldsFlag
Set to true if has table may have duplicate fields.


hasEmptyLineBeforeTableFlag

public boolean hasEmptyLineBeforeTableFlag
Set to true to look for empty line(s) BEFORE the table data


rmvTrailingBlankLinesFlag

public boolean rmvTrailingBlankLinesFlag
Set to true if remove trailing blank lines from the table


rmvTrailingEmptyColumnsFlag

public boolean rmvTrailingEmptyColumnsFlag
Set to true to remove empty trailing columns defined as columns in a Table with a header as null column names.


startTblColStr

public java.lang.String startTblColStr
Set to string known to be in header. When parsing the table input string, we look for this value to determine the line where the Table starts.


useOnlyLastHeaderLineFlag

public boolean useOnlyLastHeaderLineFlag
Reduce the number of header lines to 1 even if there are more than 1 header line.


bufSize

public int bufSize
size of input buffer


unmodifiedFieldNames

public java.lang.String[] unmodifiedFieldNames
List of unmodified tField names, if not null with size nUnmodifiedFieldNames. This is the maximum size of tFields[], i.e., tCols and may be setup by other methods in other classes (e.g., see Convert..


nUnmodifiedFieldNames

public int nUnmodifiedFieldNames
Size of unmodifiedFieldNames[], the list of unmodified tField[] names.


firstDataRowLineNbr

public int firstDataRowLineNbr
Line number of the first row with table data (Table Fields or Data if no Fields)


firstDataRowCharIdx

public int firstDataRowCharIdx
Char index of input buffer first row with table data (Table Fields or Data if no Fields).


nbrTableHdrLines

public int nbrTableHdrLines
Number of lines of the Table header "-hdr:{nbr of lines in header}" switches. The number of Table header lines with default of 1. If > 1 line, then the Table Fields searched for URL mapping are the last one in the header row. All header lines are bolded with TH rather than TD. The tokens for the last of these header lines is also saved in lastTblHdrRow[0:tCols] to be used by the Column to URL mapping...


fileName

public java.lang.String fileName
file to read or write I/O


tHdrRows

public int tHdrRows
number of header rows (default is 1)


tCols

public int tCols
number of columns/row in the table.


tRows

public int tRows
number of rows. i.e. number row Clone Id's


tName

public java.lang.String tName
Table name if any


tPreface

public java.lang.String tPreface
Table preface if any. This is parsed from the initial text prior to the actual table if it was separated by a blank line or the table defined by a tField keyword.


tHeader

public java.lang.String[][] tHeader
names of table headers of size [0:tHdrRows-1][0:tCols-1]. Some of the non-primary (i.e., tField[]) header rows may not have tCols of data (i.e., short rows). These are filled with "".


tFields

public java.lang.String[] tFields
names of table fields. These are the primary table column names.


tData

public java.lang.String[][] tData
row data cell vectors [0:tRows-1][0:tCols-1]


lineStartHeaderBytePtr

public long[] lineStartHeaderBytePtr
Index-map byte pointers of the start of header lines synced with tHeader rows.


lineEndHeaderBytePtr

public long[] lineEndHeaderBytePtr
Index-map byte pointers of the start of header lines synced with tHeader rows.


lineStartDataBytePtr

public long[] lineStartDataBytePtr
Index-map byte pointers of the start of data lines synced with tData rows.


lineEndDataBytePtr

public long[] lineEndDataBytePtr
Index-map byte pointers of the start of data lines synced with tData rows.


colNameIndexMap

public java.lang.String[] colNameIndexMap
List of column names to be used in the left side of the ftIdxMap Table if it is built. If it is null, do not build the index-map since these column names are the keys used to build the index-map Table.


ftIdxMap

public FileTable ftIdxMap
FileTable index map where save the {colNames, "StartByte", "EndByte") The colNames is a list with arbitrary names that can not be either "StartByte" or "EndByte".


needToSortTableAgainFlag

public boolean needToSortTableAgainFlag
[HACK] If the table is sorted by sortTableRowsByField for numeric values with the useAbsValueFlag set true, and both + and - changes were found, it will set the needToSortTableAgainFlag so the calling program can resort one more time if it wants to keep the data in numeric order.


tDataFull

public java.lang.String[][] tDataFull
This is the (sorted) full table data BEFORE the length of the table was limited using limitMaxRowsXXX() methods. It is null unless the Table was limited in number of rows. This is useful if we need to get at the full Table later.

Constructor Detail

FileTable

public FileTable()
FileTable() - generic Constructor, set some defaults to 0.


FileTable

public FileTable(java.lang.String tableName)
FileTable() - generic Constructor, set some defaults.

Parameters:
tableName - String name of table
See Also:
UtilCM, setDuplicateFieldsFlag(boolean), setNbrTableHdrLines(int), setRmvTrailingBlankLinesFlag(boolean), setHasEmptyLineBeforeTableFlag(boolean)

FileTable

public FileTable(java.lang.String tableName,
                 int rows,
                 int cols)
FileTable() - Constructor to make empty table of known size

Parameters:
tableName - String name of table
rows - max rows in table
cols - max columns in table
See Also:
UtilCM, setDuplicateFieldsFlag(boolean), setNbrTableHdrLines(int), setRmvTrailingBlankLinesFlag(boolean), setHasEmptyLineBeforeTableFlag(boolean)
Method Detail

clearTable

public void clearTable()
clearTable() - set to empty table. Generally called from Constructor


cloneTable

public FileTable cloneTable(java.lang.String cloneTableName)
cloneTable() - clone the current Table. Copy data by value.

Parameters:
cloneTableName - is new tName of the clone
return - FileTable instance of clone if successful, else null.

setNbrTableHdrLines

public void setNbrTableHdrLines(int nbrTableHdrLines)
setNbrTableHdrLines() - number of lines of the Table header. The number of Table header lines with default of 1. If > 1 line, then the Table Fields searched for URL mapping are the last one in the header row. The tokens for the last of these header lines is also saved in lastTblHdrRow[0:tCols] to be used by the Column to URL mapping. The last header row is also saved in tFields[0:tcols-1]. All headers are saved in tHeader[0:tHdrRows-1][0:tCols] where tCols is determined by the last header row. Must have at least 1 line.

Parameters:
nbrTableHdrLines - value

setHasTableHeaderFlag

public void setHasTableHeaderFlag(boolean hasTableHeaderRowFlag)
setHasTableHeaderFlag() - set Has Table Header Flag.

Parameters:
hasTableHeaderRowFlag - value

setDuplicateFieldsFlag

public void setDuplicateFieldsFlag(boolean ignoreDuplicateFieldsFlag)
setDuplicateFieldsFlag() - set duplicate fields Flag.

Parameters:
ignoreDuplicateFieldsFlag - value

setHasEmptyLineBeforeTableFlag

public void setHasEmptyLineBeforeTableFlag(boolean hasEmptyLineBeforeTableFlag)
setHasEmptyLineBeforeTableFlag() - set look for empty line(s) BEFORE table data flag

Parameters:
hasEmptyLineBeforeTableFlag - value

setRmvTrailingBlankLinesFlag

public void setRmvTrailingBlankLinesFlag(boolean rmvTrailingBlankLinesFlag)
setRmvTrailingBlankLinesFlag() - remove trailing blank lines in the table by shortening the end of the table.

Parameters:
rmvTrailingBlankLinesFlag - value

setRmvTrailingEmptyColumnsFlag

public void setRmvTrailingEmptyColumnsFlag(boolean rmvTrailingEmptyColumnsFlag)
setRmvTrailingEmptyColumnsFlag() - set remove empty trailing columns flag. Empty columns are defined as columns in a Table with a header as null column names. If the flag is set, after the table is created, we define tFields for the first empty cell. We then rebuild tFields, tHeader and tData to the new size and set tCols to the new size.

Parameters:
rmvTrailingEmptyColumnsFlag - value

setStartTableAtColStr

public void setStartTableAtColStr(java.lang.String startTblColStr)
setStartTableAtColStr() - start Table at string known to be in header.

Parameters:
startTblColStr - - value that is known to be in the header

setColNameIndexMapKeys

public void setColNameIndexMapKeys(java.lang.String[] colNameIndexMap)
setColNameIndexMapKeys() - set column names keys for ftIdxMap index-map. If it is null, do not build the index-map since these column names are the keys used to build the index-map Table.

Parameters:
colNameIndexMap - - list of column names keys for ftIdxMap index-map.

setUseOnlyLastHeaderLineFlag

public void setUseOnlyLastHeaderLineFlag(boolean useOnlyLastHeaderLineFlag)
setUseOnlyLastHeaderLineFlag() - set reduce number of header lines to 1 even if there are more than 1 header lines. If the tHeader list exists, it shrinks it to 1 row and copies the previous last tHeader to to the new list.

Parameters:
useOnlyLastHeaderLineFlag - - value to set the flag.

readTableLineRowFromFile

public java.lang.String[] readTableLineRowFromFile(java.lang.String fileName,
                                                   int r,
                                                   FileTable ftIdxMap,
                                                   java.lang.String nullFillStr)
readTableRowFromFile() - random access read row r token list from indexed file. This assumes that there is a ftIdxMap FileTable created by MakeIndexFile for the file or.

Parameters:
fileName - file name
r - is the row to retrieve
ftIdxMap - is the FileTable index previously created by MakeIndexFile for the file.
nullFillStr - is the string to replace all null strings if not null.
Returns:
string row of file if successful, else null if any errors.
See Also:
FileIO.readRandomAccessLine(java.lang.String, long)

readLineRowFromFile

public java.lang.String readLineRowFromFile(java.lang.String fileName,
                                            int r,
                                            FileTable ftIdxMap)
readLineRowFromFile() - random access read row r data from indexed file. This assumes that there is a ftIdxMap FileTable created by parseTableFromString(), readAndParseTableIndexMap(), readAndParseTable(). or MakeIndexFile for the file.

Parameters:
fileName - file name
r - is the row to retrieve
ftIdxMap - is the FileTable index previously created by MakeIndexFile for the file.
Returns:
string row of file if successful, else null if any errors.
See Also:
FileIO.readRandomAccessLine(java.lang.String, long)

checkForBadTable

public boolean checkForBadTable()
checkForBadTable() - verify that it is a well formed Table with all field names present and with no null, "" or duplicate entries, and tRows EQ tData.length.

Returns:
true if successful, also stuff error message into "errMsgLog" to be displayed later.

checkForBadTableHeader

public boolean checkForBadTableHeader()
checkForBadTableHeader() - verify that is a well formed tField Table with all field names present and with no null, "" or duplicate entries.

Returns:
true if successful, also stuff error message into "errMsgLog" to be displayed later.

parseTableFromString

public boolean parseTableFromString(java.lang.String tblStr)
parseTableFromString() - convert tab-delim string to Table structure. Set up the table data structures in this instance of FileTable: (tHeader,tPreface,tRows,tCols,tFields[],tData[][],tCols,tRows,tHdrNbr).

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

Parameters:
tblStr - is String to parse and convert to Table
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
rmvTrailingBlankLinesFromTable(), deleteTrailingEmptyColumnsFromTable(), checkForBadTable()

readAndParseTableIndexMap

public boolean readAndParseTableIndexMap(java.lang.String inputFile)
readAndParseTableIndexMap() - read tab-delim file to Table Index-Map. Set up the table data structures in this instance of FileTable:
(tHeader,tPreface,tRows,tCols,tFields[],tCols,tRows,tHdrNbr).
This does NOT save the tData rows.

It also sets the the Index-Map byte pointers lineStartHeaderBytePtr[], lineEndHeaderBytePtr[] for the tHeader and lineStartDataBytePtr[], and lineEndDataBytePtr[] for the tData.

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

Parameters:
inputFile - is file to read and convert to table
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
readAndParseTableData(java.lang.String, boolean, boolean, boolean)

readAndParseTableAll

public boolean readAndParseTableAll(java.lang.String inputFile)
readAndParseTableAll() - read & convert tab-delim file to Table structure. Set up the table data structures in this instance of FileTable:
(tHeader,tPreface,tRows,tCols,tFields[],tData[][],tCols,tRows,tHdrNbr).

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

It also sets the the Index-Map byte pointers lineStartHeaderBytePtr[], lineEndHeaderBytePtr[] for the tHeader and lineStartDataBytePtr[], and lineEndDataBytePtr[] for the tData. It creates the ftIdxMap index-Map Table as one of the elements of this Table.

Parameters:
inputFile - is file to read and convert to table
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
readAndParseTableData(java.lang.String, boolean, boolean, boolean)

readAndParseTable

public boolean readAndParseTable(java.lang.String inputFile)
readAndParseTable() - read & convert tab-delim file to Table structure. Set up the table data structures in this instance of FileTable:
(tHeader,tPreface,tRows,tCols,tFields[],tData[][],tCols,tRows,tHdrNbr).

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

It also sets the the Index-Map byte pointers lineStartHeaderBytePtr[], lineEndHeaderBytePtr[] for the tHeader and lineStartDataBytePtr[], and lineEndDataBytePtr[] for the tData. It does not create the ftIdxMap index-Map Table.

Parameters:
inputFile - is file to read and convert to table
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
readAndParseTableData(java.lang.String, boolean, boolean, boolean)

readAndParseTableFields

public boolean readAndParseTableFields(java.lang.String inputFile)
readAndParseTableFields() - read tab-delim file to tFields Table structure. Set up the table data structures in this instance of FileTable: (tHeader,tPreface,tRows,tCols,tFields[],tCols,tRows,tHdrNbr).
This does NOT save the tData rows.

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

It also sets the the Index-Map byte pointers lineStartHeaderBytePtr[], lineEndHeaderBytePtr[] for the tHeader. It does not read the tData rows, but instead closes the file and returns. So the index map is incomplete.

Parameters:
inputFile - is file to read and convert to table
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
readAndParseTableData(java.lang.String, boolean, boolean, boolean)

readAndParseTableFieldsAndIndexMap

public boolean readAndParseTableFieldsAndIndexMap(java.lang.String inputFile)
readAndParseTableFieldsAndIndexMap - read tab-delim file to tFields and ftIdxMap Table. Set up the table data structures in this instance of FileTable: (tHeader,tPreface,tRows,tCols,tFields[],tCols,tRows,tHdrNbr).
This does NOT save the tData rows.

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

It also sets the the Index-Map byte pointers lineStartHeaderBytePtr[], lineEndHeaderBytePtr[] for the tHeader. It creates the ftIdxMap index-Map Table as one of the elements of this Table. It does not read the tData rows, but instead closes the file and returns.

Parameters:
inputFile - is file to read and convert to table
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
readAndParseTableData(java.lang.String, boolean, boolean, boolean)

readAndParseTableData

public boolean readAndParseTableData(java.lang.String inputFile,
                                     boolean onlyReadHeaderFlag,
                                     boolean saveTblRowDataFlag,
                                     boolean makeIndexMapFlag)
readAndParseTableData() - read & convert tab-delim file to Table structure. Set up the table data structures in this instance of FileTable: (tHeader,tPreface,tRows,tCols,tFields[],tData[][],tCols,tRows,tHdrNbr).

If the table is not at the front of the file, one option is to find the start of the table by searching for a this.startTblColStr string if you know a unique string in the header row. This is used if startTblColStr is not blank (set by setStartTableAtColStr()). If it matches, we then search backwards to the front of the string for a '\n' which is the end of the previous row.

An alternate method for finding the start of the file, if the this.hasEmptyLineBeforeTableFlag is set, is to look for the first non-empty empty row after seeing an empty row that it is then assumed to be the Table data (Fields + data or data) follows. This can be problematic if there are multiple blank lines.

When the front of the table is found, then it sets this.firstDataRowLineNbr to that line number. If there is no empty row found, then it assumes there is no extra data before the table and it sets this.firstDataRowLineNbr to 0. If there is text before the Table, then it is put into this.tPreface.

It also sets the the Index-Map byte pointers lineStartHeaderBytePtr[], lineEndHeaderBytePtr[] for the tHeader and lineStartDataBytePtr[], and lineEndDataBytePtr[] for the tData if making an Index-Map ftIdxMap. If makeIndexMapFlag is set it creates the ftIdxMap index-Map Table as one of the elements of this Table.

Parameters:
inputFile - is file to read and convert to table
onlyReadHeaderFlag - only read the tPreface, tFields and tHeader and then stop reading the file unless making an index map.
saveTblRowDataFlag - to save the tData rows, else just compute the Index-Map for the data rows.
makeIndexMapFlag - make an index map of Table in this.ftIdxMap
Returns:
true if successful, else errMsgLog has reason failed.
See Also:
rmvTrailingBlankLinesFromTable(), deleteTrailingEmptyColumnsFromTable(), checkForBadTable()

computeFileLineTermSize

public int computeFileLineTermSize(java.io.RandomAccessFile rafL,
                                   long setSeekPtr)
computeFileLineTermSize() - compute a file's line terminator size. Note that the lineTermSize of the file may be different from that of the operating system (for various reasons such as being edited by an editor that changes "\n" or "\r", to "\r\n"). Therefore, we need to compute it for the current file. The method assumes that the line terminators are the same for all lines.

Parameters:
rafL - is the opened RandomAccessFile
setSeekPtr - leave the file at this seek pointer if != -1.
Returns:
lineTermSize (should be either 1 or 2), -1 if error

cvtTableToTabDelimStr

public java.lang.String cvtTableToTabDelimStr(boolean addHdrFlag)
cvtTableToTabDelimStr() - convert Table to tab delimited string. This converts out multi-line tHeader data if they exist and then the tData.

Parameters:
addHdrFlag - - add the header (i.e., tFields) to front
Returns:
converted string, else null

writeTableToTabDelimFile

public boolean writeTableToTabDelimFile(java.lang.String fileName,
                                        boolean addHdrFlag)
writeTableToTabDelimFile() - convert Table to tab delimited file. This writes out multi-line tHeader data if they exist and then the tData.

Parameters:
fileName - - to write the Table
addHdrFlag - - add the header (i.e., tFields) to front
Returns:
true if succeed, else put error message in errMsgLog.

rmvTrailingBlankLinesFromTable

public boolean rmvTrailingBlankLinesFromTable()
rmvTrailingBlankLinesFromTable() - remove Table trailing blank lines by shortening the table from the bottom of the table. Shorten the tData[rows] and tRows.

Returns:
true if shortened the table.

deleteTableColumnByName

public boolean deleteTableColumnByName(java.lang.String columnName)
deleteTableColumnByName() - delete a column from the table. Remove the column from the tFields[] and sData[][] and decrement tCols if succeed. It will also delete the tData column if tData exists (i.e., is not null).

Parameters:
columnName - of column to be deleted if found.
Returns:
true if succeed, else if fail the errMsgLog string is set with the reason it failed.
See Also:
deleteTableColumnByColIdx(int)

deleteTableColumnByColIdx

public boolean deleteTableColumnByColIdx(int cIdx)
deleteTableColumnByColIdx() - delete a column from table by column index where (column 1 has index 0). Remove the column from the tFields[], tHeader[] and tData[][] and decrement tCols if succeed. It will also delete the tData column if tData exists (i.e., is not null).

Parameters:
cIdx - is index of column to be deleted.
Returns:
true if succeed, else if fail the errMsgLog string is set with the reason it failed.

lookupFieldIdx

public int lookupFieldIdx(java.lang.String fieldName)
lookupFieldIdx() - lookup column index of field if exists.

Parameters:
fieldName - to lookup
Returns:
index if found, else if it does not exist return -1

lookupRowFromColumnData

public int lookupRowFromColumnData(java.lang.String colName,
                                   java.lang.String colValue)
lookupRowFromColumnData() - lookup row index from column data if exists.

Parameters:
colName - of column to lookup
colValue - in column to lookup in a matching row
Returns:
row index if found, else if it does not exist return -1

lookupRowDataFromColumnData

public java.lang.String lookupRowDataFromColumnData(java.lang.String col1Name,
                                                    java.lang.String col1Value,
                                                    java.lang.String col2Name)
lookupCol2DataFromCol1DataRow() - lookup col2 data from row with col1 data match.

Parameters:
col1Name - of column 1 to lookup matching row
col1Value - in column 1 to lookup matching row
col2Name - is column of data to return for matching row.
Returns:
col2 value of matching row if found, else if it does not exist then null

appendRowToTable

public boolean appendRowToTable(java.lang.String[] rowData)
appendRowToTable() - append row of data to and grow the Table. Note: this works with an empty table where tRows==0 and tData is null.

Parameters:
rowData - is row of data to append
Returns:
true if added row

removeRowFromTable

public boolean removeRowFromTable(int rowToDelete)
removeRowFromTable() - remove row of data from table. Note: this works with an empty table where tRows==0 and tData is null.

Parameters:
rowToDelete - (count from row 0)
Returns:
true if row was deleted

deleteRowsFromTable

public boolean deleteRowsFromTable(int[] rowsToDelete)
deleteRowsFromTable() - delete rows from the table and resize the table. This creates a new tData with all missing rows AND NULL rows removed.

Parameters:
rowsToDelete - if not null
Returns:
true if succeed

deleteTrailingEmptyColumnsFromTable

public boolean deleteTrailingEmptyColumnsFromTable()
deleteTrailingEmptyColumnsFromTable() - removes empty trailing columns from defined as columns in a Table with a header as null column names. If the flag is set, after the table is created, we tFields for the first empty cell. We then rebuild tFields, tHeader and tData to the new size and set tCols to the new size.

Returns:
true if removed any columns from the table. [TODO]

mapHeaderColNames

public boolean mapHeaderColNames(java.lang.String[] oldHdrMapNames,
                                 java.lang.String[] newHdrMapNames,
                                 int nHdrMapNames)
mapHeaderColNames() - map tField & tHeaders old to new names in map list.

Parameters:
oldHdrMapNames - is list of current (old) header column names.
newHdrMapNames - is list of new header column names.
nHdrMapNames - is number of header column names to map.
Returns:
true if successful, null if no names matched

setFieldsToTable

public boolean setFieldsToTable(java.lang.String[] fieldNames)
setFieldsToTable() - set the Fields list to the Table and set tCols.

Parameters:
fieldNames - is the list of field column names.
Returns:
true if added fieldNames to Table

setHeadersToTable

public boolean setHeadersToTable(java.lang.String[][] hdrNames,
                                 int nHeaders,
                                 int nCols)
setHeadersToTable() - set the Headers list to the Table and set tHdrRows.

Parameters:
hdrNames - is the lists of tHeaders column names.
nHeaders - is the number of columns in the header that should match the tFields if it exists.
nCols - this is the number of columns in the tHeader rows, and should be the same as in tFields[].
Returns:
true if added fieldNames to Table

addEmptyColumnToExistingTable

public boolean addEmptyColumnToExistingTable(java.lang.String newFieldName)
addEmptyColumnToExistingTable() - add empty column to existing Table. Create an empty column of data of size this.tRows with values "". Do NOT add Header extension as well set it to nulls if header exists in the Table.

Parameters:
newFieldName - the new field name. If the field name already exists, then do not add the field.
colData - is optional data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
Returns:
true if added column to table or column already existed, false if any problems
See Also:
replaceColumnData(java.lang.String, java.lang.String[])

addColumnToTable

public boolean addColumnToTable(java.lang.String newFieldName,
                                java.lang.String[] colData)
addColumnToTable() - add a new column to the Table with the specified field name. If there is column data specified, then add it to the table otherwise set null entries the entries to "". Do NOT add Header extension as well set it to nulls if header exists in the Table.

Parameters:
newFieldName - the new field name. If the field name already exists, then do not add the field.
colData - is optional data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
Returns:
true if added column to table or column already existed, false if any problems
See Also:
replaceColumnData(java.lang.String, java.lang.String[])

addColumnToTable

public boolean addColumnToTable(java.lang.String newFieldName,
                                java.lang.String[] newHdrCols,
                                java.lang.String[] colData)
addColumnToTable() - add a new column to the Table with the specified field name. If there is column data specified, then add it to the table otherwise set null entries the entries to "". Add Header as well if the current Table has a header, else ignore it. If there is no newHdrCols data, copy "" for those cells.

Parameters:
newFieldName - the new field name. If the field name already exists, then do not add the field.
newHdrCols[] - is the new header column data [0:tHdrRows] if not null. If it is null, then fill in the extended header entries with "".
colData - is optional data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
Returns:
true if added column to table or column already existed, false if any problems
See Also:
replaceColumnData(java.lang.String, java.lang.String[])

addColumnToTable

public boolean addColumnToTable(java.lang.String newFieldName,
                                java.lang.String[] newHdrCols,
                                java.lang.String[] colData,
                                boolean hasColDataFlag)
addColumnToTable() - add a new column to the Table with the specified field name. If there is column data specified, then add it to the table otherwise set null entries the entries to "". Add Header as well if the current Table has a header, else ignore it. If there is no newHdrCols data, copy "" for those cells.

Parameters:
newFieldName - the new field name. If the field name already exists, then do not add the field.
newHdrCols[] - is the new header column data [0:tHdrRows] if not null. If it is null, then fill in the extended header entries with "".
colData - is optional data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
hasColDataFlag - - has column data and fill the row data if any with "" data.
Returns:
true if added column to table or column already existed, false if any problems
See Also:
replaceColumnData(java.lang.String, java.lang.String[])

replaceColumnData

public boolean replaceColumnData(java.lang.String fieldName,
                                 java.lang.String[] colData)
replaceColumnData() - replace Table data in a column by reference. Set null entries to "".

Parameters:
fieldName - is the field name for the column.
colData - is column data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
Returns:
true if replaced data in column
See Also:
lookupFieldIdx(java.lang.String), replaceColumnData(java.lang.String, java.lang.String[])

replaceColumnDataByValue

public boolean replaceColumnDataByValue(java.lang.String fieldName,
                                        java.lang.String[] colData)
replaceColumnData() - replace Table data in a column by value. Set null entries to "".

Parameters:
fieldName - is the field name for the column.
colData - is column data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
Returns:
true if replaced data in column
See Also:
lookupFieldIdx(java.lang.String), replaceColumnData(java.lang.String, java.lang.String[])

replaceColumnData

public boolean replaceColumnData(int colIdx,
                                 java.lang.String[] colData,
                                 boolean replaceByValueFlag)
replaceColumnData() - replace data in a column in the Table. Set null entries to "".

Parameters:
colIdx - is the field index for the column.
colData - is column data for the new field. The size of the array must be [0:tRows-1]. If adding the data to an existing column, just replace the data.
replaceByValueFlag - - to replace by value else by reference.
Returns:
true if replaced data in column, false if problem

setColumnDataByValue

public boolean setColumnDataByValue(java.lang.String fieldName,
                                    java.lang.String colValue)
setColumnDataByValue() - set all data in a column in Table to a value. Set null entries to "".

Parameters:
fieldName - is the field name for the column.
colValue - is column data for the new field.
Returns:
true if replaced data in column
See Also:
lookupFieldIdx(java.lang.String), replaceColumnData(java.lang.String, java.lang.String[])

setColumnDataByValue

public boolean setColumnDataByValue(int colIdx,
                                    java.lang.String colValue)
setColumnDataByValue() - set all data in a column in Table to a value. Set null entries to "".

Parameters:
colIdx - is the field index for the column.
colValue - is column data for the new field.
Returns:
true if replaced data in column

getColumnData

public java.lang.String[] getColumnData(java.lang.String colName)
getColumnData() - lookup the column name and then return all data in the column from tData[][c] if the column exists. If there are null rows at the end of the table, do not return those data so the length of the table is the actual number of items. This assumes that all null rows are at the end of the table.

Parameters:
columnName - the field name.
Returns:
the array of column data, else null

reorderRowsBySortIndex

public boolean reorderRowsBySortIndex(int[] sortIdx)
reorderRowsBySortIndex() - reorder the entire table rows by the sortIdx. I.e. if sortIdx[0]=4, sortIdx[1]= 7, etc., then tRow[0] gets move to tRow[4], tRow[1] gets moved to tRow[7] etc.

Parameters:
sortIdx - is array of new row 'toRow' indexes
return - true if successful.

reorderColumnsInTable

public boolean reorderColumnsInTable(java.lang.String[] reordColName,
                                     int[] reordColNbr,
                                     int nReorderColName,
                                     boolean reorderRemainingColsFlag)
reorderColumnsInTable() - reorder Table tFields and tData by column index of the Table based on the list of column header names reordColName[0:nReorderColName-1] to be reordered by a corresponding list of new column numbers in reordColNbr[].

Multiple new columns must be different. All reorderColName[] names must be in tFields or it is an error. Those columns not specified are moved toward the right. This is done after the list of dropped columns has been processed. It will also reorder the tData column if tData exists (i.e., is not null).

if reorderRemainingColumnsAlphabeticlyFlag is set, then sort the remaining columns not specified, but that are used, alphabetically.

Parameters:
reordColName - - list of column names to be reordered
reordColNbr - - corresponding list of new column numbers starting at 1 (used specified, but we map to n-1).
nReorderColName - - number of mappings
reorderRemainingColsFlag - to sort the remaining columns not specified, but that are used, alphabetically.
Returns:
true if succeed else if fail the errMsgLog string is set with the reason it failed.

joinTables

public boolean joinTables(FileTable ftJoin)
joinTableToCurrentTable() - join another Table ftJoin to current Table.

Parameters:
ftJoin - is the Table file to join to current Table
Returns:
true if succeed.

trimTableEnclWhitespace

public void trimTableEnclWhitespace(boolean cleanHeaderFlag,
                                    boolean cleanDataFlag)
trimTableEnclWhitespace() - trim (clean) enclosing white space in Table. Either the header or data areas can be cleaned. It goes cell by cell to try to remove white space. If a cell is cleaned, it replaces the cell string, otherwise the cell string is not replaced.

Parameters:
cleanHeaderFlag - to clean the tFields and tHeader
cleanDataFlag - to clean the tData

sortTableRowsByField

public boolean sortTableRowsByField(java.lang.String sortField,
                                    boolean sortTblAscendingFlag,
                                    boolean useAbsValueFlag)
sortTableRowsByField() - sort table rows by field. It can sort the data either numerically or by string depending on whether the first cell has a number in it. Get the column data and then do a bubble sort of that data. Use the sort index to then sort the rows of the Table. It looks up the field column index and then sorts by column.

Parameters:
sortField - is the field to sort by and to use in the thresholding
useNumericSortFlag - sort data numerically else by string
sortTblAscendingFlag - to sort the table in ascending order
useAbsValueFlag - to ignore the sign of the data in the search. If the table is sorted by numeric value, and both + and - changes were found, it will set the this.needToSortTableAgainFlag so the calling program can resort one more time if it wants. to keep the data in numeric order.
Returns:
true if succeed, false if fail with error message in errMsgLog. Also set this.needToSortTableAgainFlag if need to report later.

sortTableRowsByField

public boolean sortTableRowsByField(int idxSortField,
                                    java.lang.String sortField,
                                    boolean sortTblAscendingFlag,
                                    boolean useAbsValueFlag)
sortTableRowsByField() - sort table rows by idxSortField field index. It can sort the data either numerically or by string depending on whether the first cell has a number in it. Get the column data and then do a bubble sort of that data. Use the sort index to then sort the rows of the Table.

Parameters:
idxSortField - is the field index to sort by.
sortField - is the name of sort field to sort by for msgs
useNumericSortFlag - sort data numerically else by string
sortTblAscendingFlag - to sort the table in ascending order
useAbsValueFlag - to ignore the sign of the data in the search. If the table is sorted by numeric value, and both + and - changes were found, it will set the this.needToSortTableAgainFlag so the calling program can resort one more time if it wants. to keep the data in numeric order.
Returns:
true if succeed, false if fail with error message in errMsgLog. Also set this.needToSortTableAgainFlag if need to report later.

limitMaxRows

public boolean limitMaxRows(int maxRowsToKeep,
                            boolean useAbsValueFlag)
limitMaxRows() - keep max nbr rows in front of the Table.

Parameters:
maxRowsToKeep - is the maximum number of rows to keep.
useAbsValueFlag - to ignore the sign of the data in the search. If the table is sorted by numeric value, and both + and - changes were found, it will set the this.needToSortTableAgainFlag so the calling program can resort one more time if it wants.
Returns:
true if succeed or there is no change, false if fail with error message in errMsgLog

limitMaxRowsSortedByField

public boolean limitMaxRowsSortedByField(java.lang.String sortField,
                                         boolean sortTblAscendingFlag,
                                         int maxRowsToKeep,
                                         boolean doSortFirstFlag,
                                         boolean useAbsValueFlag)
limitMaxRowsSortedByField() - sort Table by field, then keep max nbr rows. Save the full table data in this.tDataFull BEFORE shortening the length of the this.tData. The this.tDataFull is null unless the Table was limited in number of rows. This is useful if we need to get at the full Table later.

Parameters:
sortField - is the field to sort by and to use in the thresholding
sortTblAscendingFlag -
maxRowsToKeep - is the maximum number of rows to keep.
useAbsValueFlag - to ignore the sign of the data in the search. If the table is sorted by numeric value, and both + and - changes were found, it will set the this.needToSortTableAgainFlag so the calling program can resort one more time if it wants.
Returns:
true if succeed or there is no change, false if fail with error message in errMsgLog