cdx.scorebot.scoring.logic
Class Assignment

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

public class Assignment
extends java.lang.Object
implements LogicCodeExecutable, LogicCodeEvaluatable, ExpressionType, StatementType

evaluates an assignment statement

Author:
David Underhill

Constructor Summary
Assignment(Identifier varIden, OperatorType assignmentOperator, Expression value)
          instantiate an assignment statement
 
Method Summary
 Literal evaluateLogic(Context context)
          evaluate this logic code 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
 void executeLogic(Context context)
          process this logic code in the specified context
 void validateTypes(java.util.HashMap<java.lang.String,LiteralType> varTypes, java.util.HashMap<java.lang.String,TestData> testsInfo)
          Attempts to validate the type-correctness of all constituent LogicCodeEvaluatable logic code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Assignment

public Assignment(Identifier varIden,
                  OperatorType assignmentOperator,
                  Expression value)
instantiate an assignment statement

Parameters:
varIden - identifier of the variable to assign to
assignmentOperator - assignment operator to use
value - the value to assign
Method Detail

evaluateLogic

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

Specified by:
evaluateLogic in interface LogicCodeEvaluatable
Parameters:
context - contains the current context of the logic processor
Returns:
the value this logic evaluates to
Throws:
LogicException - thrown if an exception occurs while processing the logic

executeLogic

public void executeLogic(Context context)
                  throws LogicException
process this logic code in the specified context

Specified by:
executeLogic in interface LogicCodeExecutable
Parameters:
context - contains the current context of the logic processor
Throws:
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

validateTypes

public void validateTypes(java.util.HashMap<java.lang.String,LiteralType> varTypes,
                          java.util.HashMap<java.lang.String,TestData> testsInfo)
                   throws LogicException
Description copied from interface: LogicCodeExecutable
Attempts to validate the type-correctness of all constituent LogicCodeEvaluatable logic code. An exception is thrown if there is some type-check failure.

Specified by:
validateTypes in interface LogicCodeExecutable
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
Throws:
LogicException - thrown if an exception if an invalid test, test result, or test option is found