Venice 0.751beta

nz.org.venice.parser.expression
Class LoggingExpression

java.lang.Object
  extended bynz.org.venice.parser.expression.AbstractExpression
      extended bynz.org.venice.parser.expression.UnaryExpression
          extended bynz.org.venice.parser.expression.LoggingExpression
All Implemented Interfaces:
java.lang.Cloneable, Expression

public class LoggingExpression
extends UnaryExpression

An no op expression which when evaluated halts the processing of rules. Use for when something seriously wrong happens and you don't care about the rest of the days results. Will first display the alert message defined by the arguments.

Author:
Mark Hummel

Field Summary
 
Fields inherited from interface nz.org.venice.parser.Expression
BOOLEAN_TYPE, FALSE, FLOAT_QUOTE_TYPE, FLOAT_TYPE, INTEGER_QUOTE_TYPE, INTEGER_SHORT_TYPE, INTEGER_TYPE, NUMERIC_TYPE, STRING_TYPE, TRUE, TRUE_LEVEL, UNDEFINED_TYPE
 
Constructor Summary
LoggingExpression(Expression arg, Expression[] optionalArgs)
          Create a new logging expression.
 
Method Summary
 int checkType()
          Check the argument to the expression.
 java.lang.Object clone()
           
 double evaluate(Variables variables, QuoteBundle quoteBundle, Symbol symbol, int day)
          Evaluate the expression and subexpressions, and then display the resulting message.
 Expression getChild(int child)
          Return the child of this node at the given index.
 int getChildCount()
          Return the number of children required in an alert expression.
 int getType()
          Get the type of the expression
 
Methods inherited from class nz.org.venice.parser.expression.AbstractExpression
equals, getId, getIndex, getNumberFormat, getParent, getParseMetadata, hashCode, isRoot, iterator, parseDouble, parseInt, printParents, setChild, setChildMutableVersion, setParent, setParseMetadata, simplify, simplifyMutableVersion, size, size, toString, validTree, valueOfDouble, valueOfInt
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoggingExpression

public LoggingExpression(Expression arg,
                         Expression[] optionalArgs)
Create a new logging expression.

Parameters:
arg - The message expression
optionalArgs - Optional expressions (max 4) which are appended to the message defined in arg.
Method Detail

evaluate

public double evaluate(Variables variables,
                       QuoteBundle quoteBundle,
                       Symbol symbol,
                       int day)
                throws EvaluationException
Evaluate the expression and subexpressions, and then display the resulting message.

Parameters:
variables - The variables of the rule
quoteBundle - The quote bundle containing the symbol data
symbol - The implicit symbol of the rule
day - The date offset used to evaluate the rule.
Returns:
0.0
Throws:
EvaluationException - if the expression performs an illegal operation such as divide by zero.

checkType

public int checkType()
              throws TypeMismatchException
Check the argument to the expression. It can be an expression.

Returns:
the type of the expression
Throws:
TypeMismatchException - if the expression has incorrect types

getType

public int getType()
Get the type of the expression

Returns:
Expression.FLOAT_TYPE

getChildCount

public int getChildCount()
Return the number of children required in an alert expression. This will be a minimum of 1 and a maximum of 4.

Specified by:
getChildCount in interface Expression
Overrides:
getChildCount in class UnaryExpression
Returns:
The number of non null arguments.

getChild

public Expression getChild(int child)
Return the child of this node at the given index.

Specified by:
getChild in interface Expression
Overrides:
getChild in class AbstractExpression
Returns:
child at given index.

clone

public java.lang.Object clone()
Specified by:
clone in interface Expression
Specified by:
clone in class AbstractExpression
Returns:
A clone of the object.

Venice 0.751beta