org.mmbase.util
Class QueryConvertor

java.lang.Object
  extended byorg.mmbase.util.QueryConvertor

public class QueryConvertor
extends java.lang.Object

Class for the converion of a expression string to a SQL where clause. The expressions string is expected to be in 'altavista' format. This means that logical operators are identified by '+' (AND), '-' (NOT), and '|' (OR). Comparative operators are the same as those used in SCAN (i.e. '=E', '=N', etc) A wildcarded strings (with '*' or '?' characters) are automatically converted to a LIKE expression.
The resulting converted expression is preceded with the SQL 'WHERE ' keyword.
Note that if the expression to convert starts with "WHERE", it is not converted at all, but returned as is.

Version:
$Id: QueryConvertor.java,v 1.24 2004/02/09 13:50:35 pierre Exp $
Author:
Daniel Ockeloen, Pierre van Rooden (javadocs)

Field Summary
static MMJdbc2NodeInterface database
          Database used to convert invalid fieldnames (i.e.e keywords) to valid ones.
 
Constructor Summary
QueryConvertor()
           
 
Method Summary
static java.lang.String altaVista2SQL(java.lang.String query)
          Deprecated. Use setConstraint() to parse these expressions.
static java.lang.String altaVista2SQL(java.lang.String query, MMJdbc2NodeInterface db)
          Deprecated. Use setConstraint() to parse these expressions.
static void setConstraint(BasicSearchQuery query, java.lang.String where)
          Sets constraint for a BasicSearchQuery object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

database

public static MMJdbc2NodeInterface database
Database used to convert invalid fieldnames (i.e.e keywords) to valid ones.

Constructor Detail

QueryConvertor

public QueryConvertor()
Method Detail

altaVista2SQL

public static java.lang.String altaVista2SQL(java.lang.String query,
                                             MMJdbc2NodeInterface db)
Deprecated. Use setConstraint() to parse these expressions.

Converts query to a SQL "where"-clause.

Parameters:
query - the query to convert
db - the database to use when converting fieldnames

altaVista2SQL

public static java.lang.String altaVista2SQL(java.lang.String query)
Deprecated. Use setConstraint() to parse these expressions.

Converts query to a SQL "where"-clause.

Parameters:
query - the query to convert

setConstraint

public static void setConstraint(BasicSearchQuery query,
                                 java.lang.String where)
Sets constraint for a BasicSearchQuery object.

The constraint may be specified as either one of these formats:

  1. null or empty.
  2. A SQL search condition, starting with "WHERE " (ignoring case).
  3. A SQL search condition, of the form "WHERE(......)" (ignoring case).
  4. Altavista format.
If the query contains more than one step, the fields must be of the form stepalias.field.

See ConstraintParser for more on how SQL search conditions are supported.

Note: This method is provided to support different constraint formats for backward compatibility (1, 3 and 4 above). Do not call this method directly from new code, but rather use ConstraintParser to parse search constraints.

Parameters:
query - The query.
where - The constraint.
Since:
MMBase-1.7


MMBase build 1.7.1.20041002