org.makumba.providers.query.hql
Class HqlAnalyzer

java.lang.Object
  extended by org.makumba.providers.query.hql.HqlAnalyzer
All Implemented Interfaces:
QueryAnalysis

public class HqlAnalyzer
extends Object
implements QueryAnalysis


Constructor Summary
HqlAnalyzer(String query1)
           
 
Method Summary
 String getHackedQuery(String query)
           
 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
(package private)  String getTypeName(int i)
           
 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.
 String toString()
           
 String writeInSQLQuery(NameResolver nr)
          generate SQL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HqlAnalyzer

public HqlAnalyzer(String query1)
Method Detail

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.

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

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!

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)

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()

getTypeName

String getTypeName(int i)

toString

public String toString()
Overrides:
toString in class Object

getHackedQuery

public String getHackedQuery(String query)

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

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.

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