org.mmbase.util
Class QueryConvertor

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

public class QueryConvertor
extends 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.30 2005/10/05 10:44:00 michiel Exp $
Author:
Daniel Ockeloen, Pierre van Rooden (javadocs)
Warning: Will be moved to:
org.mmbase.storage.search.util

Constructor Summary
QueryConvertor()
           
 
Method Summary
static String altaVista2SQL(String query)
          Deprecated. Use setConstraint() to parse these expressions.
static String altaVista2SQL(String query, StorageManagerFactory smf)
          Deprecated. Use setConstraint() to parse these expressions.
static void setConstraint(BasicSearchQuery query, 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
 

Constructor Detail

QueryConvertor

public QueryConvertor()
Method Detail

altaVista2SQL

public static String altaVista2SQL(String query,
                                   StorageManagerFactory smf)
Deprecated. Use setConstraint() to parse these expressions.

Converts query to a SQL "where"-clause.

Parameters:
query - the query to convert
smf - the storagemanagerfactory to use when converting fieldnames

altaVista2SQL

public static String altaVista2SQL(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,
                                 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.8.1.20060716