cdx.scorebot.scoring.logic
Class Identifier

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

public class Identifier
extends java.lang.Object
implements LogicCodeEvaluatable, PrimaryExpressionType

Stores the name of a Variable

Author:
David Underhill

Constructor Summary
Identifier(java.lang.String varName)
          instantiates a variable identifier
 
Method Summary
 Literal evaluateLogic(Context context)
          returns the value of the variable whose name is specified by this identifier
 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
 java.lang.String getName()
          gets the name of the variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Identifier

public Identifier(java.lang.String varName)
instantiates a variable identifier

Parameters:
varName - name of the variable
Method Detail

evaluateLogic

public Literal evaluateLogic(Context context)
                      throws LogicException
returns the value of the variable whose name is specified by this identifier

Specified by:
evaluateLogic in interface LogicCodeEvaluatable
Parameters:
context - contains the current context of the logic processor
Returns:
the variable's value
Throws:
UndefinedVariableException - occurs if the specified variable's name has never been declared
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

getName

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