| java.lang.Object org.josql.expressions.Expression org.josql.expressions.ValueExpression org.josql.expressions.ArithmeticExpression
ArithmeticExpression | public class ArithmeticExpression extends ValueExpression (Code) | | Represents the arithmetic expressions: *, +, /, - and %.
It should be noted that ALL numbers in JoSQL are represented as double values, this
allows for easy arithmetic operations without the fear of losing precision or casting
issues.
|
ADDITION | final public static int ADDITION(Code) | | |
DIVIDE | final public static int DIVIDE(Code) | | |
MODULUS | final public static int MODULUS(Code) | | |
MULTIPLY | final public static int MULTIPLY(Code) | | |
SUBTRACT | final public static int SUBTRACT(Code) | | |
evaluate | public Object evaluate(Object o, Query q) throws QueryExecutionException(Code) | | Evaulate this expression. Apart from the special cases the LHS and RHS must evaluate
to an instance of java.lang.Number otherwise a QueryExecutionException is
thrown.
Special cases:
- If the type of the expression is + and either LHS or RHS are NOT numbers
then the String concatentation of them both are returned.
This works the same as in Java.
- If the type of the expression is / and the RHS is 0 then 0 is returned.
Parameters: o - The object to perform the expression on. Parameters: q - The Query object. The result of the expression, see the "special cases" for the exceptions to what wouldbe the intuitive result. throws: QueryExecutionException - If an error occurs during processing. |
getExpectedReturnType | public Class getExpectedReturnType(Query q) throws QueryParseException(Code) | | Return the expected return type. This just returns the result of calling this
method on the LHS.
Parameters: q - The Query object. The expected return type class. throws: QueryParseException - If something goes wrong in determining the return type. |
getType | public int getType()(Code) | | |
isTrue | public boolean isTrue(Object o, Query q) throws QueryExecutionException(Code) | | Determine whether this arithmetic expression evaluates to true.
Whilst this seems a little bizarre this method is needed to allow
artithmetic expressions to be used in the columns part of the SELECT.
Thus the following could be performed:
SELECT 10 + 20
FROM java.lang.Object
The rules are as follows:
Parameters: o - The object to perform the expression on. Parameters: q - The Query object. As according to the rules above. throws: QueryExecutionException - If something goes wrong during the evaluation of the expression. |
setType | public void setType(int t)(Code) | | |
|
|