Package com.groiss.ds

Class ObjectTableModel

java.lang.Object
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 Details

  • Constructor Details

    • 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 Details

    • 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.