com.espertech.esper.epl.expression.funcs
Class ExprCaseNode

java.lang.Object
  extended by com.espertech.esper.epl.expression.core.ExprNodeBase
      extended by com.espertech.esper.epl.expression.funcs.ExprCaseNode
All Implemented Interfaces:
ExprEvaluator, ExprEvaluatorTypableReturn, ExprNode, ExprValidator, MetaDefItem, java.io.Serializable

public class ExprCaseNode
extends ExprNodeBase
implements ExprEvaluator, ExprEvaluatorTypableReturn

Represents the case-when-then-else control flow function is an expression tree.

See Also:
Serialized Form

Nested Class Summary
static class ExprCaseNode.CaseAnalysis
           
 
Constructor Summary
ExprCaseNode(boolean isCase2)
          Ctor.
 
Method Summary
 boolean equalsNode(ExprNode node_)
          Return true if a expression node semantically equals the current node, or false if not.
 java.lang.Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
          Evaluate event tuple and return result.
 java.lang.Object[][] evaluateTypableMulti(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 java.lang.Object[] evaluateTypableSingle(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 ExprEvaluator getExprEvaluator()
           
 ExprPrecedenceEnum getPrecedence()
          Returns precedence.
 java.util.LinkedHashMap<java.lang.String,java.lang.Object> getRowProperties()
          Return null to indicate no row-type result available, or a map of property names and types to indicate a row-type result is available.
 java.lang.Class getType()
          Returns the type that the node's evaluate method returns an instance of.
 boolean isCase2()
          Returns true if this is a switch-type case.
 boolean isConstantResult()
          Returns true if the expression node's evaluation value doesn't depend on any events data, as must be determined at validation time, which is bottom-up and therefore reliably allows each node to determine constant value.
 java.lang.Boolean isMultirow()
          Return true for multi-row return, return false for return of single row only
 void toPrecedenceFreeEPL(java.io.StringWriter writer)
           
 ExprNode validate(ExprValidationContext validationContext)
           
 
Methods inherited from class com.espertech.esper.epl.expression.core.ExprNodeBase
accept, accept, acceptChildnodes, addChildNode, addChildNodes, addChildNodeToFront, getChildNodes, replaceUnlistedChildNode, setChildNode, setChildNodes, toEPL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExprCaseNode

public ExprCaseNode(boolean isCase2)
Ctor.

Parameters:
isCase2 - is an indicator of which Case statement we are working on.

True indicates a 'Case2' statement with syntax "case a when a1 then b1 else b2".

False indicates a 'Case1' statement with syntax "case when a=a1 then b1 else b2".

Method Detail

getExprEvaluator

public ExprEvaluator getExprEvaluator()
Specified by:
getExprEvaluator in interface ExprNode

isCase2

public boolean isCase2()
Returns true if this is a switch-type case.

Returns:
true for switch-type case, or false for when-then type

validate

public ExprNode validate(ExprValidationContext validationContext)
                  throws ExprValidationException
Specified by:
validate in interface ExprValidator
Throws:
ExprValidationException

isConstantResult

public boolean isConstantResult()
Description copied from interface: ExprNode
Returns true if the expression node's evaluation value doesn't depend on any events data, as must be determined at validation time, which is bottom-up and therefore reliably allows each node to determine constant value.

Specified by:
isConstantResult in interface ExprNode
Returns:
true for constant evaluation value, false for non-constant evaluation value

getType

public java.lang.Class getType()
Description copied from interface: ExprEvaluator
Returns the type that the node's evaluate method returns an instance of.

Specified by:
getType in interface ExprEvaluator
Returns:
type returned when evaluated

getRowProperties

public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getRowProperties()
                                                                            throws ExprValidationException
Description copied from interface: ExprEvaluatorTypableReturn
Return null to indicate no row-type result available, or a map of property names and types to indicate a row-type result is available.

Specified by:
getRowProperties in interface ExprEvaluatorTypableReturn
Returns:
map of property names and types or null
Throws:
ExprValidationException - if the expression is invalid

evaluate

public java.lang.Object evaluate(EventBean[] eventsPerStream,
                                 boolean isNewData,
                                 ExprEvaluatorContext exprEvaluatorContext)
Description copied from interface: ExprEvaluator
Evaluate event tuple and return result.

Specified by:
evaluate in interface ExprEvaluator
Parameters:
eventsPerStream - - event tuple
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
exprEvaluatorContext - context for expression evaluation
Returns:
evaluation result, a boolean value for OR/AND-type evalution nodes.

isMultirow

public java.lang.Boolean isMultirow()
Description copied from interface: ExprEvaluatorTypableReturn
Return true for multi-row return, return false for return of single row only

Specified by:
isMultirow in interface ExprEvaluatorTypableReturn
Returns:
multi-row flag

evaluateTypableSingle

public java.lang.Object[] evaluateTypableSingle(EventBean[] eventsPerStream,
                                                boolean isNewData,
                                                ExprEvaluatorContext context)
Specified by:
evaluateTypableSingle in interface ExprEvaluatorTypableReturn

evaluateTypableMulti

public java.lang.Object[][] evaluateTypableMulti(EventBean[] eventsPerStream,
                                                 boolean isNewData,
                                                 ExprEvaluatorContext context)
Specified by:
evaluateTypableMulti in interface ExprEvaluatorTypableReturn

equalsNode

public boolean equalsNode(ExprNode node_)
Description copied from interface: ExprNode
Return true if a expression node semantically equals the current node, or false if not.

Concrete implementations should compare the type and any additional information that impact the evaluation of a node.

Specified by:
equalsNode in interface ExprNode
Parameters:
node_ - to compare to
Returns:
true if semantically equal, or false if not equals

toPrecedenceFreeEPL

public void toPrecedenceFreeEPL(java.io.StringWriter writer)
Specified by:
toPrecedenceFreeEPL in class ExprNodeBase

getPrecedence

public ExprPrecedenceEnum getPrecedence()
Description copied from interface: ExprNode
Returns precedence.

Specified by:
getPrecedence in interface ExprNode
Returns:
precedence

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com