Venice 0.751beta

nz.org.venice.parser.expression
Class AlertExpression

java.lang.Object
  extended bynz.org.venice.parser.expression.AbstractExpression
      extended bynz.org.venice.parser.expression.UnaryExpression
          extended bynz.org.venice.parser.expression.AlertExpression
All Implemented Interfaces:
java.lang.Cloneable, Expression
Direct Known Subclasses:
HaltExpression

public class AlertExpression
extends UnaryExpression

An no op expression which when evaluated displays a message. For debugging rules.

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
AlertExpression(Expression arg, Expression[] optionalArgs)
          Create a new alert 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
 java.lang.String toString()
          Return a string representing the expression contents.
 
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, validTree, valueOfDouble, valueOfInt
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlertExpression

public AlertExpression(Expression arg,
                       Expression[] optionalArgs)
Create a new alert 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

toString

public java.lang.String toString()
Return a string representing the expression contents.

Specified by:
toString in interface Expression
Overrides:
toString in class AbstractExpression
Returns:
a string

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

Venice 0.751beta