org.makumba.providers.query.mql
Class MqlQueryAnalysis

java.lang.Object
  extended by org.makumba.providers.query.mql.MqlQueryAnalysis
All Implemented Interfaces:
QueryAnalysis

public class MqlQueryAnalysis
extends Object
implements QueryAnalysis


Field Summary
static Pattern patternInSet
           
static String regExpInSET
           
 
Constructor Summary
MqlQueryAnalysis(String query, boolean optimizeJoins, boolean autoLeftJoin)
           
 
Method Summary
 String getFieldOfExpr(String expr)
           
 DataDefinition getLabelType(String labelName)
          Gets the type of a label used within the query FIXME: remove, inline everywhere as getLabelTypes().get(labelName) for that to work, OQL and MQL need to put their aliases also in the Map returned by getLabelTypes() HQL does not support aliases in the first place
 Map<String,DataDefinition> getLabelTypes()
          Gets the type of the fields between FROM and WHERE
 DataDefinition getParameterTypes()
          Gets the types of the query parameters, as resulted from the query analysis.
 DataDefinition getProjectionType()
          Gets the type of the fields between SELECT and FROM
 String getQuery()
          Gets the original query that is analyzed by this object
 DataDefinition getTypeOfExprField(String expr)
           
(package private) static boolean isNil(antlr.collections.AST a)
           
 int parameterAt(int index)
          Gets the number of the parameter mentioned at the position indicated by the given index. query parameters may not get mentioned in the order of their $number, for example $1 may not appear first in the query, $2 may not appear second in the query, etc.
 int parameterNumber()
          Gets the total number of parameters in the query; like $1, $2 etc.
static String preProcess(String query)
           
(package private) static void setNullTest(antlr.collections.AST a)
           
static String showAst(antlr.collections.AST ast)
           
(package private)  void transformOQL(antlr.collections.AST a)
           
 String writeInSQLQuery(NameResolver nr)
          generate SQL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regExpInSET

public static final String regExpInSET
See Also:
Constant Field Values

patternInSet

public static final Pattern patternInSet
Constructor Detail

MqlQueryAnalysis

public MqlQueryAnalysis(String query,
                        boolean optimizeJoins,
                        boolean autoLeftJoin)
Method Detail

writeInSQLQuery

public String writeInSQLQuery(NameResolver nr)
Description copied from interface: QueryAnalysis
generate SQL

Specified by:
writeInSQLQuery in interface QueryAnalysis
Parameters:
nr - the NameResolver that maps DataDefinition names to database names
Returns:
a SQL string

getQuery

public String getQuery()
Description copied from interface: QueryAnalysis
Gets the original query that is analyzed by this object

Specified by:
getQuery in interface QueryAnalysis

getLabelType

public DataDefinition getLabelType(String labelName)
Description copied from interface: QueryAnalysis
Gets the type of a label used within the query FIXME: remove, inline everywhere as getLabelTypes().get(labelName) for that to work, OQL and MQL need to put their aliases also in the Map returned by getLabelTypes() HQL does not support aliases in the first place

Specified by:
getLabelType in interface QueryAnalysis
Parameters:
labelName - the name of the label
Returns:
The type of the label as declared in the FROM part of the query

getLabelTypes

public Map<String,DataDefinition> getLabelTypes()
Description copied from interface: QueryAnalysis
Gets the type of the fields between FROM and WHERE

Specified by:
getLabelTypes in interface QueryAnalysis
Returns:
A DataDefinition containing in the first field the type and name of the first label, the second field the type and name of the second label $2 etc.

getParameterTypes

public DataDefinition getParameterTypes()
Description copied from interface: QueryAnalysis
Gets the types of the query parameters, as resulted from the query analysis.

Specified by:
getParameterTypes in interface QueryAnalysis
Returns:
A DataDefinition containing in the first field the type of the QL parameter mentioned first in the query. Each mentioning of a parameter new will get a new field in this DataDefinition!

getProjectionType

public DataDefinition getProjectionType()
Description copied from interface: QueryAnalysis
Gets the type of the fields between SELECT and FROM

Specified by:
getProjectionType in interface QueryAnalysis
Returns:
A DataDefinition containing in the first field the type and name of the first QL projection, the second field the type and name of the second QL projection $2 etc.

getFieldOfExpr

public String getFieldOfExpr(String expr)

getTypeOfExprField

public DataDefinition getTypeOfExprField(String expr)

parameterAt

public int parameterAt(int index)
Description copied from interface: QueryAnalysis
Gets the number of the parameter mentioned at the position indicated by the given index. query parameters may not get mentioned in the order of their $number, for example $1 may not appear first in the query, $2 may not appear second in the query, etc.

Specified by:
parameterAt in interface QueryAnalysis
See Also:
QueryAnalysis.parameterNumber()

parameterNumber

public int parameterNumber()
Description copied from interface: QueryAnalysis
Gets the total number of parameters in the query; like $1, $2 etc. Note that if for example. $1 appears twice it will be counted twice.

Specified by:
parameterNumber in interface QueryAnalysis
See Also:
QueryAnalysis.parameterAt(int)

transformOQL

void transformOQL(antlr.collections.AST a)

showAst

public static String showAst(antlr.collections.AST ast)

isNil

static boolean isNil(antlr.collections.AST a)

setNullTest

static void setNullTest(antlr.collections.AST a)

preProcess

public static String preProcess(String query)