Package net.sf.basedb.util.jep
Class ExtraValueFunction
java.lang.Object
net.sf.basedb.util.jep.ExtraValueFunction
- All Implemented Interfaces:
JepExpressionFunction
,JepFunction
,org.nfunk.jep.function.PostfixMathCommandI
A JEP function class that adds a
xtra(int)
function to a
JEP expression parser. The function will look up the value of the extra value
with the given ID. For example: xtra(1)
To be able to use this function it must be registered with the JEP parser.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final BioAssaySet
private final DbControl
private int
private SqlResult
-
Constructor Summary
ConstructorDescriptionExtraValueFunction
(DbControl dc, Map<Integer, Integer> extraToIndex) Create a new instance of this function which can be used to dynamically evaluate expressions.ExtraValueFunction
(DbControl dc, BioAssaySet bas) Create a new instance of this function. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkNumberOfParameters
(int n) Get the name of this function.int
void
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.extraValue(ExtraValue)
method to create an expression referencing an extra value.Get the value of the specified extra value of the current sql result.
-
Field Details
-
dc
-
extraToIndex
-
bas
-
numParameters
private int numParameters -
result
-
-
Constructor Details
-
ExtraValueFunction
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 accessing the databasebas
- Bioassay set for this extra value function.- See Also:
-
ExtraValueFunction
Create a new instance of this function which can be used to dynamically evaluate expressions.- Parameters:
dc
- DbControl to use when accessing the databaseextraToIndex
- An map from extra value ID to column indexes in the SqlResult- 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 "xtra"
- See Also:
-
toExpression
Use theDynamic.extraValue(ExtraValue)
method to create an expression referencing an extra value.- 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
-
xtra
Get the value of the specified extra value of the current sql result.- Parameters:
extraId
- The extra value ID- Returns:
- an extra value as an Object.
- Throws:
ParseException
- If no result has been specified or if no extra value was found.
-