org.hibernate.hql.antlr
Class SqlGeneratorBase

java.lang.Object
  extended by antlr.TreeParser
      extended by org.hibernate.hql.antlr.SqlGeneratorBase
All Implemented Interfaces:
SqlTokenTypes
Direct Known Subclasses:
SqlGenerator

public class SqlGeneratorBase
extends antlr.TreeParser
implements SqlTokenTypes

SQL Generator Tree Parser, providing SQL rendering of SQL ASTs produced by the previous phase, HqlSqlWalker. All syntax decoration such as extra spaces, lack of spaces, extra parens, etc. should be added by this class.
This grammar processes the HQL/SQL AST and produces an SQL string. The intent is to move dialect-specific code into a sub-class that will override some of the methods, just like the other two grammars in this system.

Author:
Joshua Davis (joshua@hibernate.org)

Field Summary
static String[] _tokenNames
           
static antlr.collections.impl.BitSet _tokenSet_0
           
static antlr.collections.impl.BitSet _tokenSet_1
           
static antlr.collections.impl.BitSet _tokenSet_2
           
static antlr.collections.impl.BitSet _tokenSet_3
           
static antlr.collections.impl.BitSet _tokenSet_4
           
static antlr.collections.impl.BitSet _tokenSet_5
           
 
Fields inherited from class antlr.TreeParser
_retTree, astFactory, ASTNULL, inputState, returnAST, tokenNames, traceDepth
 
Fields inherited from interface org.hibernate.hql.antlr.SqlTokenTypes
AGGREGATE, ALIAS, ALIAS_REF, ALL, AND, ANY, AS, ASCENDING, AVG, BETWEEN, BOGUS, BOTH, CASE, CASE2, CLASS, CLOSE, CLOSE_BRACKET, COLON, COMMA, CONCAT, CONSTANT, CONSTRUCTOR, COUNT, DELETE, DESCENDING, DISTINCT, DIV, DOT, ELEMENTS, ELSE, EMPTY, END, ENTRY, EOF, EQ, ESCAPE, ESCqs, EXISTS, EXPONENT, EXPR_LIST, FALSE, FETCH, FILTER_ENTITY, FILTERS, FLOAT_SUFFIX, FROM, FROM_FRAGMENT, FULL, GE, GROUP, GT, HAVING, HEX_DIGIT, ID_LETTER, ID_START_LETTER, IDENT, IMPLIED_FROM, IN, IN_LIST, INDEX_OP, INDICES, INNER, INSERT, INTO, IS, IS_NOT_NULL, IS_NULL, JAVA_CONSTANT, JOIN, JOIN_FRAGMENT, KEY, LE, LEADING, LEFT, LEFT_OUTER, LIKE, LITERAL_ascending, LITERAL_by, LITERAL_descending, LT, MAX, MEMBER, METHOD_CALL, METHOD_NAME, MIN, MINUS, MOD, NAMED_PARAM, NE, NEW, NOT, NOT_BETWEEN, NOT_IN, NOT_LIKE, NULL, NULL_TREE_LOOKAHEAD, NUM_BIG_DECIMAL, NUM_BIG_INTEGER, NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG, OBJECT, OF, ON, OPEN, OPEN_BRACKET, OR, ORDER, ORDER_ELEMENT, OUTER, PARAM, PLUS, PROPERTIES, PROPERTY_REF, QUERY, QUOTED_STRING, RANGE, RESULT_VARIABLE_REF, RIGHT, RIGHT_OUTER, ROW_STAR, SELECT, SELECT_CLAUSE, SELECT_COLUMNS, SELECT_EXPR, SELECT_FROM, SET, SOME, SQL_NE, SQL_NODE, SQL_TOKEN, STAR, SUM, THEN, THETA_JOINS, TRAILING, TRUE, UNARY_MINUS, UNARY_PLUS, UNION, UPDATE, VALUE, VECTOR_EXPR, VERSIONED, WEIRD_IDENT, WHEN, WHERE, WITH, WS
 
