|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object O2Plib.table.SimpleTable
public class SimpleTable
Class SimpleTable is the base class for tables.
The SimpleTable class creates an empty table of size tRows and tCols counting from 0. It is up to the caller to populate the table. Data is stored in tData[tRows][tCols] with tFields[tCols]. It contains several methods for accessing data in the table.
List of Table access methods SimpleTable() - constructor for creating empty table SimpleTable() - constructor for creating a table populated w/fields & data freeTable() - free Table tData[][] and tFields so can garbage collect it trimWhitespace() - trim Table tData[][] and tFields[] data setFieldData() - set new field[] list for table getRowData() - set new row data[] for specific row in the table setRowData() - set new row data[] for specific row in the table lookupFieldIdx() - lookup column index of field if exists lookupFieldPrefixIdx() - lookup column index of field if exists by prefix lookupRowByFieldNameValue() - lookup the row of data by field(name,value). lookupRowByFieldNameValuePairs() - lookup row of data-pair matches. getListOfRowsIdxByFieldNameValuePairs() - get list of rows of data-pair matches. getListOfRowsDataByFieldNameValuePairs() - get list of rows data of data-pair matches. getFieldRowDatum() - get field in row by Table row index getFieldIdxRowDatum() - get data by field idx with row index getRowDataByFieldNameValue() - get row of data by field(name,value). setFieldRowDatum() - set datum by field name with row index setFieldIdxRowDatum() - set datum by field idx with row index appendRowToTable() - append row of data to table. removeRowFromTable() - remove row of data from table. deleteRowsFromTable() - delete rows from the table and resize the table. addColumnToTable() - add new column to table with specified field name. cvtTblToDelimData() - convert the table to a delimited string table. cvtTblToHTML() - convert the table to a HTML string cvtTblToXML() - convert the table to a XML string.
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. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.
Table
Field Summary | |
---|---|
static boolean |
dbugFlag
Debugging flag |
java.lang.String |
fullFileName
Optional full file name associated with table |
java.lang.String |
name
Optional table name associated with table |
int |
tCols
# of columns/row in the table |
java.lang.String[][] |
tData
row vectors of data [0:tRows-1][0:tCols-1] |
java.lang.String[] |
tFields
names of table fields |
java.lang.String[] |
tHelp
names of table help data if any for defining the fields |
java.lang.String |
title
Optional title of table |
int |
tRows
# of rows/Table |
java.lang.String |
tType
Type of table |
Constructor Summary | |
---|---|
SimpleTable()
SimpleTable() - constructor for creating empty table. |
|
SimpleTable(java.lang.String title,
java.lang.String name,
int tRows,
int tCols)
SimpleTable() - constructor for creating empty table. |
|
SimpleTable(java.lang.String title,
java.lang.String name,
int tRows,
int tCols,
java.lang.String[] tFields,
java.lang.String[][] tData)
SimpleTable() - constructor for creating a table popupated with fields and data. |
|
SimpleTable(java.lang.String title,
java.lang.String name,
java.lang.String type)
|
|
SimpleTable(java.lang.String title,
java.lang.String name,
java.lang.String[] tFields,
int tRows,
int tCols)
SimpleTable() - constructor for creating empty table. |
Method Summary | |
---|---|
boolean |
addColumnsToTable(java.lang.String[] newFieldNames)
addColumnsToTable() - add new columns to the table with the specified field names list. |
boolean |
addColumnToTable(java.lang.String newFieldName,
java.lang.String[] colData)
addColumnToTable() - add a new column to the table with the specified field name. |
boolean |
appendRowToTable(java.lang.String[] accRowData)
appendRowToTable() - append row of data to table. |
java.lang.String |
cvtTblToDelimData(java.lang.String delim)
cvtTblToDelimData() - convert the table to a delimited string table where delim could be tab or comma or some other character or substring. |
java.lang.String |
cvtTblToHTML(java.lang.String beginTitle,
int fontSize,
java.lang.String[] dataPreface,
java.lang.String[] dataEpilogue,
java.lang.String endTitle)
cvtTblToHTML() - convert the table to a HTML string |
java.lang.String |
cvtTblToXML(java.lang.String topObj,
java.lang.String dateStr,
java.lang.String dbName,
java.lang.String entryObj)
cvtTblToXML() - convert the table to a XML string. |
java.lang.String |
cvtTblToXML(java.lang.String topObj,
java.lang.String dateStr,
java.lang.String dbName,
java.lang.String entryObj,
java.lang.String dtdFile)
cvtTblToXML() - convert the table to a XML string. |
boolean |
deleteRowsFromTable(int[] rowsToDelete)
deleteRowsFromTable() - delete rows from the table and resize the table. |
void |
freeTable()
freeTable() - free Table tData[][] and tFields so can garbage collect it. |
java.lang.String |
getFieldIdxRowDatum(int row,
int fieldIdx)
getFieldIdxRowDatum() - get datum by field idx with row index |
java.lang.String |
getFieldRowDatum(int row,
java.lang.String fieldName)
getFieldRowDatum() - get datum by field in row by Table row index |
java.lang.String[][] |
getListOfRowsDataByFieldNameValuePairs(java.lang.String fieldName1,
java.lang.String fieldValue1,
java.lang.String fieldName2,
java.lang.String fieldValue2)
getListOfRowsDataByFieldNameValuePairs() - lookup a list of rows data by (fieldName1,fieldValue1) and (fieldName2,fieldValue2) matches. |
int[] |
getListOfRowsIdxByFieldNameValuePairs(java.lang.String fieldName1,
java.lang.String fieldValue1,
java.lang.String fieldName2,
java.lang.String fieldValue2)
getListOfRowsIdxByFieldNameValuePairs() - lookup a list of rows of data by (fieldName1,fieldValue1) and (fieldName2,fieldValue2) matches. |
java.lang.String[] |
getRowData(int rowNbr)
getRowData() - get row of data[] for specific row in the table |
java.lang.String[] |
getRowDataByFieldNameValue(java.lang.String fieldName,
java.lang.String fieldValue)
getRowDataByFieldNameValue() - get row of data by (fieldName,fieldValue). |
int |
lookupFieldIdx(java.lang.String fieldName)
lookupFieldIdx() - lookup column index of field if exists. |
int |
lookupFieldPrefixIdx(java.lang.String fieldNamePrefix)
lookupFieldPrefixIdx() - lookup column index of fieldNamePrefix if exists in the table. |
int |
lookupRowByFieldNameValue(java.lang.String fieldName,
java.lang.String fieldValue)
lookupRowByFieldNameValue() - lookup the row of data by (fieldName,fieldValue). |
int |
lookupRowByFieldNameValuePairs(java.lang.String fieldName1,
java.lang.String fieldValue1,
java.lang.String fieldName2,
java.lang.String fieldValue2)
lookupRowByFieldNameValuePairs() - lookup the row of data by (fieldName1,fieldValue1) and (fieldName2,fieldValue2) matches. |
boolean |
removeRowFromTable(int rowToDelete)
removeRowFromTable() - remove row of data from table. |
boolean |
replaceColumnData(int colIdx,
java.lang.String colValue)
replaceColumnData() - replace all data in a column in the table with the same value. |
boolean |
replaceColumnData(int colIdx,
java.lang.String[] colData)
replaceColumnData() - replace data in a column in the table. |
boolean |
replaceColumnData(java.lang.String fieldName,
java.lang.String colValue)
replaceColumnData() - replace all data in a column in the table with the same value. |
boolean |
replaceColumnData(java.lang.String fieldName,
java.lang.String[] colData)
replaceColumnData() - replace data in a column in the table. |
boolean |
setFieldData(java.lang.String[] newFields,
int nNewFields)
setFieldData() - set new field[] list for table |
boolean |
setFieldIdxRowDatum(int row,
int fieldIdx,
java.lang.String datum)
setFieldIdxRowDatum() - set datum by field idx with row index |
boolean |
setFieldRowDatum(int row,
java.lang.String fieldName,
java.lang.String datum)
setFieldRowDatum() - set datum by field name with row index |
boolean |
setHelpData(java.lang.String[] newHelpData)
setHelpData() - set tHelp[] list for table |
boolean |
setRowData(java.lang.String[] newRowData,
int rowNbr)
setRowData() - set new row data[] for specific row in the table where newRowData[] must be the size of the table rows. |
void |
trimWhitespace()
trimWhitespace() - trim Table tData[][] and tFields[] data. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean dbugFlag
public int tCols
public int tRows
public java.lang.String[] tFields
public java.lang.String[][] tData
public java.lang.String title
public java.lang.String name
public java.lang.String fullFileName
public java.lang.String[] tHelp
public java.lang.String tType
Constructor Detail |
---|
public SimpleTable()
tRows
- is # of rows of tabletCols
- is # of columns of tablepublic SimpleTable(java.lang.String title, java.lang.String name, java.lang.String type)
public SimpleTable(java.lang.String title, java.lang.String name, int tRows, int tCols)
title
- opt. title of the tablename
- opt. name assoc. w/tabletRows
- # of rows in tabletCols
- # of Field columns in table.public SimpleTable(java.lang.String title, java.lang.String name, java.lang.String[] tFields, int tRows, int tCols)
title
- opt. title of the tabletFields
- is list of field names [0:tCols-1]tRows
- # of rows in tabletCols
- # of Field columns in table.public SimpleTable(java.lang.String title, java.lang.String name, int tRows, int tCols, java.lang.String[] tFields, java.lang.String[][] tData)
title
- opt. title of the tablename
- opt. name assoc. w/tabletRows
- # of rows in tabletCols
- # of Field columns in table.tFields
- field names of the tabletData
- rows of dataMethod Detail |
---|
public void freeTable()
public void trimWhitespace()
public boolean setFieldData(java.lang.String[] newFields, int nNewFields)
newFields
- is list of new fields
public boolean setHelpData(java.lang.String[] newHelpData)
newHelpData
- is list of new help data
public java.lang.String[] getRowData(int rowNbr)
rowNbr
- is the row to get
public boolean setRowData(java.lang.String[] newRowData, int rowNbr)
newRowData
- is list of new data for row rowNbrrowNbr
- is the row to change
public int lookupFieldIdx(java.lang.String fieldName)
fieldName
- to lookup
public int lookupFieldPrefixIdx(java.lang.String fieldNamePrefix)
fieldNamePrefix
- to lookup is unique start of the field
public int lookupRowByFieldNameValue(java.lang.String fieldName, java.lang.String fieldValue)
fieldName
- is the name of the field to checkfieldValue
- is value to look for in fieldName field
lookupFieldIdx(java.lang.String)
public int lookupRowByFieldNameValuePairs(java.lang.String fieldName1, java.lang.String fieldValue1, java.lang.String fieldName2, java.lang.String fieldValue2)
fieldName1
- is the name of the first field to checkfieldValue1
- is value to look for in first fieldName fieldfieldName2
- is the name of the 2nd field to checkfieldValue2
- is value to look for in 2nd fieldName field
lookupFieldIdx(java.lang.String)
public int[] getListOfRowsIdxByFieldNameValuePairs(java.lang.String fieldName1, java.lang.String fieldValue1, java.lang.String fieldName2, java.lang.String fieldValue2)
fieldName1
- is the name of the first field to checkfieldValue1
- is value to look for in first fieldName fieldfieldName2
- is the name of the 2nd field to checkfieldValue2
- is value to look for in 2nd fieldName field
lookupFieldIdx(java.lang.String)
public java.lang.String[][] getListOfRowsDataByFieldNameValuePairs(java.lang.String fieldName1, java.lang.String fieldValue1, java.lang.String fieldName2, java.lang.String fieldValue2)
fieldName1
- is the name of the first field to checkfieldValue1
- is value to look for in first fieldName fieldfieldName2
- is the name of the 2nd field to checkfieldValue2
- is value to look for in 2nd fieldName field
lookupFieldIdx(java.lang.String)
public java.lang.String getFieldRowDatum(int row, java.lang.String fieldName)
row
- is to usefieldName
- to lookup
lookupFieldIdx(java.lang.String)
public java.lang.String getFieldIdxRowDatum(int row, int fieldIdx)
row
- is row to usefieldIdx
- of field to to lookup
public boolean setFieldRowDatum(int row, java.lang.String fieldName, java.lang.String datum)
row
- is row to usefieldName
- of field to to lookupdatum
- to store. If the datum is null, save a ""
public boolean setFieldIdxRowDatum(int row, int fieldIdx, java.lang.String datum)
row
- is row to usefieldIdx
- of field to to lookupdatum
- to store. If the datum is null, save a ""
public java.lang.String[] getRowDataByFieldNameValue(java.lang.String fieldName, java.lang.String fieldValue)
fieldName
- is the name of the field to checkfieldValue
- is value to look for in fieldName field
lookupFieldIdx(java.lang.String)
public boolean appendRowToTable(java.lang.String[] accRowData)
accRowData
- is rlow of data to append
public boolean removeRowFromTable(int rowToDelete)
rowToDelete
- (count from row 0)
public boolean deleteRowsFromTable(int[] rowsToDelete)
rowsToDelete
- if not null
public boolean addColumnToTable(java.lang.String newFieldName, java.lang.String[] colData)
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.
public boolean addColumnsToTable(java.lang.String[] newFieldNames)
newFieldNames
- is a list of new field names to add.
public boolean replaceColumnData(java.lang.String fieldName, java.lang.String[] colData)
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.
public boolean replaceColumnData(int colIdx, java.lang.String[] colData)
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.
public boolean replaceColumnData(java.lang.String fieldName, java.lang.String colValue)
fieldName
- is the field name for the column.colValue
- is column data for the new field.
public boolean replaceColumnData(int colIdx, java.lang.String colValue)
colIdx
- is the field index for the column.colValue
- is column data for the new field.
public java.lang.String cvtTblToDelimData(java.lang.String delim)
delim
- is the delimiter string (or character)
public java.lang.String cvtTblToHTML(java.lang.String beginTitle, int fontSize, java.lang.String[] dataPreface, java.lang.String[] dataEpilogue, java.lang.String endTitle)
beginTitle
- to use for the tablefontSize
- is 0 (no change), +n to increase, -n to decreasedataPreface
- is either null, or is an array [0:tCols-1]
of preface strings added before the corresponding data value.dataEpilogue
- is either null, or is an array [0:tCols-1]
of preface strings added before the corresponding data value.endTitle
- to add at the end if it is not null.
public java.lang.String cvtTblToXML(java.lang.String topObj, java.lang.String dateStr, java.lang.String dbName, java.lang.String entryObj, java.lang.String dtdFile)
topObj
- is the name of the top level objectdateStr
- is the date created if not nulldbName
- is the name of the database if not nullentryObj
- is the name of a row entry objectdtdFile
- is the DTD file (if not null, insert the DTD if it exists)
to insert in the front of the generated XML file. Note
that the DTD file must include the "< ?xml ...? >" prefix.
public java.lang.String cvtTblToXML(java.lang.String topObj, java.lang.String dateStr, java.lang.String dbName, java.lang.String entryObj)
topObj
- is the name of the top level objectdateStr
- is the date created if not nulldbName
- is the name of the database if not nullentryObj
- is the name of a row entry object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |