Package io.guise.framework.model
Class DefaultTableModel
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.model.AbstractModel
-
- io.guise.framework.model.AbstractTableModel
-
- io.guise.framework.model.DefaultTableModel
-
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,Model
,TableModel
public class DefaultTableModel extends AbstractTableModel
The default implementation of a table model. The model is thread-safe, synchronized on itself. Any iteration over values should include synchronization on the instance of this class.- Author:
- Garret Wilson
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.guise.framework.model.TableModel
TableModel.Cell<C>
-
-
Constructor Summary
Constructors Constructor Description DefaultTableModel(TableColumnModel<?>... columns)
Constructs a default table model indicating the type of values it can hold along with column definitions.DefaultTableModel(java.lang.Class<C> valueClass, C[][] rowValues, java.lang.String... columnNames)
Constructs a default table model indicating the type of values it can hold and column names.DefaultTableModel(java.lang.Class<C> valueClass, java.lang.String... columnNames)
Constructs a default table model indicating the type of values it can hold, using default column models.DefaultTableModel(java.lang.Object[][] rowValues, TableColumnModel<?>... columns)
Constructs a default table model indicating the type of values it can hold.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <C> TableColumnModel<C>[]
createDefaultColumns(java.lang.Class<C> valueClass, java.lang.String... columnNames)
Creates default columns with the given column names.<C> C
getCellValue(int rowIndex, TableColumnModel<C> column)
Returns the cell value at the given row and column.int
getRowCount()
<C> void
setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
Sets the cell value at the given row and column.-
Methods inherited from class io.guise.framework.model.AbstractTableModel
addColumn, clearColumns, getCellValue, getColumnCount, getColumnIndex, getColumns, setCellValue
-
Methods inherited from class io.guise.framework.model.AbstractModel
getEventListenerManager, getPlainText
-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
DefaultTableModel
public DefaultTableModel(java.lang.Class<C> valueClass, java.lang.String... columnNames)
Constructs a default table model indicating the type of values it can hold, using default column models.- Type Parameters:
C
- The type of values in all the cells in the table.- Parameters:
valueClass
- The class indicating the type of values held in the model.columnNames
- The names to serve as label headers for the columns.- Throws:
java.lang.NullPointerException
- if the given class object isnull
.
-
DefaultTableModel
public DefaultTableModel(TableColumnModel<?>... columns)
Constructs a default table model indicating the type of values it can hold along with column definitions.- Parameters:
columns
- The models representing the table columns.- Throws:
java.lang.NullPointerException
- if the given class object isnull
.
-
DefaultTableModel
public DefaultTableModel(java.lang.Class<C> valueClass, C[][] rowValues, java.lang.String... columnNames)
Constructs a default table model indicating the type of values it can hold and column names.- Type Parameters:
C
- The type of values in all the cells in the table.- Parameters:
valueClass
- The class indicating the type of values held in the model.rowValues
- The two-dimensional list of values, where the first index represents the row and the second represents the column, ornull
if no default values should be given.columnNames
- The names to serve as label headers for the columns.- Throws:
java.lang.NullPointerException
- if the given class object isnull
.java.lang.IllegalArgumentException
- if the given number of columns does not equal the number of columns in any given data row.
-
DefaultTableModel
public DefaultTableModel(java.lang.Object[][] rowValues, TableColumnModel<?>... columns)
Constructs a default table model indicating the type of values it can hold.- Parameters:
rowValues
- The two-dimensional list of values, where the first index represents the row and the second represents the column, ornull
if no default values should be given.columns
- The models representing the table columns.- Throws:
java.lang.IllegalArgumentException
- if the given number of columns does not equal the number of columns in any given data row.java.lang.ClassCastException
- if one of the values in a row is not compatible with the type of its column.
-
-
Method Detail
-
getRowCount
public int getRowCount()
- Returns:
- The number of rows in this table.
-
createDefaultColumns
public static <C> TableColumnModel<C>[] createDefaultColumns(java.lang.Class<C> valueClass, java.lang.String... columnNames)
Creates default columns with the given column names.- Type Parameters:
C
- The type of values contained in the columns.- Parameters:
valueClass
- The class representing the values contained in the columns.columnNames
- The names to serve as label headers for the columns.- Returns:
- An array of default columns.
-
getCellValue
public <C> C getCellValue(int rowIndex, TableColumnModel<C> column)
Description copied from interface:TableModel
Returns the cell value at the given row and column.- Type Parameters:
C
- The type of cell values in the given column.- Parameters:
rowIndex
- The zero-based row index.column
- The column for which a value should be returned.- Returns:
- The value in the cell at the given row and column, or
null
if there is no value in that cell.
-
setCellValue
public <C> void setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
Description copied from interface:TableModel
Sets the cell value at the given row and column.- Type Parameters:
C
- The type of cell values in the given column.- Parameters:
rowIndex
- The zero-based row index.column
- The column for which a value should be returned.newCellValue
- The value to place in the cell at the given row and column, ornull
if there should be no value in that cell.
-
-