com.infoviz.datamodel.table
Class IVTableModel

java.lang.Object
  extended bycom.infoviz.datamodel.table.IVTableModel

public class IVTableModel
extends java.lang.Object

IVTableModel is a data strucure for tabular data. It provides interfaces to manupulate the table columns, rows and cells. A Caller can attach a listener to the IVTableModel to get notified when the table changes.

$Id$ $Revision$ $Author$


Constructor Summary
IVTableModel(IVTableDefinition ivTableDefinition)
          creates a table from the table definition provided
 
Method Summary
 void addColumn(IVColumnDefinition colDefn, java.util.List rowValues)
          adds a column
 void addListener(IVTableModelListener l)
          add a listener for table change events
 void addRow(java.util.List rowValues)
          adds a new row to the table with the values specified in the given list
 void addRow(java.lang.Object[] rowValues)
          adds a new row with values as specified in the Object array
 java.lang.Object[] getColumnValues(int columnIndex)
          returns the column at the specified index
 java.lang.Object[] getColumnValues(java.lang.String name)
          returns the column with the given name
protected  IVTableDefinition getIVTableDefinition()
          we will not let the users modify the definition once the table is created because we have no way to listen to the changed in the definition.
protected  java.util.List getRows()
          we do not want the API users to modify this List directly, so we make this method protected.
 java.lang.Object[] getRowValues()
          returns all the rows
 java.lang.Object getValueAt(int rowIndex, int colIndex)
          get value of a row, col combination
 void removeColumn(int columnIndex)
          removes a column
 void removeColumn(java.lang.String columnName)
          remove column with the specified name
 void removeRow(int rowIndex)
          removes the row at the given index
 void removeRows(int[] rowIndices)
          removes rows at the given indices
 void setListenersEnabled(boolean flag)
          enables/disables table change notifications to listeners.
 void setValueAt(int rowIndex, int colIndex, java.lang.Object value)
          sets value at a row, column combination
 void updateRow(int[] rowIndices, java.util.List[] rowValues)
          updates a batch of rows
 void updateRow(int index, java.util.List rowValues)
          updates the row
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IVTableModel

public IVTableModel(IVTableDefinition ivTableDefinition)
creates a table from the table definition provided

Parameters:
ivTableDefinition -
Method Detail

getIVTableDefinition

protected IVTableDefinition getIVTableDefinition()
we will not let the users modify the definition once the table is created because we have no way to listen to the changed in the definition. The protected method here helps us in using the table for other classes like QuereableTableModel Note that the addColumnMethod provides a way for the API users to modify the table definition

Returns:

getRows

protected java.util.List getRows()
we do not want the API users to modify this List directly, so we make this method protected. If we let the users modify the list, there is no way we can listen to the modificationa and thus our model will become inconsistent without our knowledge.

Returns:

getRowValues

public java.lang.Object[] getRowValues()
returns all the rows

Returns:
each element of the object array is a row, which is an object array

getColumnValues

public java.lang.Object[] getColumnValues(int columnIndex)
returns the column at the specified index

Parameters:
columnIndex - index of the column
Returns:
object array containing the row values

getColumnValues

public java.lang.Object[] getColumnValues(java.lang.String name)
returns the column with the given name

Parameters:
name - name of the column
Returns:
object array containing the row values

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int colIndex)
get value of a row, col combination

Parameters:
rowIndex - index of row
colIndex - index of column
Returns:
value

setValueAt

public void setValueAt(int rowIndex,
                       int colIndex,
                       java.lang.Object value)
sets value at a row, column combination

Parameters:
rowIndex - index of row
colIndex - index of column
value -

addRow

public void addRow(java.util.List rowValues)
adds a new row to the table with the values specified in the given list

Parameters:
rowValues - each element of the list is the cell value for the corresponding column

addRow

public void addRow(java.lang.Object[] rowValues)
adds a new row with values as specified in the Object array

Parameters:
rowValues -

removeRow

public void removeRow(int rowIndex)
removes the row at the given index

Parameters:
rowIndex - the index of the row

removeRows

public void removeRows(int[] rowIndices)
removes rows at the given indices

Parameters:
rowIndices -

updateRow

public void updateRow(int index,
                      java.util.List rowValues)
updates the row

Parameters:
index - index of the row
rowValues - new values

updateRow

public void updateRow(int[] rowIndices,
                      java.util.List[] rowValues)
updates a batch of rows

Parameters:
rowIndices - rowIndices of the rows
rowValues - new values

addColumn

public void addColumn(IVColumnDefinition colDefn,
                      java.util.List rowValues)
adds a column

Parameters:
colDefn - the column definition
rowValues - row values

removeColumn

public void removeColumn(java.lang.String columnName)
remove column with the specified name

Parameters:
columnName -

removeColumn

public void removeColumn(int columnIndex)
removes a column

Parameters:
columnIndex -

addListener

public void addListener(IVTableModelListener l)
add a listener for table change events

Parameters:
l - the listener

setListenersEnabled

public void setListenersEnabled(boolean flag)
enables/disables table change notifications to listeners. Default is enabled

Parameters:
flag -