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

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

public abstract class AbstractTableModel
extends DataModel

A model for table components. Implementations of AbstractTableModel provide a representation of the data to be displayed in the view, e.g. concrete data structures, or an adapter to data stores in an alternative structure. It should handle requests from the controller and subsequently notify the view of any changes via listeners.

Since:
BlackBerry API 6.0.0

Constructor Summary
AbstractTableModel()
          Default constructor.
 
Method Summary
 void addColumn(Object data)
           
 void addColumn(Object data, boolean doNotifyListeners)
          Add a column to the data model.
 void addRow(Object data)
           
 void addRow(Object data, boolean doNotifyListeners)
          Add a row to the model.
protected abstract  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 abstract  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 abstract  Object doGetColumn(int columnIndex)
          This method provides the ability to customize the logic behind getColumn() so that a developer can specify this behavior while still ensuring that necessary notification and exception handling overheads can occur as well.
protected abstract  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 abstract  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 abstract  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 abstract  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 abstract  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 abstract  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 abstract  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.
 Object getColumn(int columnIndex)
          Retrieves the array of elements at the specified column index.
 Object getElement(int rowIndex, int columnIndex)
          Retrieves the element at the specified row index and column index.
abstract  int getNumberOfColumns()
          Get the number of columns in the table.
abstract  int getNumberOfRows()
          Get the number of rows in the table.
 Object getRow(int rowIndex)
          Retrieves the array of elements at the specified row index.
 void insertColumnAt(int columnIndex, Object data)
           
 void insertColumnAt(int columnIndex, Object data, boolean doNotifyListeners)
          Inserts a column to the model at the specified index.
 void insertRowAt(int rowIndex, Object data)
           
 void insertRowAt(int rowIndex, Object data, boolean doNotifyListeners)
          Inserts a row to the model at the specified index.
 void removeColumnAt(int columnIndex)
           
 void removeColumnAt(int columnIndex, boolean doNotifyListeners)
          Deletes a column from the model at the specified index.
 void removeRowAt(int rowIndex)
           
 void removeRowAt(int rowIndex, boolean doNotifyListeners)
          Deletes a row from the model at the specified index.
 void setElement(int rowIndex, int columnIndex, Object data)
           
 void setElement(int rowIndex, int columnIndex, Object data, boolean doNotifyListeners)
          Sets the element at specified rowIndex and columnIndex.
 
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

AbstractTableModel

public AbstractTableModel()
Default constructor.

Since:
BlackBerry API 6.0.0


Method Detail

getColumn

public final Object getColumn(int columnIndex)
                       throws IllegalArgumentException
Retrieves the array of elements at the specified column index.

Parameters:
columnIndex - Column index to retrieve the elements from.
Returns:
Column at the specified index.
Throws:
IllegalArgumentException - If the index is invalid.
Since:
BlackBerry API 6.0.0

doGetColumn

protected abstract Object doGetColumn(int columnIndex)
This method provides the ability to customize the logic behind getColumn() 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 getColumn() algorithm doesn’t change, while allowing key behavior to be configurable.

Parameters:
columnIndex - Column index to retreive the elements from.
Returns:
Column at the specified index.
Since:
BlackBerry API 6.0.0

getRow

public final Object getRow(int rowIndex)
                    throws IllegalArgumentException
Retrieves the array of elements at the specified row index.

Parameters:
rowIndex - Row index to retrieve the elements from.
Returns:
Row at the specified index.
Throws:
IllegalArgumentException - If the index is invalid.
Since:
BlackBerry API 6.0.0

doGetRow

protected abstract 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.

Parameters:
rowIndex - Row index to retrieve the elements from.
Returns:
Row at the specified index.
Since:
BlackBerry API 6.0.0

getElement

public final Object getElement(int rowIndex,
                               int columnIndex)
                        throws IllegalArgumentException
Retrieves the element at the specified row index and column index.

Parameters:
rowIndex - Row index to retrieve the element from.
columnIndex - Column index to retrieve the elements from.
Returns:
Element at the specified indices.
Throws:
IllegalArgumentException - If the row index or column index is invalid.
Since:
BlackBerry API 6.0.0

doGetElement

protected abstract 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.

Parameters:
rowIndex - Row index to retrieve the element from.
columnIndex - Column index to retrieve the elements from.
Returns:
Element at the specified indices.
Since:
BlackBerry API 6.0.0

getNumberOfColumns

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

Returns:
the number of columns in the table.
Since:
BlackBerry API 6.0.0

getNumberOfRows

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

Returns:
the number of rows in the table
Since:
BlackBerry API 6.0.0

addColumn

public final void addColumn(Object data,
                            boolean doNotifyListeners)
                     throws IllegalArgumentException
Add a column to the data model. A column must have an element for each row in the model, i.e. if there are multiple rows in the model then data needs to be an array of length AbstractTableModel.getNumberOfRows(). If there is 1 row then data can be any object. After the add is done the listeners are notified.

Parameters:
data - The column data to be added to the model.
doNotifyListeners - True if listeners should be notified of changes. False otherwise.
Throws:
IllegalArgumentException - If data is null or has invalid row count.
Since:
BlackBerry API 6.0.0

