net.esper.eql.expression
Class ExprNode

java.lang.Object
  extended by net.esper.eql.expression.ExprNode
All Implemented Interfaces:
Serializable, ExprEvaluator, ExprValidator, MetaDefItem
Direct Known Subclasses:
ExprAggregateNode, ExprAndNode, ExprArrayNode, ExprBetweenNode, ExprBitWiseNode, ExprCaseNode, ExprCastNode, ExprCoalesceNode, ExprConcatNode, ExprConstantNode, ExprEqualsNode, ExprIdentNode, ExprInNode, ExprInstanceofNode, ExprLikeNode, ExprMathNode, ExprMinMaxRowNode, ExprNotNode, ExprOrNode, ExprPreviousNode, ExprPriorNode, ExprPropertyExistsNode, ExprRegexpNode, ExprRelationalOpNode, ExprStaticMethodNode, ExprSubselectNode, ExprSubstitutionNode, ExprTimestampNode

public abstract class ExprNode
extends Object
implements ExprValidator, ExprEvaluator, MetaDefItem

Superclass for filter nodes in a filter expression tree. Allow validation against stream event types and evaluation of events against filter tree.

See Also:
Serialized Form

Nested Class Summary
protected static class ExprNode.MappedPropertyParseResult
          Encapsulates the parse result parsing a mapped property as a class and method name with args.
 
Constructor Summary
ExprNode()
          Constructor creates a list of child nodes.
 
Method Summary
 void accept(ExprNodeVisitor visitor)
          Accept the visitor.
 void addChildNode(ExprNode childNode)
          Adds a child node.
static boolean deepEquals(ExprNode nodeOne, ExprNode nodeTwo)
          Compare two expression nodes and their children in exact child-node sequence, returning true if the 2 expression nodes trees are equals, or false if they are not equals.
 void dumpDebug(String prefix)
          Recursively print out all nodes.
abstract  boolean equalsNode(ExprNode node)
          Return true if a expression node semantically equals the current node, or false if not.
 LinkedList<ExprNode> getChildNodes()
          Returns list of child nodes.
 ExprNode getValidatedSubtree(StreamTypeService streamTypeService, MethodResolutionService methodResolutionService, ViewResourceDelegate viewResourceDelegate, TimeProvider timeProvider)
          Validates the expression node subtree that has this node as root.
abstract  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.
protected static ExprNode.MappedPropertyParseResult parseMappedProperty(String property)
          Parse the mapped property into classname, method and string argument.
abstract  String toExpressionString()
          Returns the expression node rendered as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.esper.eql.expression.ExprValidator
getType, validate
 
Methods inherited from interface net.esper.eql.expression.ExprEvaluator
evaluate
 

Constructor Detail

ExprNode

public ExprNode()
Constructor creates a list of child nodes.

Method Detail

toExpressionString

public abstract String toExpressionString()
Returns the expression node rendered as a string.

Returns:
string rendering of expression

isConstantResult

public abstract 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.

Returns:
true for constant evaluation value, false for non-constant evaluation value

equalsNode

public abstract boolean equalsNode(ExprNode node)
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.

Parameters:
node - to compare to
Returns:
true if semantically equal, or false if not equals

getValidatedSubtree

public ExprNode getValidatedSubtree(StreamTypeService streamTypeService,
                                    MethodResolutionService methodResolutionService,
                                    ViewResourceDelegate viewResourceDelegate,
                                    TimeProvider timeProvider)
                             throws ExprValidationException
Validates the expression node subtree that has this node as root. Some of the nodes of the tree, including the root, might be replaced in the process.

Parameters:
streamTypeService - - serves stream type information
methodResolutionService - - for resolving class names in library method invocations
viewResourceDelegate - - delegates for view resources to expression nodes
timeProvider - - provides engine current time
Returns:
the root node of the validated subtree, possibly different than the root node of the unvalidated subtree
Throws:
ExprValidationException - when the validation fails

accept

public void accept(ExprNodeVisitor visitor)
Accept the visitor. The visitor will first visit the parent then visit all child nodes, then their child nodes.

The visitor can decide to skip child nodes by returning false in isVisit.

Parameters:
visitor - to visit each node and each child node.

addChildNode

public final void addChildNode(ExprNode childNode)
Adds a child node.

Parameters:
childNode - is the child evaluation tree node to add

getChildNodes

public final LinkedList<ExprNode> getChildNodes()
Returns list of child nodes.

Returns:
list of child nodes

dumpDebug

public final void dumpDebug(String prefix)
Recursively print out all nodes.

Parameters:
prefix - is printed out for naming the printed info

deepEquals

public static boolean deepEquals(ExprNode nodeOne,
                                 ExprNode nodeTwo)
Compare two expression nodes and their children in exact child-node sequence, returning true if the 2 expression nodes trees are equals, or false if they are not equals.

Recursive call since it uses this method to compare child nodes in the same exact sequence. Nodes are compared using the equalsNode method.

Parameters:
nodeOne - - first expression top node of the tree to compare
nodeTwo - - second expression top node of the tree to compare
Returns:
false if this or all child nodes are not equal, true if equal

parseMappedProperty

protected static ExprNode.MappedPropertyParseResult parseMappedProperty(String property)
Parse the mapped property into classname, method and string argument. Mind this has been parsed already and is a valid mapped property.

Parameters:
property - is the string property to be passed as a static method invocation
Returns:
descriptor object