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 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 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.
 
Methods inherited from class net.rim.device.api.ui.component.table.TableModel
doAddColumn, doGetColumn, doGetElement, doGetRow, doInsertColumnAt, doRemoveColumnAt, doRemoveRowAt, doSetElement, getNumberOfColumns, getNumberOfRows
 
Methods inherited from class net.rim.device.api.ui.component.table.AbstractTableModel
addColumn, addColumn, addRow, addRow, getColumn, getElement, getRow, insertColumnAt, insertColumnAt, insertRowAt, insertRowAt, removeColumnAt, removeColumnAt, removeRowAt, removeRowAt, 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)
Description copied from class: AbstractTableModel
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
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)
Description copied from class: AbstractTableModel
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
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





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.