addColumn

public final void addColumn(Object data)
                     throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.addColumn(Object, boolean)
Since:
BlackBerry API 6.0.0

doAddColumn

protected abstract 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.

Parameters:
data - The column data to be added to the model.
Returns:
True if the column was added to the model. False otherwise.
Since:
BlackBerry API 6.0.0

addRow

public final void addRow(Object data,
                         boolean doNotifyListeners)
                  throws IllegalArgumentException
Add a row to the model. A row must have an element for each column in the model, i.e. if there are multiple columns in the model then data needs to be an array of length AbstractTableModel.getNumberOfColumns() if there is 1 column then element can be any object. After the add is done the listeners are notified.

Parameters:
data - The row data to be added to the model.
doNotifyListeners - True if listeners should be notified of changes. False otherwise.
Throws:
IllegalArgumentException - If data is null or has invalid column count.
Since:
BlackBerry API 6.0.0

addRow

public final void addRow(Object data)
                  throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.addRow(Object, boolean)
Since:
BlackBerry API 6.0.0

doAddRow

protected abstract 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.

Parameters:
data - The row data to be added to the model.
Returns:
True if the row was added to the model. False otherwise.
Since:
BlackBerry API 6.0.0

removeColumnAt

public final void removeColumnAt(int columnIndex,
                                 boolean doNotifyListeners)
                          throws IllegalArgumentException
Deletes a column from the model at the specified index. After the remove is done the listeners are notified.

Parameters:
columnIndex - Column index to delete the column at.
Throws:
IllegalArgumentException - If columnIndex is invalid.
Since:
BlackBerry API 6.0.0

removeColumnAt

public final void removeColumnAt(int columnIndex)
                          throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.removeColumnAt(int, boolean)
Since:
BlackBerry API 6.0.0

doRemoveColumnAt

protected abstract 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.

Parameters:
columnIndex - The index of the column to be removed.
Returns:
True if the column was removed. False otherwise.
Since:
BlackBerry API 6.0.0

removeRowAt

public final void removeRowAt(int rowIndex,
                              boolean doNotifyListeners)
                       throws IllegalArgumentException
Deletes a row from the model at the specified index. After the remove is done the listeners are notified.

Parameters:
columnIndex - Row index to delete the row at.
Throws:
IllegalArgumentException - If rowIndex is invalid.
Since:
BlackBerry API 6.0.0

removeRowAt

public final void removeRowAt(int rowIndex)
                       throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.removeRowAt(int, boolean)
Since:
BlackBerry API 6.0.0

doRemoveRowAt

protected abstract 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.

Parameters:
rowIndex - The index of the row to be removed.
Returns:
True if the row was removed. False otherwise.
Since:
BlackBerry API 6.0.0

insertColumnAt

public final void insertColumnAt(int columnIndex,
                                 Object data,
                                 boolean doNotifyListeners)
                          throws IllegalArgumentException
Inserts a column to the model at the specified index.

Parameters:
columnIndex - Index at which to insert the column.
data - Column of data to be inserted.
doNotifyListeners - True if listeners should be notified. False otherwise.
Throws:
IllegalArgumentException - If columnIndex is invalid or data is invalid.
Since:
BlackBerry API 6.0.0

insertColumnAt

public final void insertColumnAt(int columnIndex,
                                 Object data)
                          throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.insertColumnAt(int, Object, boolean)
Since:
BlackBerry API 6.0.0

doInsertColumnAt

protected abstract 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.

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.
Since:
BlackBerry API 6.0.0

insertRowAt

public final void insertRowAt(int rowIndex,
                              Object data,
                              boolean doNotifyListeners)
                       throws IllegalArgumentException
Inserts a row to the model at the specified index.

Parameters:
rowIndex - Index at which to insert the row.
data - Row of data to be inserted.
doNotifyListeners - True if listeners should be notified. False otherwise.
Throws:
IllegalArgumentException - If rowIndex is invalid or data is invalid.
Since:
BlackBerry API 6.0.0

insertRowAt

public final void insertRowAt(int rowIndex,
                              Object data)
                       throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.insertRowAt(int, Object, boolean)
Since:
BlackBerry API 6.0.0

doInsertRowAt

protected abstract 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.

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.
Since:
BlackBerry API 6.0.0

setElement

public final void setElement(int rowIndex,
                             int columnIndex,
                             Object data,
                             boolean doNotifyListeners)
                      throws IllegalArgumentException
Sets the element at specified rowIndex and columnIndex.

Parameters:
rowIndex - Index of row in which to insert.
columnIndex - Index of column in which to insert.
data - Element of data to insert.
doNotifyListeners - True if listeners should be notified. False otherwise.
Throws:
IllegalArgumentException - If rowIndex is invalid or columnIndex is invalid.
Since:
BlackBerry API 6.0.0

setElement

public final void setElement(int rowIndex,
                             int columnIndex,
                             Object data)
                      throws IllegalArgumentException
Throws:
IllegalArgumentException
See Also:
AbstractTableModel.setElement(int, int, Object, boolean)
Since:
BlackBerry API 6.0.0

doSetElement

protected abstract 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.

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.
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.