FileDocCategorySizeDatePackage
BaseTableModel.javaAPI DocApache Lucene 1.93085Mon Feb 20 09:18:14 GMT 2006org.apache.lucene.swing.models

BaseTableModel

public class BaseTableModel extends AbstractTableModel
author
Jonathan Simon - jonathan_s_simon@yahoo.com

Fields Summary
private ArrayList
columnNames
private ArrayList
rows
Constructors Summary
public BaseTableModel(Iterator data)


       
        columnNames.add("Name");
        columnNames.add("Type");
        columnNames.add("Phone");
        columnNames.add("Street");
        columnNames.add("City");
        columnNames.add("State");
        columnNames.add("Zip");

        while (data.hasNext()) {
            Object nextRow = (Object) data.next();
            rows.add(nextRow);
        }
    
Methods Summary
public voidaddRow(RestaurantInfo info)

        rows.add(info);
        fireTableDataChanged();
    
public java.lang.ClassgetColumnClass(int columnIndex)

        return String.class;
    
public intgetColumnCount()

        return columnNames.size();
    
public java.lang.StringgetColumnName(int columnIndex)

        return columnNames.get(columnIndex).toString();
    
public intgetRowCount()

        return rows.size();
    
public java.lang.ObjectgetValueAt(int rowIndex, int columnIndex)

        RestaurantInfo restaurantInfo = (RestaurantInfo) rows.get(rowIndex);
        if (columnIndex == 0){ // name
            return restaurantInfo.getName();
        } else if (columnIndex == 1){ // category
            return restaurantInfo.getType();
        } else if (columnIndex == 2){ // phone
            return restaurantInfo.getPhone();
        } else if (columnIndex == 3){ // street
            return restaurantInfo.getStreet();
        } else if (columnIndex == 4){ // city
            return restaurantInfo.getCity();
        } else if (columnIndex == 5){ // state
            return restaurantInfo.getState();
        } else if (columnIndex == 6){ // zip
            return restaurantInfo.getZip();
        } else {
            return "";
        }
    
public booleanisCellEditable(int rowIndex, int columnIndex)

        return false;
    
public voidremoveRow(RestaurantInfo info)

        rows.remove(info);
        fireTableDataChanged();
    
public voidsetValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)

        //no op