cdx.scorebot.scoring.logic
Class ConditionalOrExpression

java.lang.Object
  extended by cdx.scorebot.scoring.logic.ConditionalOrExpression
All Implemented Interfaces:
ExpressionType, LogicCode, LogicCodeEvaluatable

public class ConditionalOrExpression
extends java.lang.Object
implements LogicCodeEvaluatable, ExpressionType

holds a conditional OR expression

Author:
David Underhill

Constructor Summary
ConditionalOrExpression(ConditionalAndExpression leftOperand)
          instantiate the conditional OR expression
 
Method Summary
 Literal evaluateLogic(Context context)
          evaluate this expression in the specified context
static boolean evaluateOR(Context context, Literal leftOperand, java.util.Vector<ConditionalAndExpression> rightOperands)
          Returns the short-circuit evaluation of the expression leftOperand || rightOperands[0] || rightOperands[1] ...
 LiteralType evaluateTypeOnly(java.util.HashMap<java.lang.String,LiteralType> varTypes, java.util.HashMap<java.lang.String,TestData> testsInfo)
          returns the kind of literal this evaluates to
 void or(ConditionalAndExpression operand)
          evaluates this expression OR'ed with this operand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionalOrExpression

public ConditionalOrExpression(ConditionalAndExpression leftOperand)
instantiate the conditional OR expression

Parameters:
leftOperand - left operand
Method Detail

evaluateLogic

public Literal evaluateLogic(Context context)
                      throws LogicException
evaluate this expression in the specified context

Specified by:
evaluateLogic in interface LogicCodeEvaluatable
Parameters:
context - contains the current context of the logic processor
Returns:
the literal value this logic evaluates to
Throws:
TypeMismatchException - thrown if an operand isn't of the required type
LogicException - thrown if an exception occurs while processing the logic

evaluateOR

public static boolean evaluateOR(Context context,
                                 Literal leftOperand,
                                 java.util.Vector<ConditionalAndExpression> rightOperands)
                          throws TypeMismatchException,
                                 LogicException
Returns the short-circuit evaluation of the expression leftOperand || rightOperands[0] || rightOperands[1] ...

Parameters:
context - contains the current context of the logic processor
leftOperand - the value on the left side of the OR operator
rightOperands - the values being OR'ed together on the right side of the OR operator
Returns:
the boolean value the specified expression evaluates to
Throws:
TypeMismatchException - thrown if an operand isn't of the required type
LogicException - thrown if an exception occurs while processing the logic

evaluateTypeOnly

public LiteralType evaluateTypeOnly(java.util.HashMap<java.lang.String,LiteralType> varTypes,
                                    java.util.HashMap<java.lang.String,TestData> testsInfo)
                             throws LogicException
Description copied from interface: LogicCodeEvaluatable
returns the kind of literal this evaluates to

Specified by:
evaluateTypeOnly in interface LogicCodeEvaluatable
Parameters:
varTypes - contains the type of value stored by each variable (variables names are keys)
testsInfo - information about each test item keyed on test item names this logic may hold
Returns:
the LiteralType this evaluates to
Throws:
LogicException - thrown if there is a problem with type which prevents this from being evaluated

or

public void or(ConditionalAndExpression operand)
evaluates this expression OR'ed with this operand

Parameters:
operand - the operand to add to the expression