Class SearchContentFilter

java.lang.Object
org.biojava.bio.search.SearchContentFilter
All Implemented Interfaces:
SearchContentHandler

public class SearchContentFilter extends Object implements SearchContentHandler

Filtering implementation of SearchContentHandler that by default passes all messages on to the next delegate in the chain.

In this handler, all info will be passed onto a delegate handler. You can build up a chain of filters by using one filter as the delegate for another. When you over-ride a method in a filter, you can modify any state you wish. If you want that to propogate on, you should call the method on yourself via super.(), if not, just return.

It is your responsibility to ensure that the events emitted from your filter are sensible. In particular, start/end messages must be paired even after filtering.

Example

 // we have a handler from somewhere
 SearchContentHandler handler = ...;

 // now we are going to mutate all "score" notifications to Double instances
 // from strings
 SearchContentHandler filter = new SearchContentFilter() {
   public void addHitProperty(Object key, Object value) {
     if("score".equals(key)) {
       if(value instanceof String) {
         value = new Double(value);
       }
     }
     super(key, value);
   }
 };
 
Since:
1.3
Author:
Matthew Pocock
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The addHitProperty method adds a key/value pair containing some property of a particular hit.
    void
    The addSearchProperty method adds a key/value pair containing some property of the overall search result.
    void
    The addSubHitProperty method adds a key/value pair containing some property of a particular subhit.
    void
    The endHeader method indicates the end of a formatted header.
    void
    The endHit method indicates the end of a formatted hit.
    void
    The endSearch method indicates the end of useful search information.
    void
    The endSubHit method indicates the end of a formatted subhit.
    boolean
    getMoreSearches returns the state of the SearchContentHandler with respect to further searches from its data source.
    void
    setDatabaseID(String databaseID)
    setDatabaseID identifies the database searched by a name, ID or URN.
    void
    setMoreSearches(boolean val)
    setMoreSearches sets the state of the SearchContentHandler's expectation of receiving more results.
    void
    setQueryID(String queryID)
    setQueryID identifies the query sequence by a name, ID or URN.
    void
    The startHeader method indicates the start of a formatted header.
    void
    The startHit method indicates the start of a formatted hit.
    void
    The startSearch method indicates the start of useful search information.
    void
    The startSubHit method indicates the start of a formatted subhit.

    Methods inherited from class java.lang.Object

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