org.apache.lucene.swing.models

## Class TableSearcher

- java.lang.Object
- - javax.swing.table.AbstractTableModel
  - - org.apache.lucene.swing.models.TableSearcher

- All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel

      public class TableSearcher
      extends javax.swing.table.AbstractTableModel

  This is a TableModel that encapsulates Lucene search logic within a TableModel implementation. It is implemented as a TableModel decorator, similar to the TableSorter demo from Sun that decorates a TableModel and provides sorting functionality. The benefit of this architecture is that you can decorate any TableModel implementation with this searching table model -- making it easy to add searching functionality to existing JTables -- or making new search capable table lucene.

  This decorator works by holding a reference to a decorated ot inner TableModel. All data is stored within that table model, not this table model. Rather, this table model simply manages links to data in the inner table model according to the search. All methods on TableSearcher forward to the inner table model with subtle filtering or alteration according to the search criteria.

  Using the table model: Pass the TableModel you want to decorate in at the constructor. When the TableModel initializes, it displays all search results. Call the search method with any valid Lucene search String and the data will be filtered by the search string. Users can always clear the search at any time by searching with an empty string. Additionally, you can add a button calling the clearSearch() method.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.swing.table.TableModel` | `tableModel` The inner table model we are decorating

    - ### Fields inherited from class javax.swing.table.AbstractTableModel

      `listenerList`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TableSearcher(javax.swing.table.TableModel tableModel)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Analyzer` | `getAnalyzer()`
    `java.lang.Class` | `getColumnClass(int column)`
    `int` | `getColumnCount()`
    `java.lang.String` | `getColumnName(int column)`
    `int` | `getRowCount()`
    `javax.swing.table.TableModel` | `getTableModel()`
    `java.lang.Object` | `getValueAt(int row, int column)`
    `boolean` | `isCellEditable(int row, int column)`
    `void` | `search(java.lang.String searchString)` Run a new search.
    `void` | `setAnalyzer(Analyzer analyzer)`
    `void` | `setTableModel(javax.swing.table.TableModel tableModel)` Set the table model used by this table model
    `void` | `setValueAt(java.lang.Object aValue, int row, int column)`

    - ### Methods inherited from class javax.swing.table.AbstractTableModel

      `addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### tableModel

          protected javax.swing.table.TableModel tableModel

      The inner table model we are decorating

  - ### Constructor Detail

    - #### TableSearcher

          public TableSearcher(javax.swing.table.TableModel tableModel)

      Parameters:
        `tableModel` - The table model to decorate

  - ### Method Detail

    - #### getTableModel

          public javax.swing.table.TableModel getTableModel()

      Returns:
        The inner table model this table model is decorating

    - #### setTableModel

          public void setTableModel(javax.swing.table.TableModel tableModel)

      Set the table model used by this table model
      Parameters:
        `tableModel` - The new table model to decorate

    - #### getAnalyzer

          public Analyzer getAnalyzer()

      Returns:
        The current lucene analyzer

    - #### setAnalyzer

          public void setAnalyzer(Analyzer analyzer)

      Parameters:
        `analyzer` - The new analyzer to use

    - #### search

          public void search(java.lang.String searchString)

      Run a new search.
      Parameters:
        `searchString` - Any valid lucene search string

    - #### getRowCount

          public int getRowCount()

    - #### getColumnCount

          public int getColumnCount()

    - #### getColumnName

          public java.lang.String getColumnName(int column)

      Specified by:
        `getColumnName` in interface `javax.swing.table.TableModel`
      Overrides:
        `getColumnName` in class `javax.swing.table.AbstractTableModel`

    - #### getColumnClass

          public java.lang.Class getColumnClass(int column)

      Specified by:
        `getColumnClass` in interface `javax.swing.table.TableModel`
      Overrides:
        `getColumnClass` in class `javax.swing.table.AbstractTableModel`

    - #### isCellEditable

          public boolean isCellEditable(int row,
                                        int column)

      Specified by:
        `isCellEditable` in interface `javax.swing.table.TableModel`
      Overrides:
        `isCellEditable` in class `javax.swing.table.AbstractTableModel`

    - #### getValueAt

          public java.lang.Object getValueAt(int row,
                                             int column)

    - #### setValueAt

          public void setValueAt(java.lang.Object aValue,
                                 int row,
                                 int column)

      Specified by:
        `setValueAt` in interface `javax.swing.table.TableModel`
      Overrides:
        `setValueAt` in class `javax.swing.table.AbstractTableModel`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.