no.sesat.search.mode.command.querybuilder
Class BaseFilterBuilder

java.lang.Object
  extended by no.sesat.commons.visitor.AbstractReflectionVisitor
      extended by no.sesat.search.mode.command.querybuilder.AbstractQueryBuilder
          extended by no.sesat.search.mode.command.querybuilder.BaseFilterBuilder
All Implemented Interfaces:
no.sesat.commons.visitor.Visitor, FilterBuilder, QueryBuilder
Direct Known Subclasses:
FastAdvancedFilterBuilder, FastSimpleFilterBuilder

public class BaseFilterBuilder
extends AbstractQueryBuilder
implements FilterBuilder

Visitor to create the filter string. Extracts filters from the query that have been defined, in modes.xml//modes/mode/search-command@field-filters, to be passed through to the backend. The filter are removed from the QueryBuilder.getQueryString due to the InitialisationQueryTransformer. For example handles the site: syntax. The default output uses a colon : to join field to the term, and prefixes the pair with the plus sign + For example: +site:vg.no The " +" is defined as the deliminator, and is provided by getDelim() if a subclass wishes to alter just this.

Version:
$Id: BaseFilterBuilder.java 7225 2009-04-09 00:32:20Z ssmiweve $

Nested Class Summary
 
Nested classes/interfaces inherited from interface no.sesat.search.mode.command.querybuilder.QueryBuilder
QueryBuilder.Context
 
Field Summary
 
Fields inherited from class no.sesat.commons.visitor.AbstractReflectionVisitor
VISIT_METHOD_IMPL
 
Constructor Summary
BaseFilterBuilder(QueryBuilder.Context cxt, QueryBuilderConfig config)
           
 
Method Summary
 void addFilter(String field, String value)
          Default format is to apend filters like "field:value".
protected  void appendFilter(LeafClause clause)
           
protected  String getDelim()
           
 String getFilter(String string)
          Find a particular filter value.
 String getFilterString()
          The Filter String built from the Query's transformed clauses.
protected  boolean isEmptyLeaf(Clause clause)
          Override logic.
protected  void visitImpl(AndNotClause clause)
           
protected  void visitImpl(BinaryClause clause)
           
protected  void visitImpl(LeafClause clause)
           
protected  void visitImpl(NotClause clause)
           
protected  void visitImpl(PhraseClause clause)
           
 
Methods inherited from class no.sesat.search.mode.command.querybuilder.AbstractQueryBuilder
appendToQueryRepresentation, appendToQueryRepresentation, escape, getConfig, getContext, getEscapedTransformedTerm, getQueryRepresentationLength, getQueryString, getWordsToEscape, insertToQueryRepresentation, isNextLeafInsideNotClause, visitImpl
 
Methods inherited from class no.sesat.commons.visitor.AbstractReflectionVisitor
visit, visitImpl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface no.sesat.search.mode.command.querybuilder.QueryBuilder
getQueryString
 
Methods inherited from interface no.sesat.commons.visitor.Visitor
visit
 

Constructor Detail

BaseFilterBuilder

public BaseFilterBuilder(QueryBuilder.Context cxt,
                         QueryBuilderConfig config)
Method Detail

addFilter

public void addFilter(String field,
                      String value)
Default format is to apend filters like "field:value". Add a filter. Where field is blank an anonymous filter will be added.

Specified by:
addFilter in interface FilterBuilder

getFilterString

public String getFilterString()
Description copied from interface: FilterBuilder
The Filter String built from the Query's transformed clauses. The filter string consists of key-value pairs usually represented key:value. The Query parser refers to these pairs as fielded clauses. By default will delegate to getQueyString()

Specified by:
getFilterString in interface FilterBuilder
Returns:
string built from the Query's transformed clauses, or "".

getFilter

public String getFilter(String string)
Find a particular filter value. When looking for a matching filter any leading QueryParser.OPERATORS to field names in the filter string are ignored.

Specified by:
getFilter in interface FilterBuilder
Parameters:
string - the filter (or field) name
Returns:
the filter's (or field's) value. space separated if multiple values exist.

visitImpl

protected void visitImpl(LeafClause clause)

visitImpl

protected void visitImpl(PhraseClause clause)

visitImpl

protected void visitImpl(BinaryClause clause)

visitImpl

protected void visitImpl(NotClause clause)

visitImpl

protected void visitImpl(AndNotClause clause)

appendFilter

protected void appendFilter(LeafClause clause)

isEmptyLeaf

protected boolean isEmptyLeaf(Clause clause)
Override logic. Almost an inversion since the QueryBuilder hides fielded filters and the FilterBuilder includes them.

Overrides:
isEmptyLeaf in class AbstractQueryBuilder
Parameters:
clause -
Returns:

getDelim

protected String getDelim()


Copyright © 2005-2009 Schibsted ASA. All Rights Reserved.