bill.util.gui
Class TableModelCSV

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--bill.util.gui.TableModelCSV
All Implemented Interfaces:
Serializable, TableModel

public class TableModelCSV
extends AbstractTableModel

Table model for a JTable that bases it's data on a CSV file.

See Also:
Serialized Form

Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableModelCSV(CSVParser parser)
          Creates a class instance using the specified CSV parser.
 
Method Summary
 int getColumnCount()
          Determines the number of columns to display in th the JTable by checking how many columns their are in the CSV header.
 String getColumnName(int columnIndex)
          Determines the name of a particular column by retriving the CSV header line's value for the specified column.
 CSVParser getParser()
          Retrieves the table model's CSV parser.
 int getRowCount()
          Determines the number of rows of CSV data we have to display.
 Object getValueAt(int rowIndex, int columnIndex)
          Retrieves the value of a particular column for a specific line.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Checks if the specified cell can be editted.
 void setParser(CSVParser parser)
          Sets the table model's CSV parser.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          Sets the value of a particular table cell.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableModelCSV

public TableModelCSV(CSVParser parser)
Creates a class instance using the specified CSV parser.
Parameters:
parser - The CSV parser to base the table model's behavior on.
Method Detail

setParser

public void setParser(CSVParser parser)
Sets the table model's CSV parser.
Parameters:
parser - The CSV parser to base the table model's behavior on.

getParser

public CSVParser getParser()
Retrieves the table model's CSV parser.
Returns:
The CSV parser the table model's behavior is based on.

getColumnCount

public int getColumnCount()
Determines the number of columns to display in th the JTable by checking how many columns their are in the CSV header.
Overrides:
getColumnCount in class AbstractTableModel
Returns:
The number of columns to display in the table.

getColumnName

public String getColumnName(int columnIndex)
Determines the name of a particular column by retriving the CSV header line's value for the specified column.
Overrides:
getColumnName in class AbstractTableModel
Parameters:
columnIndex - The 0 based index of the column to retrieve the name of.
Returns:
The name of the requested column.

getRowCount

public int getRowCount()
Determines the number of rows of CSV data we have to display.
Overrides:
getRowCount in class AbstractTableModel
Returns:
The number of rows of data.

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Retrieves the value of a particular column for a specific line.
Overrides:
getValueAt in class AbstractTableModel
Parameters:
rowIndex - The 0 based row (line) number to get the value from.
columnIndex - The 0 based column number to get from the line.
Returns:
The value from the specified row and column.

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Checks if the specified cell can be editted.
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
rowIndex - The 0 based row (line) number to check for editability.
columnIndex - The 0 based column number to check for editability.
Returns:
At this level we always return true.

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value of a particular table cell.
Overrides:
setValueAt in class AbstractTableModel
Parameters:
aValue - The value to set the specified cell to.
rowIndex - The 0 based row (line) number to set the value for.
columnIndex - The 0 based column number to set for the line.