org.mmbase.storage.search.legacy
Class QueryConvertor

java.lang.Object
  extended by org.mmbase.storage.search.legacy.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 41856 2010-04-12 16:29:03Z michiel $
Author:
Daniel Ockeloen, Pierre van Rooden (javadocs)

Field Summary
(package private) static StorageManagerFactory<?> factory
           
 
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
 

Field Detail

factory

static StorageManagerFactory<?> factory
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 2.0-SNAPSHOT - null