net.rim.device.api.ui.component.table
Class TableModel

java.lang.Object
  extended by net.rim.device.api.ui.component.table.DataModel
      extended by net.rim.device.api.ui.component.table.AbstractTableModel
          extended by net.rim.device.api.ui.component.table.TableModel
Direct Known Subclasses:
SortedTableModel

public class TableModel
extends AbstractTableModel

Implementation of AbstractTableModel that allows storage of any kind of data and supports all access/mutate methods.

Since:
BlackBerry API 6.0.0

Constructor Summary
TableModel()
          Creates a new data model with zero rows and zero columns.
TableModel(Object[][] elements)
          Creates a new table model using the provided elements as the data.
 
Method Summary
protected  boolean doAddColumn(Object data)
          This method provides the ability to customize the logic behind addColumn() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doAddMultipleRows(Object[] data)
          This method provides the ability to customize the logic behind addMultipleRows() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doAddRow(Object data)
          This method provides the ability to customize the logic behind addRow() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  Object doGetColumn(int columnIndex)
          Retrieves the array of elements at the specified column index.
protected  Object doGetElement(int rowIndex, int columnIndex)
          This method provides the ability to customize the logic behind getElement() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  Object doGetRow(int rowIndex)
          This method provides the ability to customize the logic behind getRow() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doInsertColumnAt(int columnIndex, Object data)
          This method provides the ability to customize the logic behind insertColumnAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doInsertMultipleRowsAt(int rowIndex, Object[] data)
          This method provides the ability to customize the logic behind insertMultipleRowsAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doInsertRowAt(int rowIndex, Object data)
          This method provides the ability to customize the logic behind insertRowAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doRemoveColumnAt(int columnIndex)
          This method provides the ability to customize the logic behind removeColumnAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doRemoveRowAt(int rowIndex)
          This method provides the ability to customize the logic behind removeRowAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doRemoveRowRangeAt(int rowIndex, int rowCount)
          This method provides the ability to customize the logic behind removeRowAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected  boolean doSetElement(int rowIndex, int columnIndex, Object data)
          This method provides the ability to customize the logic behind setElement() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
 int getNumberOfColumns()
          Get the number of columns in the table.
 int getNumberOfRows()
          Get the number of rows in the table.
 boolean implementationSupportsBatchOperations()
          This implementation of AbstractTableModel fully supports batch operations.
 
Methods inherited from class net.rim.device.api.ui.component.table.AbstractTableModel
addColumn, addColumn, addMultipleRows, addRow, addRow, getColumn, getElement, getRow, insertColumnAt, insertColumnAt, insertMultipleRowsAt, insertRowAt, insertRowAt, removeColumnAt, removeColumnAt, removeRowAt, removeRowAt, removeRowRangeAt, setElement, setElement
 
Methods inherited from class net.rim.device.api.ui.component.table.DataModel
modelReset, notifyListeners, registerListener, unregisterListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

TableModel

public TableModel()
Creates a new data model with zero rows and zero columns.

Since:
BlackBerry API 6.0.0

TableModel

public TableModel(Object[][] elements)
Creates a new table model using the provided elements as the data.

Notifications are not sent out for elements that are added through the constructor.

Parameters:
elements - Array of arrays representing a matrix to be inserted in this data model.
Since:
BlackBerry API 6.0.0


Method Detail

implementationSupportsBatchOperations

public boolean implementationSupportsBatchOperations()
This implementation of AbstractTableModel fully supports batch operations.

Overrides:
implementationSupportsBatchOperations in class AbstractTableModel
Returns:
True as this implementation fully supports batch operations.
See Also:
AbstractTableModel.addMultipleRows(Object[]), AbstractTableModel.insertMultipleRowsAt(int, Object[]), AbstractTableModel.removeRowRangeAt(int, int), AbstractTableModel.implementationSupportsBatchOperations()
Since:
BlackBerry API 7.0.0

doGetColumn

protected Object doGetColumn(int columnIndex)
Retrieves the array of elements at the specified column index.

Specified by:
doGetColumn in class AbstractTableModel
Parameters:
columnIndex - Column index to retrieve the elements from.
Returns:
Column at the specified index.
Throws:
IllegalArgumentException - If the index is invalid.
See Also:
AbstractTableModel.doGetColumn(int)
Since:
BlackBerry API 6.0.0

doGetRow

protected Object doGetRow(int rowIndex)
This method provides the ability to customize the logic behind getRow() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall getRow() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doGetRow in class AbstractTableModel
Parameters:
rowIndex - Row index to retrieve the elements from.
Returns:
Row at the specified index.
See Also:
AbstractTableModel.doGetRow(int)
Since:
BlackBerry API 6.0.0

doGetElement

protected Object doGetElement(int rowIndex,
                              int columnIndex)
This method provides the ability to customize the logic behind getElement() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall getElement() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doGetElement in class AbstractTableModel
Parameters:
rowIndex - Row index to retrieve the element from.
columnIndex - Column index to retrieve the elements from.
Returns:
Element at the specified indices.
See Also:
AbstractTableModel.doGetElement(int, int)
Since:
BlackBerry API 6.0.0

getNumberOfColumns

public int getNumberOfColumns()
Get the number of columns in the table.

Specified by:
getNumberOfColumns in class AbstractTableModel
Returns:
the number of columns in the table.
See Also:
AbstractTableModel.getNumberOfColumns()
Since:
BlackBerry API 6.0.0

getNumberOfRows

public int getNumberOfRows()
Get the number of rows in the table.

