com.groiss.ds
Class ObjectTableModel

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

public class ObjectTableModel
extends Object
implements 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  List<List<Object>> data
           
protected  List<?> header
           
 
Constructor Summary
ObjectTableModel()
          Empty constructor.
ObjectTableModel(List<?> header)
          Constructor with header.
ObjectTableModel(List<List<Object>> data, List<?> header)
          Constructor with data and header.
 
Method Summary
 void addRow(List row)
          Add a row at the bottom of tablemodel.
 void addTableModelListener(TableModelListener l)
          This method does nothing.
 Class<?> getColumnClass(int c)
          Get the class of the column.
 int getColumnCount()
          Get the amount of colums of the tablemodel.
 Object getColumnHeader(int c)
          Returns the header at column c.
 String getColumnName(int c)
          Get the name of the Column.
 List<List<Object>> getData()
           
 List<?> getHeader()
          Return the header of the table model.
 int getRowCount()
          Get amount of rows in the tablemodel.
 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(TableModelListener l)
          This method does nothing.
 void setHeader(List<?> header)
          Set the header of the table model.
 void setValueAt(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 List<?> header

data

protected List<List<Object>> data
Constructor Detail

ObjectTableModel

public ObjectTableModel()
Empty constructor.


ObjectTableModel

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

Parameters:
header -

ObjectTableModel

public ObjectTableModel(List<List<Object>> data,
                        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 TableModel

getColumnCount

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

Specified by:
getColumnCount in interface TableModel

getColumnName

public 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 TableModel
Parameters:
c - the column index

getColumnClass

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

Specified by:
getColumnClass in interface TableModel

isCellEditable

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

Specified by:
isCellEditable in interface TableModel

getValueAt

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

Specified by:
getValueAt in interface TableModel
Parameters:
r - the row index
c - the column index

setValueAt

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

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

addTableModelListener

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

Specified by:
addTableModelListener in interface TableModel

removeTableModelListener

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

Specified by:
removeTableModelListener in interface TableModel

setHeader

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

Parameters:
header - a list of objects

addRow

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

Parameters:
row - the new row

getColumnHeader

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

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

getData

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

getHeader

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



@enterprise 8.0.10809 Copyright © 2001-2012 Groiss Informatics GmbH. All Rights Reserved.