Constructor Summary
SqlGeneratorBase()
           
 
Method Summary
 void additiveExpr(antlr.collections.AST _t)
           
 void addrExpr(antlr.collections.AST _t)
           
 void aggregate(antlr.collections.AST _t)
           
 void arguments(antlr.collections.AST _t)
           
 void arithmeticExpr(antlr.collections.AST _t)
           
protected  void beginFunctionTemplate(antlr.collections.AST m, antlr.collections.AST i)
           
 void binaryComparisonExpression(antlr.collections.AST _t)
           
 void booleanExpr(antlr.collections.AST _t, boolean parens)
           
 void booleanOp(antlr.collections.AST _t, boolean parens)
           
 void caseExpr(antlr.collections.AST _t)
           
protected  void commaBetweenParameters(String comma)
           
 void comparisonExpr(antlr.collections.AST _t, boolean parens)
           
 void conditionList(antlr.collections.AST _t)
           
 void constant(antlr.collections.AST _t)
           
 void count(antlr.collections.AST _t)
           
 void countExpr(antlr.collections.AST _t)
           
 void deleteStatement(antlr.collections.AST _t)
           
 void distinctOrAll(antlr.collections.AST _t)
           
protected  void endFunctionTemplate(antlr.collections.AST m)
           
 void exoticComparisonExpression(antlr.collections.AST _t)
           
 void expr(antlr.collections.AST _t)
           
 void filters(antlr.collections.AST _t)
           
 void from(antlr.collections.AST _t)
           
protected  void fromFragmentSeparator(antlr.collections.AST a)
           
 void fromTable(antlr.collections.AST _t)
           
protected  int getLastChar()
          Returns the last character written to the output, or -1 if there isn't one.
protected  StringBuffer getStringBuffer()
           
 void groupExprs(antlr.collections.AST _t)
           
protected  boolean hasText(antlr.collections.AST a)
           
 void inList(antlr.collections.AST _t)
           
 void insertStatement(antlr.collections.AST _t)
           
 void likeEscape(antlr.collections.AST _t)
           
 void mapComponentReference(antlr.collections.AST _t)
           
 void methodCall(antlr.collections.AST _t)
           
 void multiplicativeExpr(antlr.collections.AST _t)
           
 void nestedExpr(antlr.collections.AST _t)
           
 void nestedExprAfterMinusDiv(antlr.collections.AST _t)
           
protected  void nestedFromFragment(antlr.collections.AST d, antlr.collections.AST parent)
           
protected  void nyi(antlr.collections.AST n)
           
protected  void optionalSpace()
          Add a aspace if the previous token was not a space or a parenthesis.
 void orderDirection(antlr.collections.AST _t)
           
 void orderExprs(antlr.collections.AST _t)
           
protected  void out(antlr.collections.AST n)
           
protected  void out(String s)
           
 void parameter(antlr.collections.AST _t)
           
 void parenSelect(antlr.collections.AST _t)
           
 void quantified(antlr.collections.AST _t)
           
 void selectAtom(antlr.collections.AST _t)
           
 void selectClause(antlr.collections.AST _t)
           
 void selectColumn(antlr.collections.AST _t)
           
 void selectExpr(antlr.collections.AST _t)
           
 void selectStatement(antlr.collections.AST _t)
           
protected  void separator(antlr.collections.AST n, String sep)
           
 void setClause(antlr.collections.AST _t)
           
 void simpleExpr(antlr.collections.AST _t)
           
 void simpleExprList(antlr.collections.AST _t)
           
 void sqlToken(antlr.collections.AST _t)
           
 void statement(antlr.collections.AST _t)
           
 void tableJoin(antlr.collections.AST _t, antlr.collections.AST parent)
           
 void thetaJoins(antlr.collections.AST _t)
           
 void updateStatement(antlr.collections.AST _t)
           
 void whereClause(antlr.collections.AST _t)
           
 void whereClauseExpr(antlr.collections.AST _t)
           
 void whereExpr(antlr.collections.AST _t)
           
 
