import javax.swing.table.AbstractTableModel;


public class JayTableModel extends AbstractTableModel{
	
	private String[] listofNames = null;
	private String title = null;
        private int numRules = 0;
	
	public JayTableModel(String[] listofNames, String title, final int numValidRules)
	{
		this.listofNames = listofNames;
		this.title = title;		
                this.numRules = numValidRules;
	}
	
	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getColumnCount()
	 */
	public int getColumnCount() {
		return 1;
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getRowCount()
	 */
	public int getRowCount() {
		//return listofNames.length;
		return numRules;
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getValueAt(int, int)
	 */
	public Object getValueAt(int row, int col) {
		return listofNames[row];
	}
	
	/**
	 *  returns the name of a specific column
	 *  
	 *  @param col the column index
	 *  @return column name
	 */
	public String getColumnName(int col) {
        return title;
    }

	 /*
     * JTable uses this method to determine the default renderer/
     * editor for each cell.  If we didn't implement this method,
     * then the last column would contain text ("true"/"false"),
     * rather than a check box.
     */
    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    /*
     * Don't need to implement this method unless your table's
     * editable.
     */
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        return false;
    }

}
