Package com.groiss.ds
Class ObjectTableModel
java.lang.Object
com.groiss.ds.ObjectTableModel
- All Implemented Interfaces:
TableModel
- Direct Known Subclasses:
ReportingTableModel
A table model implementation that allows objects as column names.
This class is used for presenting tables in HTML using the TableRenderer.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEmpty constructor.ObjectTableModel
(List<?> header) Constructor with header.ObjectTableModel
(List<List<Object>> data, List<?> header) Constructor with data and header. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a row at the bottom of tablemodel.void
This method does nothing.Class<?>
getColumnClass
(int c) Get the class of the column.int
Get the amount of colums of the tablemodel.getColumnHeader
(int c) Returns the header at column c.getColumnName
(int c) Get the name of the Column.getData()
List<?>
Return the header of the table model.int
Get amount of rows in the tablemodel.getValueAt
(int r, int c) Returns the value for the cell at columnIndex and rowIndex.boolean
isCellEditable
(int r, int c) This method returns always true.void
This method does nothing.void
Set the header of the table model.void
setValueAt
(Object val, int r, int c) Sets a cell value in the table model.
-
Field Details
-
header
-
data
-
-
Constructor Details
-
ObjectTableModel
public ObjectTableModel()Empty constructor. -
ObjectTableModel
Constructor with header. Use addRow to add data to the model.- Parameters:
header
-
-
ObjectTableModel
Constructor with data and header.- Parameters:
header
-
-
-
Method Details
-
getRowCount
public int getRowCount()Get amount of rows in the tablemodel.- Specified by:
getRowCount
in interfaceTableModel
-
getColumnCount
public int getColumnCount()Get the amount of colums of the tablemodel.- Specified by:
getColumnCount
in interfaceTableModel
-
getColumnName
Get the name of the Column. If the column name is an object, toString is called on the value.- Specified by:
getColumnName
in interfaceTableModel
- Parameters:
c
- the column index
-
getColumnClass
Get the class of the column. Always return Object.class.- Specified by:
getColumnClass
in interfaceTableModel
-
isCellEditable
public boolean isCellEditable(int r, int c) This method returns always true.- Specified by:
isCellEditable
in interfaceTableModel
-
getValueAt
Returns the value for the cell at columnIndex and rowIndex.- Specified by:
getValueAt
in interfaceTableModel
- Parameters:
r
- the row indexc
- the column index
-
setValueAt
Sets a cell value in the table model.- Specified by:
setValueAt
in interfaceTableModel
- Parameters:
r
- the row indexc
- the column indexval
- the object
-
addTableModelListener
This method does nothing.- Specified by:
addTableModelListener
in interfaceTableModel
-
removeTableModelListener
This method does nothing.- Specified by:
removeTableModelListener
in interfaceTableModel
-
setHeader
Set the header of the table model.- Parameters:
header
- a list of objects
-
addRow
Add a row at the bottom of tablemodel.- Parameters:
row
- the new row
-
getColumnHeader
Returns the header at column c.- Parameters:
c
- the column index- Returns:
- the object representing column header
-
getData
- Returns:
- the data matrix of the tablemodel.
-
getHeader
Return the header of the table model.
-