Methods inherited from class antlr.TreeParser
getAST, getASTFactory, getTokenName, getTokenNames, match, match, matchNot, panic, reportError, reportError, reportWarning, setASTFactory, setASTNodeClass, setASTNodeType, traceIn, traceIndent, traceOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_tokenNames

public static final String[] _tokenNames

_tokenSet_0

public static final antlr.collections.impl.BitSet _tokenSet_0

_tokenSet_1

public static final antlr.collections.impl.BitSet _tokenSet_1

_tokenSet_2

public static final antlr.collections.impl.BitSet _tokenSet_2

_tokenSet_3

public static final antlr.collections.impl.BitSet _tokenSet_3

_tokenSet_4

public static final antlr.collections.impl.BitSet _tokenSet_4

_tokenSet_5

public static final antlr.collections.impl.BitSet _tokenSet_5
Constructor Detail

SqlGeneratorBase

public SqlGeneratorBase()
Method Detail

out

protected void out(String s)

getLastChar

protected int getLastChar()
Returns the last character written to the output, or -1 if there isn't one.


optionalSpace

protected void optionalSpace()
Add a aspace if the previous token was not a space or a parenthesis.


out

protected void out(antlr.collections.AST n)

separator

protected void separator(antlr.collections.AST n,
                         String sep)

hasText

protected boolean hasText(antlr.collections.AST a)

fromFragmentSeparator

protected void fromFragmentSeparator(antlr.collections.AST a)

nestedFromFragment

protected void nestedFromFragment(antlr.collections.AST d,
                                  antlr.collections.AST parent)

getStringBuffer

protected StringBuffer getStringBuffer()

nyi

protected void nyi(antlr.collections.AST n)

beginFunctionTemplate

protected void beginFunctionTemplate(antlr.collections.AST m,
                                     antlr.collections.AST i)

endFunctionTemplate

protected void endFunctionTemplate(antlr.collections.AST m)

commaBetweenParameters

protected void commaBetweenParameters(String comma)

statement

