: Class Operator_In

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ModSQL
Class Operator_In

    java.lang.Object
      |
      +--ModSQL.AbstractFunction
            |
            +--ModSQL.Operator
                  |
                  +--ModSQL.Operator_In

All Implemented Interfaces:
  Function

final class Operator_In
extends Operator

SQL comparison operators with a table on the RHS.

Author:
  chris.studholme@utoronto.ca

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
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait`

Field Detail

### EQU

    public static final int EQU

  Comparison operator (equal).

### GT

    public static final int GT

  Comparison operator (greater than).

### GTE

    public static final int GTE

  Comparison operator (greater or equal).

### LT

    public static final int LT

  Comparison operator (less than).

### LTE

    public static final int LTE

  Comparison operator (less or equal).

### NE

    public static final int NE

  Comparison operator (not equal).

### op

    private int op

  Which operator? One of the above constants.

### match_all

    private boolean match_all

  True if all rows must match.

### table

    private Table table

  Table on right-hand-side (RHS).

### compare_type

    private int[] compare_type

  Per column comparison type.

### row

    private RowConstructor row

  Row-constructor on LHS if needed.

### ncolumns

    private int ncolumns

  Number of columns in row-constructor.

### hashset

    private HashSet hashset

  Hash table to speedup tests for equality.

### hashset_hasnull

    private boolean hashset_hasnull

  Does the hash table contain a null value.

Constructor Detail

### Operator_In

    public Operator_In(int op,
                       boolean match_all)

  Constructor.
  Parameters:
    `op` - comparison operator
    `match_all` - true to match all rows

Method Detail

### setTable

    public void setTable(Table table)

  Specify the table to be scanned.
  Parameters:
    `table` - table on RHS of comparison

### registerWith

    public void registerWith(Object o)
                      throws SQLException

  Since table is not a normal parameter, we need to ensure objects to register with get passed to it. This method also ensures that the LHS gets these objects too.
  Overrides:
    `registerWith` in class `AbstractFunction`
  Parameters:
    `o` - object to register with
  Throws:
    `SQLException` - if a database error occurs

### optimize

    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.

  Overrides:
    `optimize` in class `AbstractFunction`
  Throws:
    `SQLException` - if the parameters are invalid

### functionName

    public String functionName()

  Returns the name of this function for use by toString() method.
  Overrides:
    `functionName` in class `AbstractFunction`
  Returns:
    name of function

### postfixParameters

    public String postfixParameters()

  This method returns ",RHS", provided a table has been specified for the RHS.
  Overrides:
    `postfixParameters` in class `AbstractFunction`
  Returns:
    table parameter as a string

### isConstant

    public boolean isConstant()
                       throws SQLException

  Determine if this function returns a constant value. This method returns true if both the LHS and RHS are constant.
  Overrides:
    `isConstant` in class `AbstractFunction`
  Returns:
    true if the value returned is constant
  Throws:
    `SQLException` - if a database-access error occurs

### isAggregate

    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.

  Overrides:
    `isAggregate` in class `AbstractFunction`
  Returns:
    true if the function aggregates several rows of data
  Throws:
    `SQLException` - if a database-access error occurs

### getSQLType

    public int getSQLType()

  Returns Types.BIT.
  Returns:
    SQL type of data to be returned

### getMaxResultSize

    public int getMaxResultSize()

  Returns -1 as this operator will never return a String object.
  Returns:
    maximum size of String returned or -1 if unknown

### evaluate

    public Object evaluate(boolean aggregate)
                    throws SQLException,
                           EndOfTable

  Evaluate parameters and compare.
  Parameters:
    `aggregate` - passed to parameters
  Returns:
    result object
  Throws:
    `SQLException` - if a database-access error occurs
    `EndOfTable` - if thrown by a parameter

### evaluate

    public Object evaluate(int match_op,
                           Object match_value)
                    throws SQLException,
                           EndOfTable

  Evaluate parameters and compare.
  Overrides:
    `evaluate` in class `AbstractFunction`
  Parameters:
    `match_op` - how the value should be matched
    `match_value` - desired value
  Returns:
    result object
  Throws:
    `SQLException` - if a database-access error occurs
    `EndOfTable` - if thrown by a parameter

### testRow

    public Boolean testRow(Object[] r1,
                           Object[] r2)
                    throws SQLException

  Compare two rows according to op and using compare_type array.
  Parameters:
    `r1` - left row
    `r2` - right row
  Returns:
    result of comparison
  Throws:
    `SQLException` - if op is invalid or on type mismatch

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD