KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
10
11 import javax.swing.table.TableModel JavaDoc;
12
13 /**
14  * @author Laurent Etiemble
15  * @version $Revision: 1.8 $
16  */

17 public class TableModelMatchFilter extends TableModelFilter
18 {
19    /** Description of the Field */
20    protected ArrayList JavaDoc tempIndexes = new ArrayList JavaDoc();
21
22
23    /**
24     * Constructor for TableModelMatchFilter.
25     *
26     * @param model
27     */

28    public TableModelMatchFilter(TableModel JavaDoc model)
29    {
30       super(model);
31    }
32
33
34    /** */
35    public synchronized void filter()
36    {
37       this.tempIndexes.clear();
38       int rows = this.model.getRowCount();
39
40       if (this.column < 0)
41       {
42          for (int row = 0; row < rows; row++)
43          {
44             this.tempIndexes.add(new Integer JavaDoc(row));
45          }
46       }
47       else
48       {
49          for (int row = 0; row < rows; row++)
50          {
51             Object JavaDoc value = model.getValueAt(row, column);
52             for (int i = 0; i < values.length; i++)
53             {
54                if (values[i].equals(value))
55                {
56                   tempIndexes.add(new Integer JavaDoc(row));
57                }
58             }
59          }
60       }
61
62       this.indexes = new int[this.tempIndexes.size()];
63       for (int i = 0; i < this.indexes.length; i++)
64       {
65          this.indexes[i] = ((Integer JavaDoc) this.tempIndexes.get(i)).intValue();
66       }
67    }
68 }
69
Popular Tags