public final void statement(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

selectStatement

public final void selectStatement(antlr.collections.AST _t)
                           throws antlr.RecognitionException
Throws:
antlr.RecognitionException

updateStatement

public final void updateStatement(antlr.collections.AST _t)
                           throws antlr.RecognitionException
Throws:
antlr.RecognitionException

deleteStatement

public final void deleteStatement(antlr.collections.AST _t)
                           throws antlr.RecognitionException
Throws:
antlr.RecognitionException

insertStatement

public final void insertStatement(antlr.collections.AST _t)
                           throws antlr.RecognitionException
Throws:
antlr.RecognitionException

selectClause

public final void selectClause(antlr.collections.AST _t)
                        throws antlr.RecognitionException
Throws:
antlr.RecognitionException

from

public final void from(antlr.collections.AST _t)
                throws antlr.RecognitionException
Throws:
antlr.RecognitionException

whereExpr

public final void whereExpr(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

groupExprs

public final void groupExprs(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

booleanExpr

public final void booleanExpr(antlr.collections.AST _t,
                              boolean parens)
                       throws antlr.RecognitionException
Throws:
antlr.RecognitionException

orderExprs

public final void orderExprs(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

fromTable

public final void fromTable(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

setClause

public final void setClause(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

whereClause

public final void whereClause(antlr.collections.AST _t)
                       throws antlr.RecognitionException
Throws:
antlr.RecognitionException

comparisonExpr

public final void comparisonExpr(antlr.collections.AST _t,
                                 boolean parens)
                          throws antlr.RecognitionException
Throws:
antlr.RecognitionException

whereClauseExpr

public final void whereClauseExpr(antlr.collections.AST _t)
                           throws antlr.RecognitionException
Throws:
antlr.RecognitionException

conditionList

public final void conditionList(antlr.collections.AST _t)
                         throws antlr.RecognitionException
Throws:
antlr.RecognitionException

expr

public final void expr(antlr.collections.AST _t)
                throws antlr.RecognitionException
Throws:
antlr.RecognitionException

orderDirection

public final void orderDirection(antlr.collections.AST _t)
                          throws antlr.RecognitionException
Throws:
antlr.RecognitionException

filters

public final void filters(antlr.collections.AST _t)
                   throws antlr.RecognitionException
Throws:
antlr.RecognitionException

thetaJoins

public final void thetaJoins(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

sqlToken

public final void sqlToken(antlr.collections.AST _t)
                    throws antlr.RecognitionException
Throws:
antlr.RecognitionException

distinctOrAll

public final void distinctOrAll(antlr.collections.AST _t)
                         throws antlr.RecognitionException
Throws:
antlr.RecognitionException

selectColumn

public final void selectColumn(antlr.collections.AST _t)
                        throws antlr.RecognitionException
Throws:
antlr.RecognitionException

selectExpr

public final void selectExpr(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

selectAtom

public final void selectAtom(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

mapComponentReference

public final void mapComponentReference(antlr.collections.AST _t)
                                 throws antlr.RecognitionException
Throws:
antlr.RecognitionException

count

public final void count(antlr.collections.AST _t)
                 throws antlr.RecognitionException
Throws:
antlr.RecognitionException

methodCall

public final void methodCall(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

aggregate

public final void aggregate(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

constant

public final void constant(antlr.collections.AST _t)
                    throws antlr.RecognitionException
Throws:
antlr.RecognitionException

arithmeticExpr

public final void arithmeticExpr(antlr.collections.AST _t)
                          throws antlr.RecognitionException
Throws:
antlr.RecognitionException

countExpr

public final void countExpr(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

simpleExpr

public final void simpleExpr(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

tableJoin

public final void tableJoin(antlr.collections.AST _t,
                            antlr.collections.AST parent)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

booleanOp

public final void booleanOp(antlr.collections.AST _t,
                            boolean parens)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

binaryComparisonExpression

public final void binaryComparisonExpression(antlr.collections.AST _t)
                                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

exoticComparisonExpression

public final void exoticComparisonExpression(antlr.collections.AST _t)
                                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

likeEscape

public final void likeEscape(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

inList

public final void inList(antlr.collections.AST _t)
                  throws antlr.RecognitionException
Throws:
antlr.RecognitionException

quantified

public final void quantified(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

parenSelect

public final void parenSelect(antlr.collections.AST _t)
                       throws antlr.RecognitionException
Throws:
antlr.RecognitionException

simpleExprList

public final void simpleExprList(antlr.collections.AST _t)
                          throws antlr.RecognitionException
Throws:
antlr.RecognitionException

addrExpr

public final void addrExpr(antlr.collections.AST _t)
                    throws antlr.RecognitionException
Throws:
antlr.RecognitionException

parameter

public final void parameter(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException

additiveExpr

public final void additiveExpr(antlr.collections.AST _t)
                        throws antlr.RecognitionException
Throws:
antlr.RecognitionException

multiplicativeExpr

public final void multiplicativeExpr(antlr.collections.AST _t)
                              throws antlr.RecognitionException
Throws:
antlr.RecognitionException

nestedExprAfterMinusDiv

public final void nestedExprAfterMinusDiv(antlr.collections.AST _t)
                                   throws antlr.RecognitionException
Throws:
antlr.RecognitionException

caseExpr

public final void caseExpr(antlr.collections.AST _t)
                    throws antlr.RecognitionException
Throws:
antlr.RecognitionException

nestedExpr

public final void nestedExpr(antlr.collections.AST _t)
                      throws antlr.RecognitionException
Throws:
antlr.RecognitionException

arguments

public final void arguments(antlr.collections.AST _t)
                     throws antlr.RecognitionException
Throws:
antlr.RecognitionException


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.