|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdsu.util.Table
This class is a two dimensional table. Indexing of rows and columns starts at 0.
The table is growable. Surplus rows and columns are allocated to reduce cost of
growing the table. Surplus rows/columns can not be accessed until rows or columns are
added. Table can be converted from/to string/streams. In string representation default
column separator is ',' and default row separator is ';'.
The recreated table object will only contain string representations of the original
elements in the table.
Version Info
1.1 Add support for Stringizable, metaData, changed exception thrown by fromString
SimpleTokenizer
,
Stringizer
,
TokenCharacters
, Serialized FormConstructor Summary | |
Table()
Create a new table with no rows and no columns |
|
Table(int initNumberOfRows,
int initNumberOfColumns)
Create a new table with given number of rows and columns. |
Method Summary | |
void |
addColumn(java.util.Vector newColumn)
Add a new column to the end of the Table. |
void |
addColumns(Table newColumns)
Add a table as new columns. |
void |
addRow(java.util.Vector newRow)
Add a new row to the end of the Table. |
void |
addRows(Table newRows)
Add table "newRows" at the bottom of the Table. |
java.lang.Object |
clone()
Clones this table. |
java.util.Vector |
columnAt(int column)
Returns the given column in the table |
Table |
columnsAt(int startColumn,
int endColumn)
Creates a new table with the specified columns of current table |
Table |
columnsAt(java.lang.Object key,
int row)
Creates a new table containing all the columns that have the value key in the indicated row |
boolean |
contains(java.lang.Object element)
Returns true if the specified object is in the table |
java.lang.Object |
elementAt(int row,
int column)
Returns the object in table at given row and column. |
java.util.Enumeration |
elements()
Returns an enumeration of the non-null elements in row order. |
static Table |
fromColumnVector(java.util.Vector column)
Create a table using the vector column as the only column in the table |
static Table |
fromRowVector(java.util.Vector row)
Create a table using the vector row as the only row in the table |
void |
fromString(java.lang.String tableString)
Loads a Table from a string. |
LabeledData |
getMetaData()
Returns name-valeu pair of data used to parse a string version of a LabeledData object |
java.awt.Point |
indexOf(java.lang.Object element)
Searches for the specified object, in row order. |
void |
insertColumnsAt(Table newColumns,
int startIndex)
Insert table "newColumns" in the Table. |
void |
insertRowsAt(Table newRows,
int startIndex)
Insert table "newRows" in the Table. |
void |
load(java.io.InputStream in)
Loads a Table from an inputstream. |
void |
load(java.io.Reader in)
Loads a Table from an inputstream. |
int |
numberOfColumns()
Returns the number of columns that can currently be accessed |
int |
numberOfRows()
Returns the number of rows that can currently be accessed |
void |
removeColumnAt(int columnIndex)
Removes the indicated column from the table |
void |
removeColumnsAt(int firstColumn,
int endColumn)
Removes the indicated columns from the table |
void |
removeColumnsAt(java.lang.Object key,
int row)
Removes the indicated columns that have key in the indicated row |
void |
removeRowAt(int rowIndex)
Removes the indicated row from the table |
void |
removeRowsAt(int firstRow,
int endRow)
Removes the indicated rows from the table |
void |
removeRowsAt(java.lang.Object key,
int column)
Removes the indicated rows that have key in the indicated column |
java.util.Vector |
rowAt(int row)
Returns the given row in the table |
Table |
rowsAt(int startRow,
int endRow)
Creates a new table with the specified rows of current table |
Table |
rowsAt(java.lang.Object key,
int column)
Returns a new table containing all the rows that have the value key in the indicated column |
void |
save(java.io.OutputStream out,
java.lang.String header)
Writes ascii representation of a Table to Outputstream |
void |
setColumnSeparatorChar(char columnSeparatorChar)
Set character used to separate rows in String representation of a Table |
void |
setElementAt(java.lang.Object data,
int row,
int column)
Places the object in table at given row and column |
void |
setMetaData(LabeledData metaData)
Set the current objects metadata to be that found in metaData string |
void |
setRowSeparatorChar(char rowSeparatorChar)
Set character used to separate rows in String representation of a Table |
void |
setTokenCharacters(TokenCharacters newParseTable)
Sets TokenCharacters used to convert Table from/to strings/streams. |
int |
size()
Return the number of items in the table |
java.lang.String |
toString()
Converts a Table to a String. |
java.lang.String |
toString(java.lang.String header)
Converts a Table to a String with given header information. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Table()
public Table(int initNumberOfRows, int initNumberOfColumns)
Method Detail |
public static Table fromRowVector(java.util.Vector row)
public static Table fromColumnVector(java.util.Vector column)
public LabeledData getMetaData()
public void setMetaData(LabeledData metaData)
public void setTokenCharacters(TokenCharacters newParseTable)
public void setRowSeparatorChar(char rowSeparatorChar)
public void setColumnSeparatorChar(char columnSeparatorChar)
public java.awt.Point indexOf(java.lang.Object element)
public boolean contains(java.lang.Object element)
public java.lang.Object clone()
public java.lang.Object elementAt(int row, int column) throws java.lang.ArrayIndexOutOfBoundsException
public java.util.Vector rowAt(int row) throws java.lang.ArrayIndexOutOfBoundsException
public java.util.Vector columnAt(int column) throws java.lang.ArrayIndexOutOfBoundsException
public Table columnsAt(int startColumn, int endColumn) throws java.lang.ArrayIndexOutOfBoundsException
public Table columnsAt(java.lang.Object key, int row) throws java.lang.ArrayIndexOutOfBoundsException
public Table rowsAt(int startRow, int endRow) throws java.lang.ArrayIndexOutOfBoundsException
public Table rowsAt(java.lang.Object key, int column) throws java.lang.ArrayIndexOutOfBoundsException
public java.util.Enumeration elements()
public void setElementAt(java.lang.Object data, int row, int column) throws java.lang.ArrayIndexOutOfBoundsException
public void addRow(java.util.Vector newRow)
newRow
- vector of item added to the new rowpublic void addRows(Table newRows)
newRows
- table to add to bottompublic void insertRowsAt(Table newRows, int startIndex) throws java.lang.ArrayIndexOutOfBoundsException
startIndex
- the first row of newRows becomes row startIndex in current tablepublic void addColumn(java.util.Vector newColumn)
newColumn
- vector of item added to the new columnpublic void addColumns(Table newColumns)
newColumns
- table to addpublic void insertColumnsAt(Table newColumns, int startIndex) throws java.lang.ArrayIndexOutOfBoundsException
startIndex
- the first column of newColumns becomes column startIndex in current tablepublic void removeRowAt(int rowIndex) throws java.lang.ArrayIndexOutOfBoundsException
public void removeRowsAt(int firstRow, int endRow) throws java.lang.ArrayIndexOutOfBoundsException
public void removeRowsAt(java.lang.Object key, int column) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.NullPointerException
key
- the key to be searched forcolumn
- column in table to search for the keypublic void removeColumnAt(int columnIndex) throws java.lang.ArrayIndexOutOfBoundsException
public void removeColumnsAt(int firstColumn, int endColumn) throws java.lang.ArrayIndexOutOfBoundsException
public void removeColumnsAt(java.lang.Object key, int row) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.NullPointerException
key
- the key to be searched forrow
- row in table to search for the keypublic int size()
public int numberOfColumns()
public int numberOfRows()
public java.lang.String toString()
public java.lang.String toString(java.lang.String header)
public void save(java.io.OutputStream out, java.lang.String header)
public void load(java.io.InputStream in) throws java.io.IOException
public void load(java.io.Reader in) throws java.io.IOException
public void fromString(java.lang.String tableString) throws ConversionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |