org.mmbase.storage.search.implementation.database.informix.excalibur
Class EtxSqlHandler

java.lang.Object
  extended by org.mmbase.storage.search.implementation.database.ChainedSqlHandler
      extended by org.mmbase.storage.search.implementation.database.informix.excalibur.EtxSqlHandler
All Implemented Interfaces:
SqlHandler

public class EtxSqlHandler
extends ChainedSqlHandler
implements SqlHandler

The Etx query handler adds support for Excalibur Text Search constraints, when used with an Informix database and an Excalibur Text Search datablade. This class is provided as a coding example of a ChainedSqlHandler.

On initialization, the handler reads a list of etx-indices from a configuration file. This configurationfile must be named etxindices.xml and located inside the databases configuration directory. It's dtd is located in the directory org.mmbase.storage.search.implementation.database.informix.excalibur.resources in the MMBase source tree and here online.

Since:
MMBase-1.7
Version:
$Id: EtxSqlHandler.java 34900 2009-05-01 16:29:42Z michiel $
Author:
Rob van Maris

Constructor Summary
EtxSqlHandler(SqlHandler successor)
          Creates a new instance of EtxueryHandler.
 
Method Summary
 void appendConstraintToSql(StringBuilder sb, Constraint constraint, SearchQuery query, boolean inverse, boolean inComposite)
          Represents Constraint object, that is not a CompositeConstraint, as a constraint in SQL format, appending the result to a stringbuffer.
protected  boolean containsOtherStringSearchConstraints(Constraint constraint, StringSearchConstraint searchConstraint)
          Tests if a constaint is/contains another stringsearch constraint than the specified one.
 int getSupportLevel(Constraint constraint, SearchQuery query)
          Gets the level at which a constraint is supported for a query by this handler.
 int getSupportLevel(int feature, SearchQuery query)
          Gets the level at which a feature is supported for a query by this handler.
protected  boolean hasAdditionalConstraints(SearchQuery query)
          Tests if the query contains additional constraints, i.e.
 boolean hasEtxIndex(StepField field)
          Tests if an Excelibur Text Search index has been made for this field.
(package private) static String toBuilderField(String dbTable, String dbField)
          Finds builderfield corresponding to the database table and field names.
 
Methods inherited from class org.mmbase.storage.search.implementation.database.ChainedSqlHandler
appendQueryBodyToSql, getAllowedValue, getSuccessor, toSql
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.storage.search.implementation.database.SqlHandler
appendQueryBodyToSql, getAllowedValue, toSql
 

Constructor Detail

EtxSqlHandler

public EtxSqlHandler(SqlHandler successor)
              throws IOException
Creates a new instance of EtxueryHandler.

Parameters:
successor - Successor in chain or responsibility.
Throws:
IOException
Method Detail

appendConstraintToSql

public void appendConstraintToSql(StringBuilder sb,
                                  Constraint constraint,
                                  SearchQuery query,
                                  boolean inverse,
                                  boolean inComposite)
                           throws SearchQueryException
Description copied from interface: SqlHandler
Represents Constraint object, that is not a CompositeConstraint, as a constraint in SQL format, appending the result to a stringbuffer. When it is part of a composite expression, it will be surrounded by parenthesis when needed.

Specified by:
appendConstraintToSql in interface SqlHandler
Overrides:
appendConstraintToSql in class ChainedSqlHandler
Parameters:
sb - The stringbuffer to append to.
constraint - The (non-composite) constraint.
query - The searchquery containing the constraint.
inverse - True when the inverse constraint must be represented, false otherwise.
inComposite - True when the constraint is part of a composite expression.
Throws:
SearchQueryException

getSupportLevel

public int getSupportLevel(int feature,
                           SearchQuery query)
                    throws SearchQueryException
Description copied from interface: SqlHandler
Gets the level at which a feature is supported for a query by this handler. This is one of either: Given the choice, the query handler with the highest level of support is prefered.

Specified by:
getSupportLevel in interface SqlHandler
Overrides:
getSupportLevel in class ChainedSqlHandler
Throws:
SearchQueryException

getSupportLevel

public int getSupportLevel(Constraint constraint,
                           SearchQuery query)
                    throws SearchQueryException
Description copied from interface: SqlHandler
Gets the level at which a constraint is supported for a query by this handler. This is one of either: Given the choice, the query handler with the highest level of support is prefered.

Specified by:
getSupportLevel in interface SqlHandler
Overrides:
getSupportLevel in class ChainedSqlHandler
Throws:
SearchQueryException

hasEtxIndex

public boolean hasEtxIndex(StepField field)
Tests if an Excelibur Text Search index has been made for this field.

Parameters:
field - the field.
Returns:
true if an Excelibur Text Search index has been made for this field, false otherwise.

hasAdditionalConstraints

protected boolean hasAdditionalConstraints(SearchQuery query)
Tests if the query contains additional constraints, i.e. on relations or nodes.

Parameters:
query - the query.
Returns:
true if the query containts additional constraints, false otherwise.

containsOtherStringSearchConstraints

protected boolean containsOtherStringSearchConstraints(Constraint constraint,
                                                       StringSearchConstraint searchConstraint)
Tests if a constaint is/contains another stringsearch constraint than the specified one. Recursively seaches through all childs of composite constraints.

Parameters:
constraint - the constraint.
searchConstraint - the stringsearch constraint.
Returns:
true if the constraint is/contains another stringsearch constraint than the given one, false otherwise.

toBuilderField

static String toBuilderField(String dbTable,
                             String dbField)
Finds builderfield corresponding to the database table and field names.

Parameters:
dbTable - The tablename used in the database.
dbField - The fieldname used in the database.
Returns:
The corresponding builderfield represented by a string of the form <buildername>.<fieldname>.
Throws:
IllegalArgumentException - when an invalid argument is supplied.


MMBase 2.0-SNAPSHOT - null