|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--ModSQL.AbstractFunction
|
+--ModSQL.Operator
|
+--ModSQL.Operator_In
SQL comparison operators with a table on the RHS.
| Field Summary | |
private int[] |
compare_type
Per column comparison type. |
static int |
EQU
Comparison operator (equal). |
static int |
GT
Comparison operator (greater than). |
static int |
GTE
Comparison operator (greater or equal). |
private HashSet |
hashset
Hash table to speedup tests for equality. |
private boolean |
hashset_hasnull
Does the hash table contain a null value. |
static int |
LT
Comparison operator (less than). |
static int |
LTE
Comparison operator (less or equal). |
private boolean |
match_all
True if all rows must match. |
private int |
ncolumns
Number of columns in row-constructor. |
static int |
NE
Comparison operator (not equal). |
private int |
op
Which operator? One of the above constants. |
private RowConstructor |
row
Row-constructor on LHS if needed. |
private Table |
table
Table on right-hand-side (RHS). |
| 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 | |
Operator_In(int op,
boolean match_all)
Constructor. |
|
| Method Summary | |
Object |
evaluate(boolean aggregate)
Evaluate parameters and compare. |
Object |
evaluate(int match_op,
Object match_value)
Evaluate parameters and compare. |
String |
functionName()
Returns the name of this function for use by toString() method. |
int |
getMaxResultSize()
Returns -1 as this operator will never return a String object. |
int |
getSQLType()
Returns Types.BIT. |
boolean |
isAggregate()
Determine if this function will return a value that is an aggregate of many database rows. |
boolean |
isConstant()
Determine if this function returns a constant value. |
void |
optimize()
Prepare the function for use. |
String |
postfixParameters()
This method returns ",RHS", provided a table has been specified for the RHS. |
void |
registerWith(Object o)
Since table is not a normal parameter, we need to ensure objects to register with get passed to it. |
void |
setTable(Table table)
Specify the table to be scanned. |
Boolean |
testRow(Object[] r1,
Object[] r2)
Compare two rows according to op and using compare_type array. |
| Methods inherited from class ModSQL.Operator |
addAllParameters, addAllParametersNegate, addAllParametersNot, removeDoubleNegation, removeDoubleNot |
| Methods inherited from class ModSQL.AbstractFunction |
addParameter, convertToSQLType, evaluateConstantParameters, evaluateOrder, evaluateParameters, evaluateParameters, getCompatableType, getObjectSQLType, getParameter, getParameterCount, prefixParameters, reset, toString |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int EQU
public static final int GT
public static final int GTE
public static final int LT
public static final int LTE
public static final int NE
private int op
private boolean match_all
private Table table
private int[] compare_type
private RowConstructor row
private int ncolumns
private HashSet hashset
private boolean hashset_hasnull
| Constructor Detail |
public Operator_In(int op,
boolean match_all)
op - comparison operatormatch_all - true to match all rows| Method Detail |
public void setTable(Table table)
table - table on RHS of comparison
public void registerWith(Object o)
throws SQLException
registerWith in class AbstractFunctiono - object to register withSQLException - if a database error occurs
public void optimize()
throws SQLException
Prepare the function for use. This method checks the parameters and figures out how the comparison will take place (what type to use).
If the RHS consists of a single column, the operator is EQU or NE, and the table is constant, a hash table of the rows is created to greatly speed up comparisons.
optimize in class AbstractFunctionSQLException - if the parameters are invalidpublic String functionName()
functionName in class AbstractFunctionpublic String postfixParameters()
postfixParameters in class AbstractFunction
public boolean isConstant()
throws SQLException
isConstant in class AbstractFunctionSQLException - if a database-access error occurs
public boolean isAggregate()
throws SQLException
Determine if this function will return a value that is an aggregate of many database rows. The function is an aggregate if the LHS is an aggregate and the RHS is constant. If the LHS is an aggregate, but the RHS is not constant, an exception is thrown.
isAggregate in class AbstractFunctionSQLException - if a database-access error occurspublic int getSQLType()
public int getMaxResultSize()
public Object evaluate(boolean aggregate)
throws SQLException,
EndOfTable
aggregate - passed to parametersSQLException - if a database-access error occursEndOfTable - if thrown by a parameter
public Object evaluate(int match_op,
Object match_value)
throws SQLException,
EndOfTable
evaluate in class AbstractFunctionmatch_op - how the value should be matchedmatch_value - desired valueSQLException - if a database-access error occursEndOfTable - if thrown by a parameter
public Boolean testRow(Object[] r1,
Object[] r2)
throws SQLException
r1 - left rowr2 - right rowSQLException - if op is invalid or on type mismatch
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||