cdx.scorebot.scoring.logic
Class VariableInitialization

java.lang.Object
  extended by cdx.scorebot.scoring.logic.VariableInitialization
All Implemented Interfaces:
BlockStatementType, LogicCode, LogicCodeExecutable

public class VariableInitialization
extends java.lang.Object
implements LogicCodeExecutable, BlockStatementType

specifies a variable to be initialized

Author:
David Underhill

Constructor Summary
VariableInitialization(LiteralType type, Identifier iden, Expression exp)
          Construct a variable to be initialized
 
Method Summary
 void executeLogic(Context context)
          process this logic code in the specified context
 LiteralType getType()
          gets the type of variable to initialize
 java.lang.String getVarName()
          gets the name of this variable
 Expression getVarValue()
          gets the name and initial value of this variable
 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

VariableInitialization

public VariableInitialization(LiteralType type,
                              Identifier iden,
                              Expression exp)
Construct a variable to be initialized

Parameters:
type - the type of variable to initialize
iden - name of the variable to initialize
exp - the value to assign iden
Method Detail

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:
TypeMismatchException - occurs if the declared variable type is different from the initializer's type
RedefinedVariableException - occurs if the specified variable's name has already been declared
LogicException - thrown if an exception occurs while processing the logic

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

getType

public LiteralType getType()
gets the type of variable to initialize


getVarName

public java.lang.String getVarName()
gets the name of this variable


getVarValue

public Expression getVarValue()
gets the name and initial value of this variable