|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcdx.scorebot.scoring.logic.Context
public class Context
stores information about the current state when processing a scoring rule's logic
| Constructor Summary | |
|---|---|
Context(ScoringRule rule)
instantiates a Context to store state for the specified rule (and its needed test results) |
|
| Method Summary | |
|---|---|
protected void |
addVariable(Identifier iden,
Literal value)
adds a variable to the context |
protected void |
bonus(int bonus,
java.lang.String title,
java.lang.String msg)
creates a test score event with the specified bonus (will be reported) |
protected void |
bonus(int bonus,
java.lang.String title,
java.lang.String msg,
boolean known)
creates a test score event with the specified bonus |
protected boolean |
compareDates(java.lang.String date1,
OperatorType booleanOp,
java.lang.String date2)
Compare two dates with the specified boolean operator. |
protected int |
count(java.lang.String testName,
int numResultsToLookAt,
java.lang.String resultName,
OperatorType operator,
Literal operand2)
counts the number of a times a given result meets a given condition for some number of iterations of the test. |
protected void |
echo(java.lang.String msg)
prints the specified message to standard out |
protected void |
echoErr(java.lang.String errMsg)
prints the specified message to standard error |
protected int |
floor(Literal literal)
Convert a double to a floored integer. |
protected Literal |
getTestOptionValue(java.lang.String testName,
int testNum,
java.lang.String optionName)
gets the value of a test option |
protected Literal |
getTestResultValue(java.lang.String testName,
int testNum,
java.lang.String resultName)
gets the value of a test result |
java.util.Vector<TestScoreEvent> |
getTestScoreEvents()
gets any test score events generated by in this context |
protected Literal |
getVariableValue(java.lang.String varName)
gets the specified variable; if a variable with the specified name isn't found, then a UndefinedVariableException will be thrown. |
boolean |
hasAllNeededResults()
determines whether or not all TestNumPairs are fully populated |
static boolean |
mayAssign(LiteralType type,
LiteralType valueType)
Returns true if the specified value type may be assigned to the specified type. |
void |
penalty(int penalty,
java.lang.String title,
java.lang.String msg)
creates a test score event with the specified penalty (and flags it as unreported). |
protected void |
penalty(int penalty,
java.lang.String title,
java.lang.String msg,
boolean known)
creates a test score event with the specified penalty |
protected void |
setVariableValue(java.lang.String varName,
Literal value)
|
protected java.lang.String |
tostring(Literal literal)
Convert a literal to its string representation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Context(ScoringRule rule)
rule - the rule this context is used by (this is referenced in
generated score events and it contains the current test
results too)| Method Detail |
|---|
protected Literal getTestOptionValue(java.lang.String testName,
int testNum,
java.lang.String optionName)
throws UndefinedTestException,
TestUnavailableException,
UndefinedTestOptionException,
TypeMismatchException
testName - name of the test whose result is to be fetchedtestNum - what test to access (0 = most recent result, 1 = 1 run ago, etc.)optionName - name of the configuration option which is to be fetched
UndefinedTestException - occurs if the requested test is not tracked in this context
TestUnavailableException - occurs if the test is found, but it hasn't run testNum number of times yet
UndefinedTestOptionException - occurs if the test is found, but the option isn't a valid option
TypeMismatchException - occurs if the option value is not a literal (shouldn't happen)
protected Literal getTestResultValue(java.lang.String testName,
int testNum,
java.lang.String resultName)
throws UndefinedTestException,
TestUnavailableException,
UndefinedTestResultException,
TypeMismatchException
testName - name of the test whose result is to be fetchedresultName - name of the result to fetch
UndefinedTestException - occurs if the requested test is not tracked in this context
TestUnavailableException - occurs if the test is found, but it hasn't run testNum number of times yet
UndefinedTestResultException - occurs if the test is found, but the result requested isn't a valid result
TypeMismatchException - occurs if the option value is not a literal (shouldn't happen)
protected void addVariable(Identifier iden,
Literal value)
throws RedefinedVariableException
iden - the name of the variablevalue - the value of the variable
RedefinedVariableException - occurs if the specified variable's name has already been declared
protected Literal getVariableValue(java.lang.String varName)
throws UndefinedVariableException
varName - the name of the variable whose value is to be returned
UndefinedVariableException - occurs if the specified variable's name has never been declared
protected void setVariableValue(java.lang.String varName,
Literal value)
throws UndefinedVariableException,
TypeMismatchException
UndefinedVariableException
TypeMismatchException
public static boolean mayAssign(LiteralType type,
LiteralType valueType)
type - the type of the variable to setvalueType - the type of value to assign to the variable
protected boolean compareDates(java.lang.String date1,
OperatorType booleanOp,
java.lang.String date2)
throws IllegalOperandException
date1 - date on the left side of the operatorbooleanOp - the boolean operator to compare the dates withdate2 - date on the right side of the operator
IllegalOperandException - thrown if an invalid operator (i.e. not a boolean operator) is supplied
protected int count(java.lang.String testName,
int numResultsToLookAt,
java.lang.String resultName,
OperatorType operator,
Literal operand2)
throws UndefinedTestException,
TestUnavailableException,
UndefinedTestResultException,
IllegalOperandException,
TypeMismatchException
testName - name of the test to checknumResultsToLookAt - number of most recent tests to checkresultName - name of the result to checkoperator - operator to use when testing the resultoperand2 - second operand for when testing the result
UndefinedTestException - occurs if the requested test is not tracked in this context
TestUnavailableException - occurs if the test is found, but it hasn't run testNum number of times yet
UndefinedTestResultException - occurs if the test is found, but the result requested isn't a valid result
IllegalOperandException - occurs if o1 and o2 are not defined for the specified operator
TypeMismatchException - occurs if the specified operator returns a type other than Boolean
protected int floor(Literal literal)
throws IllegalArgValException
literal - the literal to convert (must be a Double)
IllegalArgValExceptionprotected java.lang.String tostring(Literal literal)
literal - the literal to convert
protected void echo(java.lang.String msg)
msg - the message to printprotected void echoErr(java.lang.String errMsg)
errMsg - the message to print
protected void bonus(int bonus,
java.lang.String title,
java.lang.String msg)
bonus - number of points to addtitle - a descriptive heading for the penaltymsg - why points are being added
protected void bonus(int bonus,
java.lang.String title,
java.lang.String msg,
boolean known)
bonus - number of points to addtitle - a descriptive heading for the penaltymsg - why points are being addedknown - If true, then all constituent TestEvents will be flagged as reported.
Otherwise, they will be flagged as not reported.
public void penalty(int penalty,
java.lang.String title,
java.lang.String msg)
penalty - number of points to deducttitle - a descriptive heading for the penaltymsg - why points are being deducted
protected void penalty(int penalty,
java.lang.String title,
java.lang.String msg,
boolean known)
penalty - number of points to deducttitle - a descriptive heading for the penaltymsg - why points are being deductedknown - If true, then all constituent TestEvents will be flagged as reported.
Otherwise, they will be flagged as not reported.public boolean hasAllNeededResults()
public java.util.Vector<TestScoreEvent> getTestScoreEvents()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||