cdx.scorebot.scoring.logic
Class ExpressionLeftAssociative<SUBEXP extends LogicCodeEvaluatable>

java.lang.Object
  extended by cdx.scorebot.scoring.logic.ExpressionLeftAssociative<SUBEXP>
All Implemented Interfaces:
LogicCode, LogicCodeEvaluatable
Direct Known Subclasses:
AdditiveExpression, ConditionalXorExpression, EqualityExpression, MultiplicativeExpression, RelationalExpression

public abstract class ExpressionLeftAssociative<SUBEXP extends LogicCodeEvaluatable>
extends java.lang.Object
implements LogicCodeEvaluatable

Defines a left-associate expression (A || B || C is equivalent to ((A || B) || C).

Author:
David Underhill

Field Summary
protected  SUBEXP leftOperand
          left operand
protected  java.util.Vector<SUBEXP> rightOperands
          right operand(s)
 
Constructor Summary
ExpressionLeftAssociative(SUBEXP leftOperand)
          instantiate the expression
 
Method Summary
protected  void addOperand(OperatorType op, SUBEXP operand)
          adds an operator and operand to this expression
 Literal evaluateLogic(Context context)
          evaluate this expression in the specified context
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftOperand

protected SUBEXP extends LogicCodeEvaluatable leftOperand
left operand


rightOperands

protected java.util.Vector<SUBEXP extends LogicCodeEvaluatable> rightOperands
right operand(s)

Constructor Detail

ExpressionLeftAssociative

public ExpressionLeftAssociative(SUBEXP leftOperand)
instantiate the 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

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

addOperand

protected void addOperand(OperatorType op,
                          SUBEXP operand)
adds an operator and operand to this expression

Parameters:
op - the operator to use to add this operand to the expression
operand - the operand to add to the expression