net.sf.saffron.oj.xlat
Class SqlToOpenjavaConverter

java.lang.Object
  |
  +--net.sf.saffron.oj.xlat.SqlToOpenjavaConverter

public class SqlToOpenjavaConverter
extends Object

A SqlToOpenjavaConverter converts a tree of SqlNode objects a ParseTree tree.

Since:
Mar 19, 2003
Version:
$Id: //open/saffron/src/net/sf/saffron/oj/xlat/SqlToOpenjavaConverter.java#7 $
Author:
jhyde

Nested Class Summary
static class SqlToOpenjavaConverter.ConverterTest
          Unit test for SqlToOpenjavaConverter.
static class SqlToOpenjavaConverter.SchemaCatalogReader
          A SchemaCatalogReader looks up catalog information from a saffron schema object.
(package private) static class SqlToOpenjavaConverter.TestContext
           
 
Field Summary
(package private) static HashMap mapBinaryOjToSql
          Inverse of mapBinarySqlToOj.
(package private) static HashMap mapBinarySqlToOj
          Maps names of SqlBinaryOperator to codes of BinaryExpression, wrapped as Integer.
private static SqlToOpenjavaConverter.TestContext testContext
           
private  SqlValidator validator
           
 
Constructor Summary
SqlToOpenjavaConverter(SqlValidator validator)
           
 
Method Summary
private static void addBinary(String name, int code)
           
private  Expression convertExpression(SqlValidator.Scope scope, SqlNode node)
           
private  Expression convertFrom(SqlValidator.Scope scope, SqlNode from)
           
private  ExpressionList convertGroup(SqlValidator.Scope scope, SqlNodeList groupList)
           
private  Expression convertIdentifier(SqlValidator.Scope scope, SqlIdentifier identifier)
          Converts an identifier into an expression in a given scope.
private static int convertJoinType(SqlJoinOperator.JoinType joinType)
           
private  Expression convertLiteral(SqlLiteral literal)
           
private  ExpressionList convertOrder(SqlValidator.Scope scope, SqlNodeList orderList)
           
 Expression convertQuery(SqlNode query)
           
private  Expression convertQueryRecursive(SqlNode query)
           
private  QueryExpression convertRowConstructor(SqlValidator.Scope scope, SqlCall rowConstructor)
           
 Expression convertSelect(SqlSelect query)
           
private  ExpressionList convertSelectList(SqlValidator.SelectScope scope, SqlNodeList selectList)
           
private  Expression convertValues(SqlValidator.Scope scope, SqlCall values)
           
private static HashMap createFunctionMap()
           
private static HashMap createPostfixMap()
           
private static HashMap createPrefixMap()
           
private static SqlToOpenjavaConverter.TestContext getTestContext()
           
private static void initMaps()
           
static Test suite()
          Standard method recognised by JUnit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testContext

private static SqlToOpenjavaConverter.TestContext testContext

mapBinarySqlToOj

static final HashMap mapBinarySqlToOj
Maps names of SqlBinaryOperator to codes of BinaryExpression, wrapped as Integer. For example, mapBinarySqlToOj.get("/") returns Integer(BinaryExpression.DIVIDE.


mapBinaryOjToSql

static final HashMap mapBinaryOjToSql
Inverse of mapBinarySqlToOj.


validator

private final SqlValidator validator
Constructor Detail

SqlToOpenjavaConverter

public SqlToOpenjavaConverter(SqlValidator validator)
Method Detail

convertQuery

public Expression convertQuery(SqlNode query)

convertSelect

public Expression convertSelect(SqlSelect query)

suite

public static Test suite()
Standard method recognised by JUnit.


getTestContext

private static SqlToOpenjavaConverter.TestContext getTestContext()

convertExpression

private Expression convertExpression(SqlValidator.Scope scope,
                                     SqlNode node)

convertFrom

private Expression convertFrom(SqlValidator.Scope scope,
                               SqlNode from)

convertJoinType

private static int convertJoinType(SqlJoinOperator.JoinType joinType)

convertGroup

private ExpressionList convertGroup(SqlValidator.Scope scope,
                                    SqlNodeList groupList)

convertLiteral

private Expression convertLiteral(SqlLiteral literal)

convertOrder

private ExpressionList convertOrder(SqlValidator.Scope scope,
                                    SqlNodeList orderList)

convertQueryRecursive

private Expression convertQueryRecursive(SqlNode query)

initMaps

private static void initMaps()

addBinary

private static void addBinary(String name,
                              int code)

createPrefixMap

private static HashMap createPrefixMap()

createPostfixMap

private static HashMap createPostfixMap()

createFunctionMap

private static HashMap createFunctionMap()

convertIdentifier

private Expression convertIdentifier(SqlValidator.Scope scope,
                                     SqlIdentifier identifier)
Converts an identifier into an expression in a given scope. For example, the "empno" in "select empno from emp join dept" becomes "emp.empno".


convertRowConstructor

private QueryExpression convertRowConstructor(SqlValidator.Scope scope,
                                              SqlCall rowConstructor)

convertSelectList

private ExpressionList convertSelectList(SqlValidator.SelectScope scope,
                                         SqlNodeList selectList)

convertValues

private Expression convertValues(SqlValidator.Scope scope,
                                 SqlCall values)

SourceForge.net_Logo