KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > swing > table > TableModelIndexed


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.swing.table;
8
9 import javax.swing.table.TableModel JavaDoc;
10
11 /**
12  * @author Laurent Etiemble
13  * @version $Revision: 1.8 $
14  */

15 public abstract class TableModelIndexed extends TableModelDecorator
16 {
17    /** Description of the Field */
18    protected int[] indexes = new int[0];
19
20
21    /**
22     * Constructor for TableFilter.
23     *
24     * @param model
25     */

26    public TableModelIndexed(TableModel JavaDoc model)
27    {
28       super(model);
29    }
30
31
32    /**
33     * Gets the rowCount attribute of the TableFilter object
34     *
35     * @return The rowCount value
36     */

37    public int getRowCount()
38    {
39       return this.indexes.length;
40    }
41
42
43    /**
44     * Gets the valueAt attribute of the TableFilter object
45     *
46     * @param row Description of the Parameter
47     * @param column Description of the Parameter
48     * @return The valueAt value
49     */

50    public Object JavaDoc getValueAt(int row, int column)
51    {
52       return this.model.getValueAt(this.indexes[row], column);
53    }
54
55
56    /**
57     * @param model The new model value
58     */

59    public void setModel(TableModel JavaDoc model)
60    {
61       super.setModel(model);
62    }
63
64
65    /**
66     * Sets the valueAt attribute of the TableFilter object
67     *
68     * @param newValue The new valueAt value
69     * @param row The new valueAt value
70     * @param column The new valueAt value
71     */

72    public void setValueAt(Object JavaDoc newValue, int row, int column)
73    {
74       this.model.setValueAt(newValue, this.indexes[row], column);
75    }
76
77
78    /**
79     * Description of the Method
80     *
81     * @param i Description of the Parameter
82     * @param j Description of the Parameter
83     */

84    protected void swap(int i, int j)
85    {
86       int tmp = indexes[i];
87       indexes[i] = indexes[j];
88       indexes[j] = tmp;
89    }
90 }
91
Popular Tags