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

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
              extended by net.rim.device.api.ui.component.table.SortedTableModel

public class SortedTableModel
extends TableModel

Maintain a sorted model according to one row column.

Since:
BlackBerry API 6.0.0

Constructor Summary
SortedTableModel(Object[][] elements, Comparator comparator, int sortedColumn)
          Create a SortedTableModel that uses the given comparator and sorted column number.
SortedTableModel(Comparator comparator, int sortedColumn)
          Create a SortedTableModel that uses the given comparator and sorted column number.
 
Method Summary
protected  boolean doAddMultipleRows(Object[] data)
          SortedTableModel is unable to insert multiple rows.
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  boolean doInsertMultipleRowsAt(int rowIndex, Object[] data)
          SortedTableModel is unable to insert multiple rows.
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.
 Comparator getComparator()
          Get the comparator that is being used to compare elements in the sorted column.
 int getSortColumn()
          Get the column number that is being used to sort the table.
 boolean implementationSupportsBatchOperations()
          SortedTableModel is unable to insert multiple contiguous rows, as the row order will be changed on insert.
 
Methods inherited from class net.rim.device.api.ui.component.table.TableModel
doAddColumn, doGetColumn, doGetElement, doGetRow, doInsertColumnAt, doRemoveColumnAt, doRemoveRowAt, doRemoveRowRangeAt, doSetElement, getNumberOfColumns, getNumberOfRows
 
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

SortedTableModel

public SortedTableModel(Comparator comparator,
                        int sortedColumn)
Create a SortedTableModel that uses the given comparator and sorted column number.

Parameters:
comparator - the comparator used to compare two items in the sorted column of the model.
sortedColumn - the column number that is sorted using the comparator.
Throws:
IllegalArgumentException - If comparator is passed in as null. Comparator must be defined for object type.
Since:
BlackBerry API 6.0.0

SortedTableModel

public SortedTableModel(Object[][] elements,
                        Comparator comparator,
                        int sortedColumn)
Create a SortedTableModel that uses the given comparator and sorted column number.

Parameters:
elements - the initial data in the model that will be added to the table in sorted order.
comparator - the comparator used to compare two items in the sorted column of the model.
sortedColumn - the column number that is sorted using the comparator.
Throws:
IllegalArgumentException - If comparator is passed in as null. Comparator must be defined for object type.
Since:
BlackBerry API 6.0.0


Method Detail

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.

Overrides:
doAddRow in class TableModel
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.doAddRow(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.

Overrides:
doInsertRowAt in class TableModel
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.doInsertRowAt(int, Object)
Since:
BlackBerry API 6.0.0

getComparator

public Comparator getComparator()
Get the comparator that is being used to compare elements in the sorted column.

Returns:
the current comparator that is being used to compare elements in the sorted column.
Since:
BlackBerry API 6.0.0

getSortColumn

public int getSortColumn()
Get the column number that is being used to sort the table.

Returns:
the column number that is being used to sort the table
Since:
BlackBerry API 6.0.0

doAddMultipleRows

protected boolean doAddMultipleRows(Object[] data)
SortedTableModel is unable to insert multiple rows.

Overrides:
doAddMultipleRows in class TableModel
Parameters:
data - The rows of data to be added to the model.
Returns:
False, no rows will be added by this implementation.
See Also:
AbstractTableModel.doAddMultipleRows(java.lang.Object[])
Since:
BlackBerry API 7.0.0

doInsertMultipleRowsAt

protected boolean doInsertMultipleRowsAt(int rowIndex,
                                         Object[] data)
SortedTableModel is unable to insert multiple rows.

Overrides:
doInsertMultipleRowsAt in class TableModel
Parameters:
rowIndex - Index of row in which to insert.
data - Array of row data to insert
Returns:
False, no rows will be added by this implementation.
See Also:
AbstractTableModel.doInsertMultipleRowsAt(int, java.lang.Object[])
Since:
BlackBerry API 7.0.0

implementationSupportsBatchOperations

public boolean implementationSupportsBatchOperations()
SortedTableModel is unable to insert multiple contiguous rows, as the row order will be changed on insert.

Overrides:
implementationSupportsBatchOperations in class TableModel
Returns:
False, as this implementation does not support multiple row operations.
See Also:
TableModel.implementationSupportsBatchOperations()
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