cdx.scorebot.scoring.logic
Class Method

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

public class Method
extends GenericMethod
implements LogicCodeEvaluatable, PrimaryExpressionType

evaluates a method call which returns a value (this is called a "function")

Author:
David Underhill

Constructor Summary
Method(Identifier methodName, Arguments args)
          Instantiate a method call which returns a value.
 
Method Summary
 Literal evaluateLogic(Context context)
          evaluate the method called 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
static LiteralType[] getArgTypes(java.lang.String methodName)
          gets an array with the names of methods which return some value
static java.lang.String[] getMethods()
          gets an array with the names of methods which return some value
static java.lang.String getSignature(java.lang.String name)
           
 
Methods inherited from class cdx.scorebot.scoring.logic.GenericMethod
getArgs, getMethodName, throwIAE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Method

public Method(Identifier methodName,
              Arguments args)
Instantiate a method call which returns a value. Currently defines the methods compareDates, count, and string.

Parameters:
methodName - the name of the method
args - the arguments to the method call
See Also:
Context.compareDates(java.lang.String, cdx.scorebot.scoring.logic.OperatorType, java.lang.String), Context.count(java.lang.String, int, java.lang.String, cdx.scorebot.scoring.logic.OperatorType, cdx.scorebot.scoring.logic.Literal), Context.tostring(cdx.scorebot.scoring.logic.Literal)
Method Detail

evaluateLogic

public Literal evaluateLogic(Context context)
                      throws LogicException
evaluate the method called 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:
UndefinedMethodException - thrown if the specified method name does not reference a method which exists
IllegalMethodArgsException - thrown if the specified method name exists but the args don't meet expectations
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

getMethods

public static java.lang.String[] getMethods()
gets an array with the names of methods which return some value


getArgTypes

public static LiteralType[] getArgTypes(java.lang.String methodName)
                                 throws UndefinedMethodException
gets an array with the names of methods which return some value

Throws:
UndefinedMethodException

getSignature

public static java.lang.String getSignature(java.lang.String name)
                                     throws IllegalMethodArgsException,
                                            UndefinedMethodException
Throws:
IllegalMethodArgsException
UndefinedMethodException