public class SqlWhereVisitor
extends CodeVisitorSupport
AST visitor used by DataSet to derive an SQL WHERE clause
and positional parameter list from a supported filter closure.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public List<Object> |
getParameters()Returns the positional parameters collected while building the SQL fragment. |
|
public String |
getWhere()Returns the SQL WHERE fragment built so far. |
|
public void |
setClosure(Closure<?> closure)Supplies the closure whose captured variables may be referenced while the SQL fragment is being derived. |
|
protected String |
tokenAsSql(Token token)Maps a Groovy AST token to its SQL operator representation. |
|
public void |
visitBinaryExpression(BinaryExpression expression)Visits a binary expression and renders it as SQL, collecting any literal values as parameters. |
|
public void |
visitBooleanExpression(BooleanExpression expression)Visits the wrapped boolean expression. |
|
public void |
visitConstantExpression(ConstantExpression expression)Adds a constant value as a positional parameter. |
|
public void |
visitPropertyExpression(PropertyExpression expression)Appends a property reference as a column name. |
|
public void |
visitReturnStatement(ReturnStatement statement)Visits the closure return expression that defines the filter. |
|
public void |
visitVariableExpression(VariableExpression expression)Resolves a variable captured from the enclosing closure scope and adds it as a positional parameter. |
Returns the positional parameters collected while building the SQL fragment.
Returns the SQL WHERE fragment built so far.
Supplies the closure whose captured variables may be referenced while the SQL fragment is being derived.
closure - the closure currently being translatedMaps a Groovy AST token to its SQL operator representation.
token - the AST token to translateVisits a binary expression and renders it as SQL, collecting any literal values as parameters.
expression - the binary expression to visitVisits the wrapped boolean expression.
expression - the boolean expression to visitAdds a constant value as a positional parameter.
expression - the constant expression to visitAppends a property reference as a column name.
expression - the property expression to visitVisits the closure return expression that defines the filter.
statement - the return statement to visitResolves a variable captured from the enclosing closure scope and adds it as a positional parameter.
expression - the variable expression to visit