org.eigenbase.sql.fun
Class SqlLikeOperator

java.lang.Object
  extended by org.eigenbase.sql.SqlOperator
      extended by org.eigenbase.sql.SqlSpecialOperator
          extended by org.eigenbase.sql.fun.SqlLikeOperator

public class SqlLikeOperator
extends SqlSpecialOperator

An operator describing the LIKE and SIMILAR operators.

Syntax of the two operators:

NOTE If the NOT clause is present the parser will generate a eqvivalent to NOT (src LIKE pattern ...)

Since:
Jan 21, 2004
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/fun/SqlLikeOperator.java#19 $
Author:
Wael Chatila

Field Summary
private  boolean negated
           
 
Fields inherited from class org.eigenbase.sql.SqlOperator
MaxPrec, NL
 
Constructor Summary
SqlLikeOperator(String name, SqlKind kind, boolean negated)
          Creates a SqlLikeOperator.
 
Method Summary
 boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
          Checks that the operand values in a SqlCall to this operator are valid.
 SqlOperandCountRange getOperandCountRange()
          Returns a constraint on the number of operands expected by this operator.
 boolean isNegated()
          Returns whether this is the 'NOT LIKE' operator.
 int reduceExpr(int opOrdinal, List<Object> list)
          Reduces a list of operators and arguments according to the rules of precedence and associativity.
 void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec)
          Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.
 
Methods inherited from class org.eigenbase.sql.SqlSpecialOperator
getSyntax
 
Methods inherited from class org.eigenbase.sql.SqlOperator
acceptCall, acceptCall, adjustType, argumentMustBeScalar, checkOperandCount, createCall, createCall, createCall, createCall, deriveType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getName, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isName, leftPrec, preValidateCall, requiresDecimalExpansion, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateCall, validateOperands
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

negated

private final boolean negated
Constructor Detail

SqlLikeOperator

SqlLikeOperator(String name,
                SqlKind kind,
                boolean negated)
Creates a SqlLikeOperator.

Parameters:
name - Operator name
kind - Kind
negated - Whether this is 'NOT LIKE'
Method Detail

isNegated

public boolean isNegated()
Returns whether this is the 'NOT LIKE' operator.

Returns:
whether this is 'NOT LIKE'

getOperandCountRange

public SqlOperandCountRange getOperandCountRange()
Description copied from class: SqlOperator
Returns a constraint on the number of operands expected by this operator. Subclasses may override this method; when they don't, the range is derived from the SqlOperandTypeChecker associated with this operator.

Overrides:
getOperandCountRange in class SqlOperator
Returns:
acceptable range

checkOperandTypes

public boolean checkOperandTypes(SqlCallBinding callBinding,
                                 boolean throwOnFailure)
Description copied from class: SqlOperator
Checks that the operand values in a SqlCall to this operator are valid. Subclasses must either override this method or supply an instance of SqlOperandTypeChecker to the constructor.

Overrides:
checkOperandTypes in class SqlOperator
Parameters:
callBinding - description of call
throwOnFailure - whether to throw an exception if check fails (otherwise returns false in that case)
Returns:
whether check succeeded

unparse

public void unparse(SqlWriter writer,
                    SqlNode[] operands,
                    int leftPrec,
                    int rightPrec)
Description copied from class: SqlOperator
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.

The default implementation of this method delegates to SqlSyntax.unparse(org.eigenbase.sql.SqlWriter, org.eigenbase.sql.SqlOperator, org.eigenbase.sql.SqlNode[], int, int).

Overrides:
unparse in class SqlSpecialOperator

reduceExpr

public int reduceExpr(int opOrdinal,
                      List<Object> list)
Description copied from class: SqlSpecialOperator
Reduces a list of operators and arguments according to the rules of precedence and associativity. Returns the ordinal of the node which replaced the expression.

The default implementation throws UnsupportedOperationException.

Overrides:
reduceExpr in class SqlSpecialOperator
Parameters:
opOrdinal - indicating the ordinal of the current operator in the list on which a possible reduction can be made
list - List of alternating SqlParserUtil.ToTreeListItem and SqlNode
Returns:
ordinal of the node which replaced the expression