public class SqlParserBase
extends java.lang.Object
Supported extensions
The parser supports extensions described in PropertiesSubstitutor
.
Additionally ? prefix is used for expressions which should be injected as prepared statement parameters.
Example:
var=_name
id=11
--------------------------------------
select * FROM table${var} where id=?id
--- is transformed to ---
select * FROM table_name where id=? where statement parameter has value of 11
Notes:
--only ${prop} and ?surname are handled
SELECT * FROM "Table" WHERE NAME="?John${prop}" and SURNAME=?surname;
These extensions are handled by subclasses in handleParameter(String, boolean, boolean)
method.Constructor and Description |
---|
SqlParserBase() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
handleParameter(java.lang.String name,
boolean expression,
boolean jdbcParam)
Called when parameter is encountered in SQL.
|
void |
parse(java.io.Reader reader)
Parses SQL script.
|
void |
parse(SqlTokenizer tok) |
protected void |
statementParsed(java.lang.String sql)
Invoked when SQL statement has been processed and all expressions handled.
|
public void parse(java.io.Reader reader)
reader
- reader with SQL script.public void parse(SqlTokenizer tok)
protected java.lang.String handleParameter(java.lang.String name, boolean expression, boolean jdbcParam)
name
- parameter name or expressionexpression
- true if specified name is an expression, not a simple property referencejdbcParam
- true if parameter value should be passed as prepared statement parameter. Othewise it's value should be inserted
into statement text.protected void statementParsed(java.lang.String sql)
sql
- content of the preprocessed statement.Copyright © Copyright 2006-2019 The Scriptella Project Team.