Package net.sf.basedb.util.jep
Class ScoreFunction
java.lang.Object
net.sf.basedb.util.jep.ScoreFunction
- All Implemented Interfaces:
JepExpressionFunction
,JepFunction
,org.nfunk.jep.function.PostfixMathCommandI
A JEP function class that adds a
score(reporterListId)
function to a
JEP expression parser. The function will look up a reporters score in the
reporter list with the ID given as an argument to this function.
To be able to use this function it must be registered with the JEP
parser and, before the expression is evaluated, a SqlResult
object
must be set.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a new instance of this function.ScoreFunction
(DbControl dc, int scoreIndex) Create a new instance of this function which can be used to dynamically evaluate expressions. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkNumberOfParameters
(int n) Get the name of this function.int
void
score()
Get the score value from the current sql result.void
setCurNumberOfParameters
(int n) void
setSqlResult
(SqlResult result) Set a newSqlResult
object that will be used the next time the JEP expression is evaluated.toExpression
(Node node) Use theDynamic.score(ReporterList)
method to create an expression referencing the score of a reporter in the reporter list.
-
Field Details
-
dc
-
scoreIndex
private int scoreIndex -
result
-
numParameters
private int numParameters
-
-
Constructor Details
-
ScoreFunction
Create a new instance of this function. The new instance cannot be used to dynamically evaluate expressions. It should only be used for converting JEP formulas toExpression
:s.- Parameters:
dc
- DbControl to use when this ScoreFunction accessing the database.- See Also:
-
ScoreFunction
Create a new instance of this function which can be used to dynamically evaluate expressions.- Parameters:
dc
- DbControl to use when this ScoreFunction accessing the database.scoreIndex
- The column index in the SqlResult that holds the score value- See Also:
-
-
Method Details
-
getFunctionName
Description copied from interface:JepFunction
Get the name of this function. It is used when registering the function with aJEP
parser.- Specified by:
getFunctionName
in interfaceJepFunction
- Returns:
- The string "score"
- See Also:
-
toExpression
Use theDynamic.score(ReporterList)
method to create an expression referencing the score of a reporter in the reporter list.- Specified by:
toExpression
in interfaceJepExpressionFunction
- Parameters:
node
- The node representing this function- Returns:
- An
Expression
object
-
getNumberOfParameters
public int getNumberOfParameters()- Specified by:
getNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
- Returns:
- Always 1
-
setCurNumberOfParameters
public void setCurNumberOfParameters(int n) - Specified by:
setCurNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
checkNumberOfParameters
public boolean checkNumberOfParameters(int n) - Specified by:
checkNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
run
- Specified by:
run
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
- Throws:
ParseException
-
setSqlResult
Set a newSqlResult
object that will be used the next time the JEP expression is evaluated.- Parameters:
result
- The result object
-
score
Get the score value from the current sql result.- Returns:
- a
Object
- Throws:
ParseException
- If no result has been specified or if getting the score result fails.
-