org.jaffa.presentation.portlet.widgets.model
Class TableModel

java.lang.Object
  extended byorg.jaffa.presentation.portlet.widgets.model.WidgetModel
      extended byorg.jaffa.presentation.portlet.widgets.model.TableModel

public class TableModel
extends WidgetModel

Model for the Table widget.


Nested Class Summary
 class TableModel.Column
          An instance of this class will be created for each column added to the TableModel.
 
Constructor Summary
TableModel()
           
 
Method Summary
 void addColumn(String name, String dataType)
          Add a column to the Table.
 void addRow(int position, List fields)
          Add a row to the table.
 void addRow(List fields)
          Add a row to the table.
 void clearColumns()
          Clear out all the columns
 void clearRows()
          Clear out all the rows
 String getColumnDataType(String columnName)
          Returns the dataType for the columnName.
 List getColumnNames()
          Returns a List of columnNames, in the order of entry.
 List getColumns()
          Returns a List of TableModel.Column objects, in the order of entry.
 List getRow(int rowNum)
          Returns a List of field values in column order for the input row number.
 List getRows()
          Returns a Collection, where each element is a List of fields, in the order of the columns.
 List getSelectedRows()
          Returns a List of selected rows, where each row is a List of field values.
 Object getValue(String columnName, int rowNum)
          Return a field value from a given row.
 boolean isModelChanged()
          See if model has changed, in the process reset the changed flag.
 void setSelectedRows(List rowNums)
          Sets the selected rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableModel

public TableModel()
Method Detail

clearColumns

public void clearColumns()
Clear out all the columns


addColumn

public void addColumn(String name,
                      String dataType)
Add a column to the Table. An exisiting column by the same name will be over-written.

Parameters:
name - The name of the column.
dataType - The data type of the column.

getColumns

public List getColumns()
Returns a List of TableModel.Column objects, in the order of entry.

Returns:
a List of TableModel.Column objects, in the order of entry.

getColumnNames

public List getColumnNames()
Returns a List of columnNames, in the order of entry.

Returns:
a List of columnNames, in the order of entry.

getColumnDataType

public String getColumnDataType(String columnName)
Returns the dataType for the columnName. A null will be returned in case no such column exists.

Parameters:
columnName - The name of the column.
Returns:
the dataType for the column.

addRow

public void addRow(List fields)
Add a row to the table. A ColumnMismatchRuntimeException is thrown if the no. of fields does not equal the no. of columns.

Parameters:
fields - The List of values.

addRow

public void addRow(int position,
                   List fields)
Add a row to the table. A ColumnMismatchRuntimeException is thrown if the no. of fields does not equal the no. of columns.

Parameters:
position - The index of the row.
fields - The List of values.

clearRows

public void clearRows()
Clear out all the rows


getRows

public List getRows()
Returns a Collection, where each element is a List of fields, in the order of the columns.

Returns:
a Collection, where each element is a List of fields, in the order of the columns.

getRow

public List getRow(int rowNum)
Returns a List of field values in column order for the input row number. An IndexOutOfBoundsException will be thrown in case the rowNum is senseless.

Parameters:
rowNum - The index of the row to be retrieved.
Returns:
a List of field values in column order for the input row number.

getValue

public Object getValue(String columnName,
                       int rowNum)
Return a field value from a given row. A null will be returned in case the columnName does not exist An IndexOutOfBoundsException will be thrown in case the rowNum is senseless.

Parameters:
columnName - The name of the column.
rowNum - The index of the row to be retrieved.
Returns:
a field value from a given row.

getSelectedRows

public List getSelectedRows()
Returns a List of selected rows, where each row is a List of field values.

Returns:
a List of selected rows, where each row is a List of field values.

setSelectedRows

public void setSelectedRows(List rowNums)
Sets the selected rows. This will first reset the selected status of all rows.

Parameters:
rowNums - A List of row numbers to be marked as selected.

isModelChanged

public boolean isModelChanged()
See if model has changed, in the process reset the changed flag.

Returns:
true if the model was changed.


Copyright © 2002-2004 JAFFA Project.