|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--saffron.Statement
A Statement
is used to execute a saffron (or regular Java)
expression dynamically.
Nested Class Summary | |
static class |
Statement.Argument
An Argument supplies a name/value pair to a statement. |
(package private) static interface |
Statement.Binder
|
(package private) static class |
Statement.Thunk
|
Field Summary | |
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 Class |
resultClass
Class which should be returned by execution. |
Constructor Summary | |
Statement()
|
Method Summary | |
private void |
addDecl(Statement statement,
ExpressionList exprList)
|
private ParseTree |
addResultCast(Expression expression)
|
private Statement.Thunk |
compile(ClassDeclaration decl,
Environment env,
ParseTree parseTree,
Statement.Argument[] arguments)
|
private Statement.Thunk |
compile(String packageName,
String className,
String s,
Class[] parameterTypes,
String[] parameterNames)
|
private static JavaCompiler |
createCompiler()
|
Object |
evaluate(ClassDeclaration decl,
ParseTree parseTree,
Statement.Argument[] arguments)
Evaluates an expression represented by a parse tree. |
Object |
execute(String queryString,
Statement.Argument[] arguments)
Executes a query string, passing in a set of arguments, and returns the result. |
ResultSet |
executeSql(String queryString,
Connection connection)
|
private static String |
getClassRoot()
|
private static String |
getCompilerClassName()
|
Environment |
getEnvironment()
|
private static String |
getJavaRoot()
|
private static String |
getTempPackageName()
|
ClassDeclaration |
init(Statement.Argument[] arguments)
|
Expression |
parse(String queryString)
|
private PreparedResult |
prepareExplanation(ParseTree parseTree)
|
PreparedResult |
prepareSql(String queryString,
Connection connection)
|
void |
setResultClass(Class resultClass)
|
private Expression |
toExpression(SqlNode sqlNode,
Connection connection)
|
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,
String fromClassName)
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 |
Environment env
int executionCount
private JavaCompiler javaCompiler
private Class resultClass
public static final String connectionVariable
Constructor Detail |
public Statement()
Method Detail |
public Environment getEnvironment()
public void setResultClass(Class resultClass)
public Object execute(String queryString, Statement.Argument[] arguments)
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
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)});
public Expression parse(String queryString)
public ParseTree validate(ParseTree parseTree, QueryExpander queryExpander)
public ClassDeclaration init(Statement.Argument[] arguments)
private static Class visibleBaseClass(Class clazz, String fromPackageName, String fromClassName)
clazz
which is visible from
fromPackage
.fromClazz
.
private static String getTempPackageName()
private static String getJavaRoot()
private static String getClassRoot()
private static String getCompilerClassName()
private static JavaCompiler createCompiler()
public Object evaluate(ClassDeclaration decl, ParseTree parseTree, Statement.Argument[] arguments)
private Statement.Thunk compile(ClassDeclaration decl, Environment env, ParseTree parseTree, Statement.Argument[] arguments)
private Statement.Thunk compile(String packageName, String className, String s, Class[] parameterTypes, String[] parameterNames)
private void addDecl(Statement statement, ExpressionList exprList)
public ResultSet executeSql(String queryString, Connection connection)
public PreparedResult prepareSql(String queryString, Connection connection)
private PreparedResult prepareExplanation(ParseTree parseTree)
private Expression toExpression(SqlNode sqlNode, Connection connection)
private ParseTree addResultCast(Expression expression)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |