ModSQL
Class Operator_Logical

java.lang.Object
  |
  +--ModSQL.AbstractFunction
        |
        +--ModSQL.Operator
              |
              +--ModSQL.Operator_Logical
All Implemented Interfaces:
Function

final class Operator_Logical
extends Operator

SQL operators AND and OR.

Author:
chris.studholme@utoronto.ca

Field Summary
protected  boolean and
          True for AND, false for OR.
protected  Boolean constant_value
          Result of operator applied to all constant parameters.
 
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_Logical(boolean and)
          Constructor.
 
Method Summary
 void addParameter(Function function)
          Adds a function to the list of parameters maintained by this operator.
 Object evaluate(boolean aggregate)
          Evaluate parameters and compute the function.
 Object evaluate(int match_op, Object match_value)
          Evaluate parameters and compute the function.
 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.
 void optimize()
          Prepare the function for use.
 
Methods inherited from class ModSQL.Operator
addAllParameters, addAllParametersNegate, addAllParametersNot, removeDoubleNegation, removeDoubleNot
 
Methods inherited from class ModSQL.AbstractFunction
convertToSQLType, evaluateConstantParameters, evaluateOrder, evaluateParameters, evaluateParameters, getCompatableType, getObjectSQLType, getParameter, getParameterCount, isAggregate, isConstant, postfixParameters, prefixParameters, registerWith, reset, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

and

protected boolean and
True for AND, false for OR.

constant_value

protected Boolean constant_value
Result of operator applied to all constant parameters.
Constructor Detail

Operator_Logical

public Operator_Logical(boolean and)
Constructor.
Parameters:
and - true for AND, false for OR
Method Detail

addParameter

public void addParameter(Function function)
                  throws SQLException
Adds a function to the list of parameters maintained by this operator. If the function is of type Operator_Not and has double NOT, the double NOT operators will be removed. If the function is of type Operator_Logical, or Operator_Not followed by Operator_Logical, the functions parameters (conjuncts/disjuncts) may be added instead of the function (with NOT operators applied as needed).
Overrides:
addParameter in class AbstractFunction
Parameters:
function - function to add
Throws:
SQLException - if a database error occurs

optimize

public void optimize()
              throws SQLException

Prepare the function for use. This method will check the parameters and apply the operator to all constant parameters.

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

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 compute the function.
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 compute the function.
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