org.exolab.castor.jdo.oql
Class ParseTreeWalker

java.lang.Object
  extended by org.exolab.castor.jdo.oql.ParseTreeWalker
All Implemented Interfaces:
TokenTypes

public class ParseTreeWalker
extends java.lang.Object
implements TokenTypes

A class which walks the parse tree created by the parser to check for errors and translate to SQL.

Version:
$Revision: 1.14 $ $Date: 2005/11/05 16:32:06 $
Author:
Nissim Karpenstein

Field Summary
static int AGGREGATE
           
static int DEPENDANT_OBJECT
           
static int DEPENDANT_OBJECT_VALUE
           
static int DEPENDANT_VALUE
           
static int FUNCTION
           
static int MAX_TABLE_LENGTH
           
static int PARENT_OBJECT
           
 
Fields inherited from interface org.exolab.castor.jdo.oql.TokenTypes
ARROW, BOOLEAN_LITERAL, CHAR_LITERAL, COLON, COMMA, CONCAT, DATE_LITERAL, DIVIDE, DOLLAR, DOT, DOUBLE_LITERAL, END_OF_QUERY, EQUAL, GT, GTE, IDENTIFIER, KEYWORD_ABS, KEYWORD_AND, KEYWORD_AS, KEYWORD_ASC, KEYWORD_AVG, KEYWORD_BETWEEN, KEYWORD_BY, KEYWORD_COUNT, KEYWORD_DESC, KEYWORD_DISTINCT, KEYWORD_FROM, KEYWORD_IN, KEYWORD_IS_DEFINED, KEYWORD_IS_UNDEFINED, KEYWORD_LIKE, KEYWORD_LIMIT, KEYWORD_LIST, KEYWORD_MAX, KEYWORD_MIN, KEYWORD_MOD, KEYWORD_NIL, KEYWORD_NOT, KEYWORD_OFFSET, KEYWORD_OR, KEYWORD_ORDER, KEYWORD_SELECT, KEYWORD_SUM, KEYWORD_UNDEFINED, KEYWORD_WHERE, LONG_LITERAL, LPAREN, LT, LTE, MINUS, NOT_EQUAL, PLUS, RPAREN, STRING_LITERAL, TIME_LITERAL, TIMES, TIMESTAMP_LITERAL
 
Constructor Summary
ParseTreeWalker(LockEngine dbEngine, ParseTreeNode parseTree, java.lang.ClassLoader classLoader, DbMetaInfo dbInfo)
          Creates a new parse tree walker.
 
Method Summary
 java.lang.String buildTableAlias(java.lang.String tableName, java.util.Vector path, int tableIndex)
          Builds the alias name for a table from the path info.
 JDOClassDescriptor getClassDescriptor()
          Accessor method for _clsDesc.
 java.lang.Class getObjClass()
          Accessor method for _objClass.
 java.util.Hashtable getParamInfo()
          Accessor method for _paramInfo.
 java.util.Vector getPathInfo()
          Method to get path info for the selected object.
 int getProjectionType()
          Accessor method for _projectionType.
 QueryExpression getQueryExpression()
          Accessor method for private _queryExpr member.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AGGREGATE

public static final int AGGREGATE
See Also:
Constant Field Values

FUNCTION

public static final int FUNCTION
See Also:
Constant Field Values

PARENT_OBJECT

public static final int PARENT_OBJECT
See Also:
Constant Field Values

DEPENDANT_OBJECT

public static final int DEPENDANT_OBJECT
See Also:
Constant Field Values

DEPENDANT_OBJECT_VALUE

public static final int DEPENDANT_OBJECT_VALUE
See Also:
Constant Field Values

DEPENDANT_VALUE

public static final int DEPENDANT_VALUE
See Also:
Constant Field Values

MAX_TABLE_LENGTH

public static final int MAX_TABLE_LENGTH
See Also:
Constant Field Values
Constructor Detail

ParseTreeWalker

public ParseTreeWalker(LockEngine dbEngine,
                       ParseTreeNode parseTree,
                       java.lang.ClassLoader classLoader,
                       DbMetaInfo dbInfo)
                throws QueryException
Creates a new parse tree walker. Which checks the tree for errors, and generates a QueryExpression containing the SQL translation.

Parameters:
dbEngine - The Persistence Engine
parseTree - The parse tree to walk
classLoader - A ClassLoader instance to load classes.
Throws:
QueryException - Thrown by checkErrors.
Method Detail

getObjClass

public java.lang.Class getObjClass()
Accessor method for _objClass.

Returns:
The _objClass member.

getProjectionType

public int getProjectionType()
Accessor method for _projectionType.

Returns:
The _projectionType member.

getQueryExpression

public QueryExpression getQueryExpression()
Accessor method for private _queryExpr member.

Returns:
private _queryExpr member

getParamInfo

public java.util.Hashtable getParamInfo()
Accessor method for _paramInfo.

Returns:
The _paramInfo member.

getClassDescriptor

public JDOClassDescriptor getClassDescriptor()
Accessor method for _clsDesc.

Returns:
The _clsDesc member.

getPathInfo

public java.util.Vector getPathInfo()
Method to get path info for the selected object. This is the path which will be used by the QueryResults to follow the path if the object selected is a DEPENDANT_OBJECT or DEPENDANT_OBJECT_VALUE. Any other projectionTypes do not need this, so null will be returned.

Returns:
Path info for the selected element, null otherwise.

buildTableAlias

public java.lang.String buildTableAlias(java.lang.String tableName,
                                        java.util.Vector path,
                                        int tableIndex)
Builds the alias name for a table from the path info.

Parameters:
tableName - The name of the table to add to the select clause
path - The path info vector to build the alias with
tableIndex - Field index in the path info
Returns:
Alias name for a given table.


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com