org.makumba.providers
Class QueryAnalysisProvider

java.lang.Object
  extended by org.makumba.providers.QueryAnalysisProvider
Direct Known Subclasses:
HQLQueryAnalysisProvider, MqlQueryAnalysisProvider

public abstract class QueryAnalysisProvider
extends Object

Version:
$Id: QueryAnalysisProvider.java 5151 2010-05-18 19:07:27Z rosso_nero $
Author:

Nested Class Summary
static class QueryAnalysisProvider.ASTTransformVisitor
           
static class QueryAnalysisProvider.FromWhere
          A holder for FROM and WHERE sections to enrich a query, and the query enrichment code.
(package private) static class QueryAnalysisProvider.SubqueryReductionVisitor
           
 
Field Summary
static String DUMMY_PROJECTION
           
static Pattern patternInSet
           
static String regExpInSET
           
 
Constructor Summary
QueryAnalysisProvider()
           
 
Method Summary
 Object checkExprSetOrNullable(String from, String expr)
          Checks if an expression is valid, nullable or set
static String checkForFrom(String query)
          Add a dummy FROM section to the query if it doesn't have one, in order for it to conform to the grammars.
 Object checkLabelSetOrNullable(String from, String referenceSequence)
          Checks if an id is nullable, and if so, return the path to the null pointer
static boolean compare(List<antlr.collections.AST> path, antlr.collections.AST t1, antlr.collections.AST t2)
          Test method to compare two AST trees
static void doThrow(String query, Throwable t, antlr.collections.AST debugTree)
           
abstract  FieldDefinition getAlternativeField(DataDefinition dd, String fn)
          Returns a possible alternative field to the one indicated.
static String getGeneratedActorName(antlr.collections.AST actorType)
           
abstract  String getName()
           
abstract  String getParameterSyntax()
          return the first character(s) in a parameter designator
abstract  String getPrimaryKeyNotation(String label)
          Returns the notation of the primary key in the query language
abstract  QueryAnalysis getQueryAnalysis(antlr.collections.AST query, DataDefinition knownLabels)
           
 QueryAnalysis getQueryAnalysis(String query)
           
 QueryAnalysis getQueryAnalysis(String query, String insertIn)
           
protected abstract  QueryAnalysis getRawQueryAnalysis(String query)
           
protected  QueryAnalysis getRawQueryAnalysis(String query, String insertIn)
           
 antlr.collections.AST inlineFunctions(String query)
           
(package private) static boolean isMakId(char c)
          Checks if a character can be part of a makumba identifier
static antlr.collections.AST makeASTCopy(antlr.collections.AST current1)
          make a copy of an AST, node with the same first child, but with no next sibling
static antlr.collections.AST parseQuery(String query)
           
static String preProcess(String query)
           
static boolean reduceDummyFrom(antlr.collections.AST parsed)
          Attempt to reduce the dummy FROM from the AST after inlining.
abstract  boolean selectGroupOrOrderAsLabels()
          Returns whether the GROUP BY or ORDER BY sections can include labels
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUMMY_PROJECTION

public static final String DUMMY_PROJECTION
See Also:
Constant Field Values

regExpInSET

public static final String regExpInSET
See Also:
Constant Field Values

patternInSet

public static final Pattern patternInSet
Constructor Detail

QueryAnalysisProvider

public QueryAnalysisProvider()
Method Detail

getName

public abstract String getName()

getRawQueryAnalysis

protected abstract QueryAnalysis getRawQueryAnalysis(String query)

getRawQueryAnalysis

protected QueryAnalysis getRawQueryAnalysis(String query,
                                            String insertIn)

getQueryAnalysis

public QueryAnalysis getQueryAnalysis(String query)

getQueryAnalysis

public abstract QueryAnalysis getQueryAnalysis(antlr.collections.AST query,
                                               DataDefinition knownLabels)

getQueryAnalysis

public QueryAnalysis getQueryAnalysis(String query,
                                      String insertIn)

selectGroupOrOrderAsLabels

public abstract boolean selectGroupOrOrderAsLabels()
Returns whether the GROUP BY or ORDER BY sections can include labels


getAlternativeField

public abstract FieldDefinition getAlternativeField(DataDefinition dd,
                                                    String fn)
Returns a possible alternative field to the one indicated.


getPrimaryKeyNotation

public abstract String getPrimaryKeyNotation(String label)
Returns the notation of the primary key in the query language

Parameters:
label - the label of the object
Returns:
the notation for the primary key of the object

checkExprSetOrNullable

public Object checkExprSetOrNullable(String from,
                                     String expr)
Checks if an expression is valid, nullable or set

Parameters:
expr - the expression
Returns:
The path to the null pointer (if the object is nullable), null otherwise

isMakId

static boolean isMakId(char c)
Checks if a character can be part of a makumba identifier

Parameters:
c - the character to check
Returns:
true if the character can be part of a makumba identifier, false otherwise

checkLabelSetOrNullable

public Object checkLabelSetOrNullable(String from,
                                      String referenceSequence)
Checks if an id is nullable, and if so, return the path to the null pointer

Parameters:
referenceSequence - a sequence like field1.field2.field3
Returns:
The path to the null pointer (if the object is nullable), null otherwise

getParameterSyntax

public abstract String getParameterSyntax()
return the first character(s) in a parameter designator


getGeneratedActorName

public static String getGeneratedActorName(antlr.collections.AST actorType)

inlineFunctions

public antlr.collections.AST inlineFunctions(String query)

makeASTCopy

public static antlr.collections.AST makeASTCopy(antlr.collections.AST current1)
make a copy of an AST, node with the same first child, but with no next sibling


compare

public static boolean compare(List<antlr.collections.AST> path,
                              antlr.collections.AST t1,
                              antlr.collections.AST t2)
Test method to compare two AST trees

Parameters:
path - the path from the root to the compared nodes
t1 - current node in the first tree
t2 - current node in second tree
Returns:
whether the trees are identical or not

doThrow

public static void doThrow(String query,
                           Throwable t,
                           antlr.collections.AST debugTree)

parseQuery

public static antlr.collections.AST parseQuery(String query)

checkForFrom

public static String checkForFrom(String query)
Add a dummy FROM section to the query if it doesn't have one, in order for it to conform to the grammars.

Parameters:
query -
Returns:
the new query

reduceDummyFrom

public static boolean reduceDummyFrom(antlr.collections.AST parsed)
Attempt to reduce the dummy FROM from the AST after inlining. Some inlining processes will add a from section, so the dummy FROM is not needed any longer.

Parameters:
parsed - the AST
Returns:
whether the query still needs a dummy from after inlining

preProcess

public static String preProcess(String query)