com.groiss.ds
Class ObjectTableModel

java.lang.Object
  extended by com.groiss.ds.ObjectTableModel
All Implemented Interfaces:
javax.swing.table.TableModel
Direct Known Subclasses:
ReportingTableModel

public class ObjectTableModel
extends java.lang.Object
implements javax.swing.table.TableModel

A table model implementation that allows objects as column names. This class is used for presenting tables in HTML using the TableRenderer.


Field Summary
protected  java.util.List<java.util.List<java.lang.Object>> data
           
protected  java.util.List<?> header
           
 
Constructor Summary
ObjectTableModel()
          Empty constructor.
ObjectTableModel(java.util.List<?> header)
          Constructor with header.
ObjectTableModel(java.util.List<java.util.List<java.lang.Object>> data, java.util.List<?> header)
          Constructor with data and header.
 
Method Summary
 void addRow(java.util.List row)
          Add a row at the bottom of tablemodel.
 void addTableModelListener(javax.swing.event.TableModelListener l)
          This method does nothing.
 java.lang.Class<?> getColumnClass(int c)
          Get the class of the column.
 int getColumnCount()
          Get the amount of colums of the tablemodel.
 java.lang.Object getColumnHeader(int c)
          Returns the header at column c.
 java.lang.String getColumnName(int c)
          Get the name of the Column.
 java.util.List<java.util.List<java.lang.Object>> getData()
           
 java.util.List<?> getHeader()
          Return the header of the table model.
 int getRowCount()
          Get amount of rows in the tablemodel.
 java.lang.Object 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 removeTableModelListener(javax.swing.event.TableModelListener l)
          This method does nothing.
 void setHeader(java.util.List<?> header)
          Set the header of the table model.
 void setValueAt(java.lang.Object val, int r, int c)
          Sets a cell value in the table model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

header

protected java.util.List<?> header

data

protected java.util.List<java.util.List<java.lang.Object>> data
Constructor Detail

ObjectTableModel

public ObjectTableModel()
Empty constructor.


ObjectTableModel

public ObjectTableModel(java.util.List<?> header)
Constructor with header. Use addRow to add data to the model.

Parameters:
header -

ObjectTableModel

public ObjectTableModel(java.util.List<java.util.List<java.lang.Object>> data,
                        java.util.List<?> header)
Constructor with data and header.

Parameters:
header -
Method Detail

getRowCount

public int getRowCount()
Get amount of rows in the tablemodel.

Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Get the amount of colums of the tablemodel.

Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int c)
Get the name of the Column. If the column name is an object, toString is called on the value.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Parameters:
c - the column index

getColumnClass

public java.lang.Class<?> getColumnClass(int c)
Get the class of the column. Always return Object.class.

Specified by:
getColumnClass in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int r,
                              int c)
This method returns always true.

Specified by:
isCellEditable in interface javax.swing.table.TableModel

getValueAt

public java.lang.Object getValueAt(int r,
                                   int c)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
r - the row index
c - the column index

setValueAt

public void setValueAt(java.lang.Object val,
                       int r,
                       int c)
Sets a cell value in the table model.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Parameters:
r - the row index
c - the column index
val - the object

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
This method does nothing.

Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
This method does nothing.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

setHeader

public void setHeader(java.util.List<?> header)
Set the header of the table model.

Parameters:
header - a list of objects

addRow

public void addRow(java.util.List row)
Add a row at the bottom of tablemodel.

Parameters:
row - the new row

getColumnHeader

public java.lang.Object getColumnHeader(int c)
Returns the header at column c.

Parameters:
c - the column index
Returns:
the object representing column header

getData

public java.util.List<java.util.List<java.lang.Object>> getData()
Returns:
the data matrix of the tablemodel.

getHeader

public java.util.List<?> getHeader()
Return the header of the table model.



@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.