All Packages Class Hierarchy This Package Previous Next Index
Class sdsu.util.LabeledTable
java.lang.Object
|
+----sdsu.util.Table
|
+----sdsu.util.LabeledTable
- public class LabeledTable
- extends Table
This class is a two dimensional table that permits indexing via labels. Labels are taken from
the first row and column. If the contents of LabeledTable example is:
Name | Pay | Department |
Joe | $100.00 | Math |
Sally | $500.00 | Physics |
then example.elementAt( "Sally", "Pay") returns $500.00.
If row (column) labels contain duplicates, only the first instance is accessed by label indexing.
When creating subtables (via rowAt, rowsAt, columnAt
columnsAt) labels from original table are copied to subtable. While changing individual elements
via labels is supported, adding additional rows and columns via labels is not yet supported. Use addRow and
addColumn from Table superclass.
- Author:
- Roger Whitney (whitney@cs.sdsu.edu)
- See Also:
- SimpleTokenizer, Stringizer, TokenCharacters, Table
-
LabeledTable()
- Create a new LabeledTable with no rows and no columns
-
LabeledTable(int, int)
- Create a new LabeledTable with given number of rows and columns.
-
LabeledTable(Table)
- Create a LabeledTable from a table
-
clone()
- Clones this labledTable.
-
columnAt(Object)
- Returns the column in the table indicated by the label
Returns null if column label is not found
Rows labels of current labeledTable are copied to new LabeledTable
-
columnsAt(int, int)
- Creates a new labeledTable with the specified columns of current labeledTable
Rows labels of current labeledTable are copied to new LabeledTable
-
columnsAt(Object, Object)
- Creates a new LabeledTable containing all the columns that have the
value key in the indicated row.
-
elementAt(int, Object)
- Returns the object in table at given row and column.
-
elementAt(Object, int)
- Returns the object in table at given row and column.
-
elementAt(Object, Object)
- Returns the object in table at given row and column.
-
insertColumnsAt(Table, Object)
- Insert table "newColumns" in the Table.
-
insertRowsAt(Table, Object)
- Insert table "newRows" in the Table.
-
removeColumnAt(Object)
- Removes the indicated column from the table
-
removeColumnsAt(Object, Object)
- Removes the indicated columns that have key in the indicated row
-
removeRowAt(Object)
- Removes the indicated row from the table
-
removeRowsAt(Object, Object)
- Removes the indicated rows that have key in the indicated column
-
rowAt(Object)
- Returns the column in the table indicated by the label
Returns null if column label is not found
-
rowsAt(int, int)
- Creates a new table with the specified rows of current table
-
rowsAt(Object, Object)
- Returns a new table containing all the rows that have the value key in the indicated column
-
setElementAt(Object, int, Object)
- Places the object in table at given row and column
-
setElementAt(Object, Object, int)
- Places the object in table at given row and column
-
setElementAt(Object, Object, Object)
- Places the object in table at given row and column
LabeledTable
public LabeledTable()
- Create a new LabeledTable with no rows and no columns
LabeledTable
public LabeledTable(int initNumberOfRows,
int initNumberOfColumns)
- Create a new LabeledTable with given number of rows and columns. All elements are
set to null.
LabeledTable
public LabeledTable(Table contents)
- Create a LabeledTable from a table
clone
public synchronized Object clone()
- Clones this labledTable. The elements are not cloned.
- Overrides:
- clone in class Table
elementAt
public synchronized Object elementAt(int row,
Object columnLabel) throws ArrayIndexOutOfBoundsException
- Returns the object in table at given row and column. Column is indicated by label object.
Returns null if column label is not found
- Throws: ArrayIndexOutOfBoundsException
- thrown if row or columnLabel is not
a valid index
elementAt
public synchronized Object elementAt(Object rowLabel,
Object columnLabel) throws ArrayIndexOutOfBoundsException
- Returns the object in table at given row and column. row is indicated by label object.
Returns null if row label is not found
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowlabel or columnLabel is not
a valid index
elementAt
public synchronized Object elementAt(Object rowLabel,
int column) throws ArrayIndexOutOfBoundsException
- Returns the object in table at given row and column. row is indicated by label object.
Returns null if row label is not found
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowlabel or column is not
a valid index
columnAt
public synchronized LabeledTable columnAt(Object columnLabel) throws ArrayIndexOutOfBoundsException
- Returns the column in the table indicated by the label
Returns null if column label is not found
Rows labels of current labeledTable are copied to new LabeledTable
- Throws: ArrayIndexOutOfBoundsException
- thrown if is not
a valid index
columnsAt
public synchronized LabeledTable columnsAt(Object key,
Object rowLabel) throws ArrayIndexOutOfBoundsException
- Creates a new LabeledTable containing all the columns that have the
value key in the indicated row.
Rows labels of current labeledTable are copied to new LabeledTable
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowlabel is not
a valid index
columnsAt
public synchronized Table columnsAt(int startColumn,
int endColumn) throws ArrayIndexOutOfBoundsException
- Creates a new labeledTable with the specified columns of current labeledTable
Rows labels of current labeledTable are copied to new LabeledTable
- Returns:
- a labeledTable, inheritance forces to declare return type as table
- Throws: ArrayIndexOutOfBoundsException
- thrown if startColumn or endColumn is not
a valid index
- Overrides:
- columnsAt in class Table
insertColumnsAt
public synchronized void insertColumnsAt(Table newColumns,
Object startColumnLabel) throws ArrayIndexOutOfBoundsException
- Insert table "newColumns" in the Table. "newColumns" is inserted at column "startColumnLabel" of
current table. The column "startIndex" prior to the insert will follow the newly added columns
Table grows to include all elements of newColumns
- Throws: ArrayIndexOutOfBoundsException
- thrown ifstartColumnLabel is not
a valid index
removeColumnAt
public synchronized void removeColumnAt(Object columnLabel) throws ArrayIndexOutOfBoundsException
- Removes the indicated column from the table
- Throws: ArrayIndexOutOfBoundsException
- thrown if columnLabel is not
a valid index
removeColumnsAt
public synchronized void removeColumnsAt(Object key,
Object rowLabel) throws ArrayIndexOutOfBoundsException, NullPointerException
- Removes the indicated columns that have key in the indicated row
- Parameters:
- key - the key to be searched for
- row - row in table to search for the key
- Throws: ArrayIndexOutOfBoundsException
- thrown if
row is not a valid index
- Throws: NullPointerException
- thrown if key is null
insertRowsAt
public synchronized void insertRowsAt(Table newRows,
Object rowLabel) throws ArrayIndexOutOfBoundsException
- Insert table "newRows" in the Table. "newRows" is inserted at row "startRowLabel" of
current table. The row "startIndex" prior to the insert will follow the newly added rows
Table grows to include all elements of newRows
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowlabel is not
a valid index
removeRowAt
public synchronized void removeRowAt(Object rowLabel) throws ArrayIndexOutOfBoundsException
- Removes the indicated row from the table
- Throws: ArrayIndexOutOfBoundsException
- thrown if
rowlabel is not a valid index
removeRowsAt
public synchronized void removeRowsAt(Object key,
Object columnLabel) throws ArrayIndexOutOfBoundsException, NullPointerException
- Removes the indicated rows that have key in the indicated column
- Parameters:
- key - the key to be searched for
- column - column in table to search for the key
- Throws: ArrayIndexOutOfBoundsException
- thrown if
columnLabel is not a valid index
- Throws: NullPointerException
- thrown if key is null
rowAt
public synchronized LabeledTable rowAt(Object rowLabel) throws ArrayIndexOutOfBoundsException
- Returns the column in the table indicated by the label
Returns null if column label is not found
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowLabel is not a valid index
rowsAt
public synchronized Table rowsAt(int startRow,
int endRow) throws ArrayIndexOutOfBoundsException
- Creates a new table with the specified rows of current table
- Throws: ArrayIndexOutOfBoundsException
- thrown if row or column is not
a valid index
- Overrides:
- rowsAt in class Table
rowsAt
public synchronized LabeledTable rowsAt(Object key,
Object columnLabel) throws ArrayIndexOutOfBoundsException
- Returns a new table containing all the rows that have the value key in the indicated column
- Throws: ArrayIndexOutOfBoundsException
- thrown if columnLabel is not
a valid index
setElementAt
public synchronized void setElementAt(Object data,
Object rowLabel,
int column) throws ArrayIndexOutOfBoundsException
- Places the object in table at given row and column
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowLabel or column is not
a valid index
setElementAt
public synchronized void setElementAt(Object data,
int row,
Object columnLabel) throws ArrayIndexOutOfBoundsException
- Places the object in table at given row and column
- Throws: ArrayIndexOutOfBoundsException
- thrown if row or columnLabel is not
a valid index
setElementAt
public synchronized void setElementAt(Object data,
Object rowLabel,
Object columnLabel) throws ArrayIndexOutOfBoundsException
- Places the object in table at given row and column
- Throws: ArrayIndexOutOfBoundsException
- thrown if rowLabel or columnLabel is not
a valid index
All Packages Class Hierarchy This Package Previous Next Index