org.hibernate.hql.antlr

Class SqlGeneratorBase

Implemented Interfaces:
SqlTokenTypes
Known Direct Subclasses:
SqlGenerator

public class SqlGeneratorBase
extends 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 BitSet
_tokenSet_0
static BitSet
_tokenSet_1
static BitSet
_tokenSet_2
static BitSet
_tokenSet_3
static BitSet
_tokenSet_4
static BitSet
_tokenSet_5

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, EOF, EQ, ESCAPE, ESCqs, EXISTS, EXPONENT, EXPR_LIST, FALSE, FETCH, FILTERS, FILTER_ENTITY, FLOAT_SUFFIX, FROM, FROM_FRAGMENT, FULL, GE, GROUP, GT, HAVING, HEX_DIGIT, IDENT, ID_LETTER, ID_START_LETTER, IMPLIED_FROM, IN, INDEX_OP, INDICES, INNER, INSERT, INTO, IN_LIST, IS, IS_NOT_NULL, IS_NULL, JAVA_CONSTANT, JOIN, JOIN_FRAGMENT, LE, LEADING, LEFT, LEFT_OUTER, LIKE, LITERAL_ascending, LITERAL_by, LITERAL_descending, LT, MAX, MEMBER, METHOD_CALL, METHOD_NAME, MIN, MINUS, NAMED_PARAM, NE, NEW, NOT, NOT_BETWEEN, NOT_IN, NOT_LIKE, NULL, NULL_TREE_LOOKAHEAD, 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, 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, VECTOR_EXPR, VERSIONED, WEIRD_IDENT, WHEN, WHERE, WITH, WS

Constructor Summary

SqlGeneratorBase()

Method Summary