Specified by:
getNumberOfRows in class AbstractTableModel
Returns:
the number of rows in the table
See Also:
AbstractTableModel.getNumberOfRows()
Since:
BlackBerry API 6.0.0

doAddColumn

protected boolean doAddColumn(Object data)
This method provides the ability to customize the logic behind addColumn() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall addColumn() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doAddColumn in class AbstractTableModel
Parameters:
data - The column data to be added to the model.
Returns:
True if the column was added to the model. False otherwise.
See Also:
AbstractTableModel.addColumn(Object)
Since:
BlackBerry API 6.0.0

doAddRow

protected boolean doAddRow(Object data)
This method provides the ability to customize the logic behind addRow() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall addRow() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doAddRow in class AbstractTableModel
Parameters:
data - The row data to be added to the model.
Returns:
True if the row was added to the model. False otherwise.
See Also:
AbstractTableModel.addRow(Object)
Since:
BlackBerry API 6.0.0

doInsertColumnAt

protected boolean doInsertColumnAt(int columnIndex,
                                   Object data)
This method provides the ability to customize the logic behind insertColumnAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall insertColumnAt() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doInsertColumnAt in class AbstractTableModel
Parameters:
columnIndex - Index at which to insert the column.
data - Column of data to be inserted.
Returns:
True if the column was inserted. False otherwise.
See Also:
AbstractTableModel.insertColumnAt(int, Object)
Since:
BlackBerry API 6.0.0

doInsertRowAt

protected boolean doInsertRowAt(int rowIndex,
                                Object data)
This method provides the ability to customize the logic behind insertRowAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall insertRowAt() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doInsertRowAt in class AbstractTableModel
Parameters:
rowIndex - Index at which to insert the column.
data - Column of data to be inserted.
Returns:
True if the column was inserted. False otherwise.
See Also:
AbstractTableModel.insertRowAt(int, Object)
Since:
BlackBerry API 6.0.0

doRemoveColumnAt

protected boolean doRemoveColumnAt(int columnIndex)
This method provides the ability to customize the logic behind removeColumnAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall removeColumnAt() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doRemoveColumnAt in class AbstractTableModel
Parameters:
columnIndex - The index of the column to be removed.
Returns:
True if the column was removed. False otherwise.
See Also:
AbstractTableModel.removeColumnAt(int)
Since:
BlackBerry API 6.0.0

doRemoveRowAt

protected boolean doRemoveRowAt(int rowIndex)
This method provides the ability to customize the logic behind removeRowAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall removeRowAt() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doRemoveRowAt in class AbstractTableModel
Parameters:
rowIndex - The index of the row to be removed.
Returns:
True if the row was removed. False otherwise.
See Also:
AbstractTableModel.removeRowAt(int)
Since:
BlackBerry API 6.0.0

doRemoveRowRangeAt

protected boolean doRemoveRowRangeAt(int rowIndex,
                                     int rowCount)
This method provides the ability to customize the logic behind removeRowAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall removeRowAt() algorithm doesn't change, while allowing key behavior to be configurable.

Overrides:
doRemoveRowRangeAt in class AbstractTableModel
Parameters:
rowIndex - Index of row to be removed.
rowCount - The number of rows to remove
Returns:
True if the rows were removed, false otherwise.
See Also:
AbstractTableModel.doRemoveRowRangeAt(int, int)
Since:
BlackBerry API 7.0.0

doSetElement

protected boolean doSetElement(int rowIndex,
                               int columnIndex,
                               Object data)
This method provides the ability to customize the logic behind setElement() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall setElement() algorithm doesn’t change, while allowing key behavior to be configurable.

Specified by:
doSetElement in class AbstractTableModel
Parameters:
rowIndex - Index of row in which to insert.
columnIndex - Index of column in which to insert.
data - Element of data to insert.
Returns:
True if the element was inserted. False otherwise.
See Also:
AbstractTableModel.setElement(int, int, Object)
Since:
BlackBerry API 6.0.0

doAddMultipleRows

protected boolean doAddMultipleRows(Object[] data)
This method provides the ability to customize the logic behind addMultipleRows() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall addMultipleRows() algorithm doesn't change, while allowing key behavior to be configurable. The default behavior is not implemented. If this method returns false, the base implementation will insert the rows with multiple calls to addRow(). As such, implementations of doAddMultipleRows() should ensure that rows are added atomically.

Overrides:
doAddMultipleRows in class AbstractTableModel
Parameters:
data - The rows of data to be added to the model.
Returns:
True if all rows were added. False if no rows were added.
See Also:
AbstractTableModel.doAddMultipleRows(java.lang.Object[])
Since:
BlackBerry API 7.0.0

doInsertMultipleRowsAt

protected boolean doInsertMultipleRowsAt(int rowIndex,
                                         Object[] data)
This method provides the ability to customize the logic behind insertMultipleRowsAt() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well. This way, the general structure of the overall insertMultipleRowsAt() algorithm doesn't change, while allowing key behavior to be configurable.\ The default behaviour is not implemented. If this method returns false, the base implementation will insert the rows with multiple calls to insertRowAt(). As such, implementations of doInsertMultipleRowsAt() should ensure that rows are added atomically.

Overrides:
doInsertMultipleRowsAt in class AbstractTableModel
Parameters:
rowIndex - Index of row in which to insert.
data - Array of row data to insert
Returns:
False if no rows were added, true if all rows have been added.
See Also:
AbstractTableModel.doInsertMultipleRowsAt(int, java.lang.Object[])
Since:
BlackBerry API 7.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal