001/* TableModel.java -- 002 Copyright (C) 2002, 2005, Free Software Foundation, Inc. 003 004This file is part of GNU Classpath. 005 006GNU Classpath is free software; you can redistribute it and/or modify 007it under the terms of the GNU General Public License as published by 008the Free Software Foundation; either version 2, or (at your option) 009any later version. 010 011GNU Classpath is distributed in the hope that it will be useful, but 012WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014General Public License for more details. 015 016You should have received a copy of the GNU General Public License 017along with GNU Classpath; see the file COPYING. If not, write to the 018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 01902110-1301 USA. 020 021Linking this library statically or dynamically with other modules is 022making a combined work based on this library. Thus, the terms and 023conditions of the GNU General Public License cover the whole 024combination. 025 026As a special exception, the copyright holders of this library give you 027permission to link this library with independent modules to produce an 028executable, regardless of the license terms of these independent 029modules, and to copy and distribute the resulting executable under 030terms of your choice, provided that you also meet, for each linked 031independent module, the terms and conditions of the license of that 032module. An independent module is a module which is not derived from 033or based on this library. If you modify this library, you may extend 034this exception to your version of the library, but you are not 035obligated to do so. If you do not wish to do so, delete this 036exception statement from your version. */ 037 038package javax.swing.table; 039 040import javax.swing.event.TableModelListener; 041 042/** 043 * A <code>TableModel</code> is a two dimensional data structure that 044 * can store arbitrary <code>Object</code> instances, usually for the 045 * purpose of display in a {@link javax.swing.JTable} component. Individual 046 * objects can be accessed by specifying the row index and column index for 047 * the object. Each column in the model has a name associated with it. 048 * <p> 049 * The {@link DefaultTableModel} class provides one implementation of 050 * this interface. 051 * 052 * @author Andrew Selkirk 053 */ 054public interface TableModel 055{ 056 /** 057 * Returns the number of rows in the model. 058 * 059 * @return The row count. 060 */ 061 int getRowCount(); 062 063 /** 064 * Returns the number of columns in the model. 065 * 066 * @return The column count 067 */ 068 int getColumnCount(); 069 070 /** 071 * Returns the name of a column in the model. 072 * 073 * @param columnIndex the column index. 074 * 075 * @return The column name. 076 */ 077 String getColumnName(int columnIndex); 078 079 /** 080 * Returns the <code>Class</code> for all <code>Object</code> instances 081 * in the specified column. 082 * 083 * @param columnIndex the column index. 084 * 085 * @return The class. 086 */ 087 Class<?> getColumnClass(int columnIndex); 088 089 /** 090 * Returns <code>true</code> if the cell is editable, and <code>false</code> 091 * otherwise. 092 * 093 * @param rowIndex the row index. 094 * @param columnIndex the column index. 095 * 096 * @return <code>true</code> if editable, <code>false</code> otherwise. 097 */ 098 boolean isCellEditable(int rowIndex, int columnIndex); 099 100 /** 101 * Returns the value (<code>Object</code>) at a particular cell in the 102 * table. 103 * 104 * @param rowIndex the row index. 105 * @param columnIndex the column index. 106 * 107 * @return The value at the specified cell. 108 */ 109 Object getValueAt(int rowIndex, int columnIndex); 110 111 /** 112 * Sets the value at a particular cell in the table. 113 * 114 * @param aValue the value (<code>null</code> permitted). 115 * @param rowIndex the row index. 116 * @param columnIndex the column index. 117 */ 118 void setValueAt(Object aValue, int rowIndex, int columnIndex); 119 120 /** 121 * Adds a listener to the model. The listener will receive notification 122 * of updates to the model. 123 * 124 * @param listener the listener. 125 */ 126 void addTableModelListener(TableModelListener listener); 127 128 /** 129 * Removes a listener from the model. 130 * 131 * @param listener the listener. 132 */ 133 void removeTableModelListener(TableModelListener listener); 134}