|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--ModSQL.AbstractFunction
|
+--ModSQL.Function_Math
This class implements standard SQL math functions: ABS, CEIL, FLOOR, GREATEST, LEAST, MOD, POWER, ROUND, SIGN, and SQRT.
| Field Summary | |
static int |
ABS
Function is ABS(). |
static int |
CEIL
Function is CEIL(). |
static int |
FLOOR
Function is FLOOR(). |
static int |
GREATEST
Function is GREATEST(). |
static int |
LEAST
Function is LEAST(). |
static int |
MOD
Function is MOD(). |
private int |
op
Which function are we? One of the above constants. |
static int |
POWER
Function is POWER(). |
private int |
return_type
SQL return type for this function. |
static int |
ROUND
Function is ROUND(). |
static int |
SIGN
Function is SIGN(). |
static int |
SQRT
Function is SQRT(). |
| Fields inherited from class ModSQL.AbstractFunction |
all_constant, constant_non_null, evaluate_order, evaluate_order_array, out_of_order, parameter_constant, parameter_value, parameters, parameters_array |
| Fields inherited from interface ModSQL.Function |
MATCH_BEGINS, MATCH_EQU, MATCH_GT, MATCH_GTE, MATCH_LT, MATCH_LTE, MATCH_NE |
| Constructor Summary | |
Function_Math(int op)
Constructor. |
|
| Method Summary | |
Object |
evaluate(boolean aggregate)
Evaluate parameters and compute function. |
static Function |
forName(String name)
Returns a new instance of this class if name is recognized. |
String |
functionName()
Returns the name of this function for use by toString() method. |
int |
getMaxResultSize()
Returns -1 as this function will never return a String constant. |
int |
getSQLType()
Returns the SQL type of this function. |
void |
optimize()
Prepare the function for use. |
static Number |
power(Number n,
Number e,
int return_type)
Compute n to the power of e and return a number of the desired type. |
static Number |
round(Number n)
Round number to nearest integer. |
static Number |
round(Number n,
Number d)
Round number of specified number of decimal places. |
| Methods inherited from class ModSQL.AbstractFunction |
addParameter, convertToSQLType, evaluate, evaluateConstantParameters, evaluateOrder, evaluateParameters, evaluateParameters, getCompatableType, getObjectSQLType, getParameter, getParameterCount, isAggregate, isConstant, postfixParameters, prefixParameters, registerWith, reset, toString |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int ABS
public static final int CEIL
public static final int FLOOR
public static final int GREATEST
public static final int LEAST
public static final int MOD
public static final int POWER
public static final int ROUND
public static final int SIGN
public static final int SQRT
private int op
private int return_type
| Constructor Detail |
public Function_Math(int op)
op - function type| Method Detail |
public static Function forName(String name)
name - name of function to find
public void optimize()
throws SQLException
optimize in class AbstractFunctionSQLException - if the parameters are invalidpublic int getSQLType()
public int getMaxResultSize()
public String functionName()
functionName in class AbstractFunction
public Object evaluate(boolean aggregate)
throws SQLException,
EndOfTable
Evaluate parameters and compute function.
aggregate - passed to parametersSQLException - if a database-access error occursEndOfTable - if thrown by a parameterpublic static Number round(Number n)
n - number to round
public static Number round(Number n,
Number d)
n - number to roundd - number of decimal places to round to (integer)
public static Number power(Number n,
Number e,
int return_type)
throws SQLException
n - basee - exponentreturn_type - SQL type of object to returnSQLException - if type mismatch
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||