JIDE 3.5.15

com.jidesoft.lucene
Class LuceneFilterableListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by com.jidesoft.list.DefaultListModelWrapper
          extended by com.jidesoft.list.FilterableListModel
              extended by com.jidesoft.lucene.LuceneFilterableListModel
All Implemented Interfaces:
IndexChangeEventGenerator, EventFireListModel, ListModelWrapper, Serializable, EventListener, ListDataListener, ListModel

public class LuceneFilterableListModel
extends FilterableListModel

LuceneFilterableListModel is a special FilterableListModel which uses Lucene mechanism to speed up the search.

See Also:
Serialized Form

Field Summary
static String LIST_FIELD_NAME
           
 
Fields inherited from class com.jidesoft.list.FilterableListModel
_filters, _filtersApplied
 
Fields inherited from class com.jidesoft.list.DefaultListModelWrapper
_adjustingIndexes, _indexes, _model
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
LuceneFilterableListModel()
           
LuceneFilterableListModel(ListModel model)
          Creates a FilterableListModel from any list model.
 
Method Summary
 void contentsChanged(ListDataEvent e)
           
protected  String convertElementToString(Object element)
          Convert the element in the list model to string.
protected  String convertFilterToLuceneQueryText(Filter filter)
          Convert Filter to Query text.
protected  void filter()
          Applies filters and generates a new array of indices.
 void fireFilterChanged(FilterableListModelEvent e)
          Forwards the given notification event to all FilterableTableModelListeners that registered themselves as listeners for this list model.
 Document getDocument(int rowIndex)
          Get the document for the row.
 int getDocumentCount()
          Get the total number of available documents.
 void intervalAdded(ListDataEvent e)
           
 void intervalRemoved(ListDataEvent e)
           
 void notifyIndexCreated()
          Notify indexing is finished in LuceneSupport so that it is able to do filtering.
 
Methods inherited from class com.jidesoft.list.FilterableListModel
addFilter, addFilterableListModelListener, addFilters, clearFilters, getFilterableTableModelListeners, getFilters, hasFilter, isAdjusting, isAndMode, isFiltersApplied, refresh, removeFilter, removeFilterableListModelListener, setAdjusting, setAndMode, setFiltersApplied, shouldBeFiltered, shouldBeFiltered
 
Methods inherited from class com.jidesoft.list.DefaultListModelWrapper
addIndexChangeListener, createCompoundListDataEvent, fireEvents, fireIndexChanged, fireListDataEvent, getActualIndexAt, getActualModel, getElementAt, getIndexAt, getIndexChangeListeners, getIndexes, getSize, reallocateIndexes, removeIndexChangeListener, setActualModel, setIndexes
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_FIELD_NAME

public static final String LIST_FIELD_NAME
See Also:
Constant Field Values
Constructor Detail

LuceneFilterableListModel

public LuceneFilterableListModel()

LuceneFilterableListModel

public LuceneFilterableListModel(ListModel model)
Creates a FilterableListModel from any list model.

Parameters:
model - list model
Method Detail

intervalAdded

public void intervalAdded(ListDataEvent e)
Specified by:
intervalAdded in interface ListDataListener
Overrides:
intervalAdded in class FilterableListModel

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Specified by:
intervalRemoved in interface ListDataListener
Overrides:
intervalRemoved in class FilterableListModel

contentsChanged

public void contentsChanged(ListDataEvent e)
Specified by:
contentsChanged in interface ListDataListener
Overrides:
contentsChanged in class FilterableListModel

filter

protected void filter()
Description copied from class: FilterableListModel
Applies filters and generates a new array of indices.

Overrides:
filter in class FilterableListModel

fireFilterChanged

public void fireFilterChanged(FilterableListModelEvent e)
Description copied from class: FilterableListModel
Forwards the given notification event to all FilterableTableModelListeners that registered themselves as listeners for this list model.

Overrides:
fireFilterChanged in class FilterableListModel
Parameters:
e - the event to be forwarded
See Also:
FilterableListModel.addFilterableListModelListener(com.jidesoft.list.FilterableListModelListener), FilterableListModelEvent, EventListenerList

convertFilterToLuceneQueryText

protected String convertFilterToLuceneQueryText(Filter filter)
Convert Filter to Query text.

So far we only converted FieldFilter to Query instances. You can convert your desired filter to query as you wish. If you think you cannot convert the filter you encounter, you'd better return null. Otherwise, you probably will lose some effect from the lost filter.

Parameters:
filter - the filter
Returns:
null if you think this filter is not able to converted to query text in some cases. "" if you want to ignore the filter. Otherwise return a valid string.

convertElementToString

protected String convertElementToString(Object element)
Convert the element in the list model to string.

This method will be invoked by getDocument(int) so that LuceneSupport will have right string to do indexing.

Parameters:
element - the value on the list model
Returns:
the string to be searched on.

getDocument

public Document getDocument(int rowIndex)
Get the document for the row.

This method will be invoked by LuceneSupport so that LuceneSupport have documents to indexing and searching. The document must be row(record) based so that LuceneSupport can return a row index(record number) while searching.

Parameters:
rowIndex - the row index (record number)
Returns:
the document to be indexed.

getDocumentCount

public int getDocumentCount()
Get the total number of available documents.

This method will be invoked by LuceneSupport so that LuceneSupport knows how many documents to be indexed and searched at.

Returns:
the number of the available documents.

notifyIndexCreated

public void notifyIndexCreated()
Notify indexing is finished in LuceneSupport so that it is able to do filtering.

This method will be invoked by LuceneSupport when it finishes indexing. You can put actions like filter() in this method so that it can do the first round lucene searching for you.


JIDE 3.5.15