public class CompositeOperandTypeChecker extends Object implements SqlOperandTypeChecker
SqlOperandTypeChecker rules to be
combined into one rule. For example, allowing an operand to be either string
or numeric could be done by:
Similary a rule that would only allow a numeric literal can be done by:CompositeOperandsTypeChecking newCompositeRule = new CompositeOperandsTypeChecking( Composition.OR, new SqlOperandTypeChecker[]{stringRule, numericRule});
CompositeOperandsTypeChecking newCompositeRule = new CompositeOperandsTypeChecking( Composition.AND, new SqlOperandTypeChecker[]{numericRule, literalRule});
Finally, creating a signature expecting a string for the first operand and a numeric for the second operand can be done by:
CompositeOperandsTypeChecking newCompositeRule = new CompositeOperandsTypeChecking( Composition.SEQUENCE, new SqlOperandTypeChecker[]{stringRule, numericRule});
For SEQUENCE composition, the rules must be instances of SqlSingleOperandTypeChecker, and signature generation is not supported. For AND composition, only the first rule is used for signature generation.
| Modifier and Type | Class and Description |
|---|---|
static class |
CompositeOperandTypeChecker.Composition
How operands are composed.
|
SqlOperandTypeChecker.Consistency| Modifier and Type | Field and Description |
|---|---|
protected com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> |
allowedRules |
protected CompositeOperandTypeChecker.Composition |
composition |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkOperandTypes(SqlCallBinding callBinding,
boolean throwOnFailure)
Checks the types of all operands to an operator call.
|
String |
getAllowedSignatures(SqlOperator op,
String opName)
Returns a string describing the allowed formal signatures of a call, e.g.
|
SqlOperandTypeChecker.Consistency |
getConsistency()
Returns the strategy for making the arguments have consistency types.
|
SqlOperandCountRange |
getOperandCountRange() |
com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> |
getRules() |
protected final com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules
protected final CompositeOperandTypeChecker.Composition composition
public com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> getRules()
public SqlOperandTypeChecker.Consistency getConsistency()
SqlOperandTypeCheckergetConsistency in interface SqlOperandTypeCheckerpublic String getAllowedSignatures(SqlOperator op, String opName)
SqlOperandTypeCheckergetAllowedSignatures in interface SqlOperandTypeCheckerop - the operator being checkedopName - name to use for the operator in case of aliasingpublic SqlOperandCountRange getOperandCountRange()
getOperandCountRange in interface SqlOperandTypeCheckerpublic boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
SqlOperandTypeCheckercheckOperandTypes in interface SqlOperandTypeCheckercallBinding - description of the call to be checkedthrowOnFailure - whether to throw an exception if check fails
(otherwise returns false in that case)Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.