Package com.github.eikecochu.sqlbuilder
Class Expression
- java.lang.Object
-
- com.github.eikecochu.sqlbuilder.QueryPartImpl<Expression>
-
- com.github.eikecochu.sqlbuilder.Expression
-
- All Implemented Interfaces:
QueryBuilder<Expression>,QueryPart,QueryPartLinked<Expression>,QueryPartSQL<Expression>
public class Expression extends QueryPartImpl<Expression> implements QueryBuilder<Expression>
Expressions are used to create stored procedure calls. They can be used as part of a query or as standalone expression.
-
-
Constructor Summary
Constructors Constructor Description Expression(java.lang.String expression, java.lang.Object... values)Create a new expression with multiple IN parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expressionin(java.lang.Object value)Add a new IN parameterExpressioninOut(java.lang.Object value, int type)Add a new IN/OUT parameterExpressionout(int type)Add a new OUT parameterjava.lang.StringpreparedString(QueryOptions options)Turns this expression into a string with value placeholders for query preparationQueryquery()Returns the Query representation of this builder instanceExpressionsetIn(int index, java.lang.Object value)Sets a parameter to be an IN parameter.ExpressionsetInOut(int index, java.lang.Object value, int type)Sets a parameter to be an IN/OUT parameter.ExpressionsetIns(java.lang.Object... values)Set multiple parameters to be IN parameters.ExpressionsetOut(int index, int type)Sets a parameter to be an OUT parameter.ExpressionsetOuts(java.lang.Integer... types)Set multiple parameters to be OUT parameters.java.lang.Stringstring(QueryOptions options)Transforms this statement into an SQL stringjava.lang.Stringstring(QueryOptions options, boolean prepare)Turns this expression into a string.java.lang.StringtoString()java.lang.StringvalueString(QueryOptions options)Turns this expression into a string with the passed values inserted.-
Methods inherited from class com.github.eikecochu.sqlbuilder.QueryPartImpl
parent, sql
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.eikecochu.sqlbuilder.QueryBuilder
query
-
Methods inherited from interface com.github.eikecochu.sqlbuilder.QueryPartLinked
ext, parent, parent
-
-
-
-
Method Detail
-
in
public Expression in(java.lang.Object value)
Add a new IN parameter- Parameters:
value- the IN parameter value- Returns:
- this instance
-
out
public Expression out(int type)
Add a new OUT parameter- Parameters:
type- the OUT parameter data type- Returns:
- this instance
-
inOut
public Expression inOut(java.lang.Object value, int type)
Add a new IN/OUT parameter- Parameters:
value- the IN parameter valuetype- the OUT parameter data type- Returns:
- this instance
-
setIn
public Expression setIn(int index, java.lang.Object value)
Sets a parameter to be an IN parameter. If it does not exist, parameters will be added automatically until it exists.- Parameters:
index- the parameter index, starting at 0value- the IN parameter value- Returns:
- this instance
-
setIns
public Expression setIns(java.lang.Object... values)
Set multiple parameters to be IN parameters. The index is taken from the position of the passed parameters.- Parameters:
values- the IN parameter value- Returns:
- this instance
-
setOut
public Expression setOut(int index, int type)
Sets a parameter to be an OUT parameter. If it does not exist, parameters will be added automatically until it exists.- Parameters:
index- the parameter index, starting at 0type- the OUT parameter data type- Returns:
- this instance
-
setOuts
public Expression setOuts(java.lang.Integer... types)
Set multiple parameters to be OUT parameters. The index is taken from the position of the passed parameters- Parameters:
types- the OUT parameter data types- Returns:
- this instance
-
setInOut
public Expression setInOut(int index, java.lang.Object value, int type)
Sets a parameter to be an IN/OUT parameter. If it does not exist, parameters will be added automatically until it exists.- Parameters:
index- the parameter index, starting at 0value- the IN parameter valuetype- the OUT parameter data type- Returns:
- this instance
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
string
public java.lang.String string(QueryOptions options)
Description copied from interface:QueryPartTransforms this statement into an SQL string
-
string
public java.lang.String string(QueryOptions options, boolean prepare)
Turns this expression into a string. Will replace values by placeholders if prepare is true, else it will insert the passed values.- Parameters:
options- The QueryOptionsprepare- True to insert value placeholders, false to insert values- Returns:
- The created string
-
preparedString
public java.lang.String preparedString(QueryOptions options)
Turns this expression into a string with value placeholders for query preparation- Parameters:
options- The QueryOptions- Returns:
- The created string
-
valueString
public java.lang.String valueString(QueryOptions options)
Turns this expression into a string with the passed values inserted.- Parameters:
options- The QueryOptions- Returns:
- The created string
-
query
public Query query()
Description copied from interface:QueryBuilderReturns the Query representation of this builder instance- Specified by:
queryin interfaceQueryBuilder<Expression>- Returns:
- The Query representation
-
-