org.openprivacy.reptile.search.impl
Class DBSearchProvider

java.lang.Object
  |
  +--org.openprivacy.reptile.search.AbstractSearchProvider
        |
        +--org.openprivacy.reptile.search.impl.DBSearchProvider
All Implemented Interfaces:
SearchProvider
Direct Known Subclasses:
ArticleSearchProvider, ChannelSearchProvider, PeerSearchProvider, TaskLogSearchProvider, WeblogSearchProvider

public abstract class DBSearchProvider
extends AbstractSearchProvider

A generic SearchProvider for the local DB. This should contain the default fields and sort order and the Class of the peer to use.

Version:
$Id: DBSearchProvider.java,v 1.8 2002/07/06 05:57:57 burton Exp $
Author:
Kevin A. Burton
See Also:
SearchProvider, AbstractSearchProvider

Field Summary
protected  java.util.List defaultSearchFields
          Default fields for this search provider.
protected  java.util.List defaultSortOrder
          Default sort order for this search provider.
 
Fields inherited from interface org.openprivacy.reptile.search.SearchProvider
STATE_NEVER_SEARCHED, STATE_SEARCH_COMPLETE, STATE_SEARCH_IN_PROGRESS
 
Constructor Summary
DBSearchProvider(java.lang.Class peer)
          Create a new DBSearchProvider instance.
 
Method Summary
protected  java.util.Vector getResults()
          Return the results directly from the search provider for use by class implementations for pulling out records.
 void search(SearchRequest sr)
           Run a search with a given query.
 
Methods inherited from class org.openprivacy.reptile.search.AbstractSearchProvider
assertSearchable, getHandle, getResultCount, getSearchCompletedTime, getSearchRequest, getSearchStartTime, getState, getState, getTimeCreated, isSearchable, setResultCount, setSearchCompletedTime, setSearchRequest, setSearchStartTime, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openprivacy.reptile.search.SearchProvider
destroy, record
 

Field Detail

defaultSearchFields

protected java.util.List defaultSearchFields
Default fields for this search provider.


defaultSortOrder

protected java.util.List defaultSortOrder
Default sort order for this search provider.

Constructor Detail

DBSearchProvider

public DBSearchProvider(java.lang.Class peer)
Create a new DBSearchProvider instance.

Method Detail

search

public void search(SearchRequest sr)
            throws java.lang.Exception
Description copied from interface: SearchProvider

Run a search with a given query. Note that some search providers may NOT finish the search here.. Specifically some search providers may take a few minutes to fill in results as results are collected. A good example of this is code that executes within a P2P network and is waiting or other peers to reply.

Only one 'search' can be run on any search provder. If you wish to run multiple searches you need to instantiate multiple SearchProviders.

If you want to develop a mutltithreaded/asynchronous SearchProvider, you should set the state to STATE_SEARCH_IN_PROGRESS, kick off any threads or async queries an then set the state to STATE_SEARCH_COMPLETE (possibly outside of the search method)

Note that when you are running this method you should synchronize around 'this' object instance. This should only be done int code that could break the search if it is requested to early.

AKA This IS thread reentrant!

SearchProviders also need to pay attention to the SearchRequest and implement any settings here. Specifically we need to pay attention to sort order, search fields, criteria, etc.

java.lang.Exception
See Also:
SearchProvider.search(org.openprivacy.reptile.search.SearchRequest)

getResults

protected java.util.Vector getResults()
Return the results directly from the search provider for use by class implementations for pulling out records.