|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectat.spardat.xma.datasource.TabularData
A TabularDatatable stores data in a row/column matrix of Atoms in memory, with column header names. It can be read from a File or an InputStream and written to an OutputStream or File in CSV format. The "UTF-8" encoding is used.
| Constructor Summary | |
TabularData()
Creates an empty table. |
|
TabularData(java.lang.String[] columnNames,
Atom[][] rows)
Creates a table containing given data |
|
| Method Summary | |
void |
addColumn(java.lang.String name)
Add a column. |
void |
addRow(TabularDataRow r)
Adds a row in the table. |
void |
clear()
Clears the table data. |
Atom |
getCell(int row,
int col)
Get the value from a cell specified bei row and col. |
Atom |
getCell(int row,
java.lang.String columnName)
Returns the value from a cell specified bei row and columnName. |
int |
getColumnIndex(java.lang.String colName)
Returns the index of the column with the name colName. |
java.lang.String |
getColumnName(int col)
Returns the header name of the n'th column in the table |
TabularDataRow |
getRow(int row)
Gets the table row with the index row. |
int |
hashCode()
Maps this TabularData to an integer hash code. |
int |
numCols()
Returns the number of columns in this table |
static TabularData |
readFrom(java.io.File file)
Creates a table by reading it in from a UTF-8 encoded CSV file. |
static TabularData |
readFrom(java.io.InputStream inputStream)
Creates a table by reading it from an InputStream in UTF-8-encoded CSV format. |
void |
save(java.io.File file)
Store the table in to a given file, in CSV format. |
int |
size()
Returns the number of rows in this table |
void |
write(java.io.OutputStream outputStream)
Writes a TabularData to an OutputStream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TabularData()
public TabularData(java.lang.String[] columnNames,
Atom[][] rows)
throws java.lang.IllegalArgumentException
columnNames - - The column header namesrows - - The data as a matrix of strings| Method Detail |
public static TabularData readFrom(java.io.File file)
throws java.io.IOException
file - the file to read from
java.io.IOException
public static TabularData readFrom(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - - The InputStream to read from.
java.io.IOException - and RuntimeExceptions if inputStream could not be read.
public void addColumn(java.lang.String name)
throws java.lang.IllegalArgumentException
name - the name of the column to be added.
java.lang.IllegalArgumentException - if the name is not valid or a column with that name already exists.
java.lang.IllegalStateException - if there are already rows in the table.public int size()
ITabularData
size in interface ITabularDataITabularData.size()public int numCols()
ITabularData
numCols in interface ITabularDataITabularData.numCols()public TabularDataRow getRow(int row)
row - the index of the row.
java.lang.RuntimeException - if row out of bounds.
public void addRow(TabularDataRow r)
throws java.lang.IllegalArgumentException
r - the row to add.
java.lang.IllegalArgumentException - if no columns have been defined yet.
public Atom getCell(int row,
int col)
getCell in interface ITabularDatarow - - The row index.col - - The column index.
ITabularData.getCell(int, int)
public Atom getCell(int row,
java.lang.String columnName)
getCell in interface ITabularDatarow - - The row index.columnName - - The name of the column.
public int getColumnIndex(java.lang.String colName)
getColumnIndex in interface ITabularDatacolName - the name of the column
public java.lang.String getColumnName(int col)
getColumnName in interface ITabularDatacol - the column index
java.lang.IllegalArgumentException - if col is out of range.
public void write(java.io.OutputStream outputStream)
throws java.io.IOException
outputStream - - The OutputStream to write the TabularData to.
java.io.IOException
public void save(java.io.File file)
throws java.io.IOException
file - - The file to write to.
java.io.IOExceptionpublic void clear()
public int hashCode()
Object.hashCode()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||