void
additiveExpr(AST _t)
void
addrExpr(AST _t)
void
aggregate(AST _t)
void
arguments(AST _t)
void
arithmeticExpr(AST _t)
protected void
beginFunctionTemplate(AST m, AST i)
void
binaryComparisonExpression(AST _t)
void
booleanExpr(AST _t, boolean parens)
void
booleanOp(AST _t, boolean parens)
void
caseExpr(AST _t)
protected void
commaBetweenParameters(String comma)
void
comparisonExpr(AST _t, boolean parens)
void
conditionList(AST _t)
void
constant(AST _t)
void
count(AST _t)
void
countExpr(AST _t)
void
deleteStatement(AST _t)
void
distinctOrAll(AST _t)
protected void
endFunctionTemplate(AST m)
void
exoticComparisonExpression(AST _t)
void
expr(AST _t)
void
filters(AST _t)
void
from(AST _t)
protected void
fromFragmentSeparator(AST a)
void
fromTable(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(AST _t)
protected boolean
hasText(AST a)
void
inList(AST _t)
void
insertStatement(AST _t)
void
likeEscape(AST _t)
void
methodCall(AST _t)
void
multiplicativeExpr(AST _t)
void
nestedExpr(AST _t)
void
nestedExprAfterMinusDiv(AST _t)
protected void
nestedFromFragment(AST d, AST parent)
protected void
nyi(AST n)
protected void
optionalSpace()
Add a aspace if the previous token was not a space or a parenthesis.
void
orderDirection(AST _t)
void
orderExprs(AST _t)
protected void
out(AST n)
protected void
out(String s)
void
parameter(AST _t)
void
parenSelect(AST _t)
void
quantified(AST _t)
void
selectAtom(AST _t)
void
selectClause(AST _t)
void
selectColumn(AST _t)
void
selectExpr(AST _t)
void
selectStatement(AST _t)
protected void
separator(AST n, String sep)
void
setClause(AST _t)
void
simpleExpr(AST _t)
void
simpleExprList(AST _t)
void
sqlToken(AST _t)
void
statement(AST _t)
void
tableJoin(AST _t, AST parent)
void
thetaJoins(AST _t)
void
updateStatement(AST _t)
void
whereClause(AST _t)
void
whereClauseExpr(AST _t)
void
whereExpr(AST _t)

Field Details

_tokenNames

public static final String[] _tokenNames

_tokenSet_0

public static final BitSet _tokenSet_0

_tokenSet_1

public static final BitSet _tokenSet_1

_tokenSet_2

public static final BitSet _tokenSet_2

_tokenSet_3

public static final BitSet _tokenSet_3

_tokenSet_4

public static final BitSet _tokenSet_4

_tokenSet_5

public static final BitSet _tokenSet_5

Constructor Details

SqlGeneratorBase

public SqlGeneratorBase()

Method Details

additiveExpr

public final void additiveExpr(AST _t)
            throws RecognitionException

addrExpr

public final void addrExpr(AST _t)
            throws RecognitionException

aggregate

public final void aggregate(AST _t)
            throws RecognitionException

arguments

public final void arguments(AST _t)
            throws RecognitionException

arithmeticExpr

public final void arithmeticExpr(AST _t)
            throws RecognitionException

beginFunctionTemplate

protected void beginFunctionTemplate(AST m,
                                     AST i)

binaryComparisonExpression

public final void binaryComparisonExpression(AST _t)
            throws RecognitionException

booleanExpr

public final void booleanExpr(AST _t,
                              boolean parens)
            throws RecognitionException

booleanOp

public final void booleanOp(AST _t,
                            boolean parens)
            throws RecognitionException

caseExpr

public final void caseExpr(AST _t)
            throws RecognitionException

commaBetweenParameters

protected void commaBetweenParameters(String comma)

comparisonExpr

public final void comparisonExpr(AST _t,
                                 boolean parens)
            throws RecognitionException

conditionList

public final void conditionList(AST _t)
            throws RecognitionException

constant

public final void constant(AST _t)
            throws RecognitionException

count

public final void count(AST _t)
            throws RecognitionException

countExpr

public final void countExpr(AST _t)
            throws RecognitionException

deleteStatement

public final void deleteStatement(AST _t)
            throws RecognitionException

distinctOrAll

public final void distinctOrAll(AST _t)
            throws RecognitionException

endFunctionTemplate

protected void endFunctionTemplate(AST m)

exoticComparisonExpression

public final void exoticComparisonExpression(AST _t)
            throws RecognitionException

expr

public final void expr(AST _t)
            throws RecognitionException

filters

public final void filters(AST _t)
            throws RecognitionException

from

public final void from(AST _t)
            throws RecognitionException

fromFragmentSeparator

protected void fromFragmentSeparator(AST a)

fromTable

public final void fromTable(AST _t)
            throws RecognitionException

getLastChar

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

getStringBuffer

protected StringBuffer getStringBuffer()

groupExprs

public final void groupExprs(AST _t)
            throws RecognitionException

hasText

protected boolean hasText(AST a)

inList

public final void inList(AST _t)
            throws RecognitionException

insertStatement

public final void insertStatement(AST _t)
            throws RecognitionException

likeEscape

public final void likeEscape(AST _t)
            throws RecognitionException

methodCall

public final void methodCall(AST _t)
            throws RecognitionException

multiplicativeExpr

public final void multiplicativeExpr(AST _t)
            throws RecognitionException

nestedExpr

public final void nestedExpr(AST _t)
            throws RecognitionException

nestedExprAfterMinusDiv

public final void nestedExprAfterMinusDiv(AST _t)
            throws RecognitionException

nestedFromFragment

protected void nestedFromFragment(AST d,
                                  AST parent)

nyi

protected void nyi(AST n)

optionalSpace

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

orderDirection

public final void orderDirection(AST _t)
            throws RecognitionException

orderExprs

public final void orderExprs(AST _t)
            throws RecognitionException

out

protected void out(AST n)

out

protected void out(String s)

parameter

public final void parameter(AST _t)
            throws RecognitionException

parenSelect

public final void parenSelect(AST _t)
            throws RecognitionException

quantified

public final void quantified(AST _t)
            throws RecognitionException

selectAtom

public final void selectAtom(AST _t)
            throws RecognitionException

selectClause

public final void selectClause(AST _t)
            throws RecognitionException

selectColumn

public final void selectColumn(AST _t)
            throws RecognitionException

selectExpr

public final void selectExpr(AST _t)
            throws RecognitionException

selectStatement

public final void selectStatement(AST _t)
            throws RecognitionException

separator

protected void separator(AST n,
                         String sep)

setClause

public final void setClause(AST _t)
            throws RecognitionException

simpleExpr

public final void simpleExpr(AST _t)
            throws RecognitionException

simpleExprList

public final void simpleExprList(AST _t)
            throws RecognitionException

sqlToken

public final void sqlToken(AST _t)
            throws RecognitionException

statement

public final void statement(AST _t)
            throws RecognitionException

tableJoin

public final void tableJoin(AST _t,
                            AST parent)
            throws RecognitionException

thetaJoins

public final void thetaJoins(AST _t)
            throws RecognitionException

updateStatement

public final void updateStatement(AST _t)
            throws RecognitionException

whereClause

public final void whereClause(AST _t)
            throws RecognitionException

whereClauseExpr

public final void whereClauseExpr(AST _t)
            throws RecognitionException

whereExpr

public final void whereExpr(AST _t)
            throws RecognitionException