org.mmbase.storage.search.implementation.database
Class MySqlSqlHandler

java.lang.Object
  extended by org.mmbase.storage.search.implementation.database.BasicSqlHandler
      extended by org.mmbase.storage.search.implementation.database.MySqlSqlHandler
All Implemented Interfaces:
SqlHandler

public class MySqlSqlHandler
extends BasicSqlHandler
implements SqlHandler

The MySQL query handler, implements SqlHandler for standard MySQL functionality.
Derived from BasicSqlHandler, overrides

Since:
MMBase-1.7
Version:
$Id: MySqlSqlHandler.java 36317 2009-06-23 14:19:19Z michiel $
Author:
Rob van Maris

Constructor Summary
MySqlSqlHandler()
          Constructor.
 
Method Summary
protected  void appendDateField(StringBuilder sb, Step step, String fieldName, boolean multipleSteps, int datePart)
           
protected  StringBuilder appendLikeOperator(StringBuilder sb, FieldConstraint constraint)
          Appends the 'LIKE' operator for the given case sensitiviy.
protected  String appendPreField(StringBuilder sb, FieldConstraint constraint, StepField field, boolean multiple)
           
protected  StringBuilder appendRegularExpressionOperator(StringBuilder sb, FieldConstraint constraint)
           
protected  StringBuilder appendSortOrderField(StringBuilder sb, SortOrder sortOrder, boolean multipleSteps)
           
protected  DataType getDataType(StepField field)
           
protected  CoreField getField(StepField field)
           
 int getSupportLevel(int feature, SearchQuery query)
          Gets the level at which a feature is supported for a query by this handler.
protected  boolean isCaseSensitive(DataType dt)
           
 String toSql(SearchQuery query, SqlHandler firstInChain)
          Represents a SearchQuery object as a string in SQL format, using the database configuration.
protected  String toSqlString(String str)
          Utility method, modifies strings for use in SQL statements.
protected  boolean useLower(FieldConstraint constraint)
          Wether the 'LOWER' function needs to be used to implement case insensitivity.
 
Methods inherited from class org.mmbase.storage.search.implementation.database.BasicSqlHandler
appendCompositeConstraintToSql, appendConstraintToSql, appendDateValue, appendField, appendField, appendField, appendFieldValue, appendLowerField, appendQueryBodyToSql, appendRelationConstraints, appendSortOrderDirection, appendSortOrderField, appendSortOrders, appendTableAlias, appendTableName, forceEncode, getAllowedValue, getSupportLevel
 
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
appendConstraintToSql, appendQueryBodyToSql, getAllowedValue, getSupportLevel
 

Constructor Detail

MySqlSqlHandler

public MySqlSqlHandler()
Constructor.

Method Detail

toSqlString

protected String toSqlString(String str)
Description copied from class: BasicSqlHandler
Utility method, modifies strings for use in SQL statements. This amounts to replacing all single quotes by two single quotes.

Overrides:
toSqlString in class BasicSqlHandler
Parameters:
str - The input string.
Returns:
The modified string.

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 BasicSqlHandler
Throws:
SearchQueryException

getField

protected CoreField getField(StepField field)

getDataType

protected DataType getDataType(StepField field)

isCaseSensitive

protected boolean isCaseSensitive(DataType dt)

useLower

protected boolean useLower(FieldConstraint constraint)
Description copied from class: BasicSqlHandler
Wether the 'LOWER' function needs to be used to implement case insensitivity. This is not always the case, because some database only match case insensitively, in which case it does not make sense to lowercase.

Overrides:
useLower in class BasicSqlHandler

appendPreField

protected String appendPreField(StringBuilder sb,
                                FieldConstraint constraint,
                                StepField field,
                                boolean multiple)
Overrides:
appendPreField in class BasicSqlHandler
Since:
MMBase-1.9.2

appendLikeOperator

protected StringBuilder appendLikeOperator(StringBuilder sb,
                                           FieldConstraint constraint)
Description copied from class: BasicSqlHandler
Appends the 'LIKE' operator for the given case sensitiviy. Some databases support a case insensitive LIKE ('ILIKE'). Implementations for those database can override this method.

Overrides:
appendLikeOperator in class BasicSqlHandler
Returns:
The string buffer.

appendRegularExpressionOperator

protected StringBuilder appendRegularExpressionOperator(StringBuilder sb,
                                                        FieldConstraint constraint)
Overrides:
appendRegularExpressionOperator in class BasicSqlHandler

appendDateField

protected void appendDateField(StringBuilder sb,
                               Step step,
                               String fieldName,
                               boolean multipleSteps,
                               int datePart)
Overrides:
appendDateField in class BasicSqlHandler
Javadoc:

appendSortOrderField

protected StringBuilder appendSortOrderField(StringBuilder sb,
                                             SortOrder sortOrder,
                                             boolean multipleSteps)
Overrides:
appendSortOrderField in class BasicSqlHandler

toSql

public String toSql(SearchQuery query,
                    SqlHandler firstInChain)
             throws SearchQueryException
Description copied from interface: SqlHandler
Represents a SearchQuery object as a string in SQL format, using the database configuration.

Specified by:
toSql in interface SqlHandler
Overrides:
toSql in class BasicSqlHandler
Parameters:
query - The searchquery.
firstInChain - The first element in the chain of handlers. At some point appendQueryBodyToSql() will have to be called on this handler, to generate the body of the query.
Returns:
SQL string representation of the query.
Throws:
SearchQueryException


MMBase 2.0-SNAPSHOT - null