|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.saffron.oj.stmt.OJStatement
An OJStatement
is used to execute a saffron (or regular Java)
expression dynamically.
Nested Class Summary | |
static class |
OJStatement.Argument
An Argument supplies a name/value pair to a statement. |
(package private) static interface |
OJStatement.Binder
|
Field Summary | |
private SaffronConnection |
connection
|
static String |
connectionVariable
|
(package private) Environment |
env
|
(package private) int |
executionCount
|
private JavaCompiler |
javaCompiler
Share the same compiler between multiple statements because DynamicJava has a class loader which caches class definitions. |
private CallingConvention |
resultCallingConvention
CallingConvention via which results should be returned by execution. |
Constructor Summary | |
OJStatement(SaffronConnection connection)
Creates a statement |
Method Summary | |
private void |
addDecl(Statement statement,
ExpressionList exprList)
|
private BoundMethod |
compile(ClassDeclaration decl,
Environment env,
ParseTree parseTree,
OJStatement.Argument[] arguments)
|
private BoundMethod |
compile(String packageName,
String className,
String s,
Class[] parameterTypes,
String[] parameterNames)
|
private BoundMethod |
compileAndBind(ClassDeclaration decl,
ParseTree parseTree,
OJStatement.Argument[] arguments)
|
private static JavaCompiler |
createCompiler()
|
Object |
evaluate(ClassDeclaration decl,
ParseTree parseTree,
OJStatement.Argument[] arguments)
Evaluates an expression represented by a parse tree. |
Object |
execute(String queryString,
OJStatement.Argument[] arguments)
Executes a query string, passing in a set of arguments, and returns the result. |
ResultSet |
executeSql(String queryString)
|
protected static String |
getClassRoot()
|
private static String |
getCompilerClassName()
|
Environment |
getEnvironment()
|
protected static String |
getJavaRoot()
|
protected SqlToRelConverter |
getSqlToRelConverter(SqlValidator validator,
SaffronConnection connection)
Protected method to allow subclasses to override construction of SqlToRelConverter. |
protected String |
getTempClassName()
|
protected String |
getTempMethodName()
|
protected String |
getTempPackageName()
|
ClassDeclaration |
init(OJStatement.Argument[] arguments)
|
Expression |
parse(String queryString)
|
PreparedResult |
prepareSql(SqlNode sqlQuery,
Class runtimeContextClass,
SqlValidator validator)
Prepares a statement for execution, starting from a parse tree and using a user-supplied validator. |
PreparedResult |
prepareSql(String queryString)
Prepares a statement for execution, starting from a SQL string and using the standard validator. |
void |
setResultCallingConvention(CallingConvention resultCallingConvention)
|
ParseTree |
validate(ParseTree parseTree,
QueryExpander queryExpander)
Validates and transforms an expression: expands schemas, validates, and possibly expands queries. |
private static Class |
visibleBaseClass(Class clazz,
String fromPackageName)
Returns the lowest ancestor of clazz which is visible from
fromPackage .fromClazz . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String connectionVariable
Environment env
int executionCount
private CallingConvention resultCallingConvention
private JavaCompiler javaCompiler
private final SaffronConnection connection
Constructor Detail |
public OJStatement(SaffronConnection connection)
connection
- Connection statement belongs to; may be null, but only
if this statement implements SaffronConnection
Method Detail |
public Environment getEnvironment()
public void setResultCallingConvention(CallingConvention resultCallingConvention)
public Object evaluate(ClassDeclaration decl, ParseTree parseTree, OJStatement.Argument[] arguments)
private BoundMethod compileAndBind(ClassDeclaration decl, ParseTree parseTree, OJStatement.Argument[] arguments)
public Object execute(String queryString, OJStatement.Argument[] arguments)
Example:
Sales sales = new Sales("jdbc:odbc:Northwind"); int maxSalary = 10000; Statement statement = new Statement(); statement.execute( "select * from sales.emp where emp.sal > maxSalary", this.class, new Argument[] { new Argument("sales", sales), new Argument("maxSalary", maxSalary)});
queryString
- expression to execute. (Although this method is
intended to allow execution of relational expressions,
queryString
can actually be any valid Java
expression, for example 1 + 2
.)arguments
- a set of name/value pairs to pass to the expression.
Enumeration
public ResultSet executeSql(String queryString)
public ClassDeclaration init(OJStatement.Argument[] arguments)
public Expression parse(String queryString)
public PreparedResult prepareSql(String queryString)
public PreparedResult prepareSql(SqlNode sqlQuery, Class runtimeContextClass, SqlValidator validator)
protected SqlToRelConverter getSqlToRelConverter(SqlValidator validator, SaffronConnection connection)
public ParseTree validate(ParseTree parseTree, QueryExpander queryExpander)
protected static String getClassRoot()
private static String getCompilerClassName()
protected static String getJavaRoot()
protected String getTempPackageName()
protected String getTempMethodName()
protected String getTempClassName()
private static JavaCompiler createCompiler()
private static Class visibleBaseClass(Class clazz, String fromPackageName)
clazz
which is visible from
fromPackage
.fromClazz
.
private void addDecl(Statement statement, ExpressionList exprList)
private BoundMethod compile(ClassDeclaration decl, Environment env, ParseTree parseTree, OJStatement.Argument[] arguments)
private BoundMethod compile(String packageName, String className, String s, Class[] parameterTypes, String[] parameterNames)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |