org.openprivacy.reptile.search.impl
Class ArticleSearchProvider

java.lang.Object
  |
  +--org.openprivacy.reptile.search.AbstractSearchProvider
        |
        +--org.openprivacy.reptile.search.impl.ArticleSearchProvider
All Implemented Interfaces:
SearchProvider

public class ArticleSearchProvider
extends AbstractSearchProvider

Handles searching articles in the OM database article store.

Version:
$Id: ArticleSearchProvider.java,v 1.8 2002/02/06 21:48:16 burton Exp $
Author:
Kevin A. Burton
See Also:
SearchProvider, AbstractSearchProvider

Fields inherited from interface org.openprivacy.reptile.search.SearchProvider
STATE_NEVER_SEARCHED, STATE_SEARCH_COMPLETE, STATE_SEARCH_IN_PROGRESS
 
Constructor Summary
ArticleSearchProvider()
           
 
Method Summary
 void destroy()
           Called before garbage collection by the SearchProviderGCThread.
 void record(SearchRecord record)
           Get the given SearchRecord from this SearchProvider.
 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
 

Constructor Detail

ArticleSearchProvider

public ArticleSearchProvider()
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.

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

record

public void record(SearchRecord record)
            throws java.lang.Exception
Description copied from interface: SearchProvider

Get the given SearchRecord from this SearchProvider.

It is important that all SearchProviders implement this method correctly.

The given implementation needs to fill in all necessary information into this SearchRecord, this includes the title, description, etc.

Note. This is basically a visitor pattern. Callers use a search provider and then fetch a record from the SearchProvider by index.

Throws:
java.lang.Exception - When an invalid SearchRecord index is used
See Also:
SearchProvider.record(org.openprivacy.reptile.search.SearchRecord)

destroy

public void destroy()
Description copied from interface: SearchProvider

Called before garbage collection by the SearchProviderGCThread. If your search provider needs to perform any garbage collection it should do so here.

If your SearchProvider has executed an asynchronous query, it should abort this before returning.

See Also:
SearchProvider.destroy()