Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.table
Class ListTableModelWrapper

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.citra.table.TableMap
          extended by com.citra.table.ListTableModelWrapper
All Implemented Interfaces:
ReorderListener, ListTableModel, ReorderModel, Serializable, EventListener, TableModelListener, TableModel

public class ListTableModelWrapper
extends TableMap
implements ListTableModel

ListTableModelWrapper provides a wrapping for any TableModel class. This is sometimes required for providing sorting and/or filtering capabilities to a TableModel that does not implement the ListTableModel interface. For example, having tableModel as the original table model:

ListTableModelWrapper wrapper = new ListTableModelWrapper(tableModel);
FilterTableModel ftm = new FilterTableModel(wrapper);
SortTableModel stm = new SortTableModel(ftm);
JTable table = new AdvancedJTable(stm);
stm.setHeader(table.getTableHeader());

Note that the extra ListTableModel methods that are implemented will throw an UnsupportedOperationException (if throwsException is true), with the exclusion of getRows() that returns null.

See Also:
Serialized Form

Field Summary
protected  boolean throwsException
          flag that indicates that an exception will be thrown when the ListTableModel methods are called.
 
Fields inherited from class com.citra.table.TableMap
tableModel
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ListTableModelWrapper(TableModel model)
          Constructs a ListTableModelWrapper.
 
Method Summary
 void addRow(Object row)
          This method throws an UnsupportedOperationException.
 void addRows(List addedRows)
          This method throws an UnsupportedOperationException.
 void clear()
          This method throws an UnsupportedOperationException.
 Object getCellValue(Object row, int index)
          This method throws an UnsupportedOperationException.
 List getRows()
          This method returns null.
 boolean getThrowsException()
          Determines the behaviour of the model when the ListTableModel methods are called.
 void removeRow(int row)
          This method throws an UnsupportedOperationException.
 void removeRows(int[] deletedRows)
          This method throws an UnsupportedOperationException.
 void setThrowsException(boolean throwsException)
          Assigns the behaviour of the model when the ListTableModel methods are called.
 
Methods inherited from class com.citra.table.TableMap
addReorderListener, fireRowsMapped, fireRowsReordered, getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, getValueAt, isCellEditable, removeReorderListener, rowsReordered, setModel, setValueAt, tableChanged
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.citra.table.ListTableModel
fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 

Field Detail

throwsException

protected boolean throwsException
flag that indicates that an exception will be thrown when the ListTableModel methods are called.

Constructor Detail

ListTableModelWrapper

public ListTableModelWrapper(TableModel model)
Constructs a ListTableModelWrapper.

Method Detail

addRow

public void addRow(Object row)
This method throws an UnsupportedOperationException. Adds a row to the end of the model.

Specified by:
addRow in interface ListTableModel
Parameters:
row - the row being added

addRows

public void addRows(List addedRows)
This method throws an UnsupportedOperationException. Adds a list of rows to the end of the model.

addedRows contains objects representing the actual rows being added. e.g. Vector, for DefaultTableModel.

Specified by:
addRows in interface ListTableModel
Parameters:
addedRows - the rows being added.

clear

public void clear()
This method throws an UnsupportedOperationException. Clears the model of any data.

Specified by:
clear in interface ListTableModel

getCellValue

public Object getCellValue(Object row,
                           int index)
This method throws an UnsupportedOperationException. Returns the Object found at index of row passed as a parameter.

Specified by:
getCellValue in interface ListTableModel
Parameters:
row - the row data
index - an index
Returns:
the object found at column index of the row data row

getRows

public List getRows()
This method returns null. Returns the data of this tablemodel

Specified by:
getRows in interface ListTableModel
Returns:
the rows of the datamodel as a List

getThrowsException

public boolean getThrowsException()
Determines the behaviour of the model when the ListTableModel methods are called. The default value is true.

Returns:
true if an exception should be thrown when the ListTableModel methods are called

removeRow

public void removeRow(int row)
This method throws an UnsupportedOperationException. Removes a row from the data model

Specified by:
removeRow in interface ListTableModel
Parameters:
row - the index of the row being removed

removeRows

public void removeRows(int[] deletedRows)
This method throws an UnsupportedOperationException. Removes a few rows from the data model

Specified by:
removeRows in interface ListTableModel
Parameters:
deletedRows - an integer array that contains indexes of the rows being deleted

setThrowsException

public void setThrowsException(boolean throwsException)
Assigns the behaviour of the model when the ListTableModel methods are called. The default value is true.

Parameters:
throwsException - true if an exception should be thrown when the ListTableModel methods are called

Copyright © 2011 Citra Technologies. All Rights Reserved.