public class RawFunction extends java.lang.Object implements JepExpressionFunction
raw(string)
function to a
JEP expression parser. The function will look up the value of the raw data
property with the given name. For example:
raw('ch1FgMean') - raw('ch1BgMean')
To be able to use this function it must be registered with the JEP parser and, before the expression is evaluated, a raw data object must be set. For example we can evaluate an expression for every raw data object in a raw bioassay:
DbControl dc = ... RawBioAssay assay = ... String expression = "raw('ch1FgMean') - raw('ch1BgMean')"; RawFunction raw = new RawFunction(assay.getRawDataType()); JEP jep = JepUtil.newJep(expression, raw); DataResultIterator<RawData> result = assay.getRawData().iterate(dc); while (result.hasNext()) { raw.setRawData(result.next()); double value = jep.getValue(); // Do something with the value } result.close();
Jep
,
BioAssaySetUtil.createJepExpression(DbControl, String, DynamicQuery)
Modifier and Type | Field and Description |
---|---|
private boolean |
allowUse |
private DbControl |
dc |
private Metadata<RawData> |
metaData |
private int |
numParameters |
private RawData |
rawData |
private RawDataType |
rawDataType |
Constructor and Description |
---|
RawFunction(boolean allowUse)
Create a new instance of this function.
|
RawFunction(DbControl dc,
RawDataType rawDataType,
boolean allowUse)
Create a new instance of this function working with raw data of
the specified raw data type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n) |
java.lang.String |
getFunctionName()
Get the name of this function.
|
int |
getNumberOfParameters() |
RawData |
getRawData()
Get the current raw data object used when evaluating the JEP expression.
|
RawDataType |
getRawDataType()
Get the raw data type this function uses.
|
java.lang.Object |
raw(java.lang.String propertyName)
Get the value of the specified property of the current raw data object.
|
void |
run(java.util.Stack stack) |
void |
setCurNumberOfParameters(int n) |
void |
setRawData(RawData rawData)
Set a new raw data object that will be used the next time the
JEP expression is evaluated.
|
Expression |
toExpression(Node node)
Use the
Dynamic.rawData(String) method to create an
expression referencing a raw data property. |
private final RawDataType rawDataType
private final DbControl dc
private final boolean allowUse
private int numParameters
private RawData rawData
public RawFunction(boolean allowUse)
Expression
:s.public RawFunction(DbControl dc, RawDataType rawDataType, boolean allowUse)
rawDataType
- The type of raw data this function usespublic java.lang.String getFunctionName()
JepFunction
JEP
parser.getFunctionName
in interface JepFunction
JEP.addFunction(String, PostfixMathCommandI)
public Expression toExpression(Node node)
Dynamic.rawData(String)
method to create an
expression referencing a raw data property.toExpression
in interface JepExpressionFunction
node
- The node representing this functionExpression
objectpublic int getNumberOfParameters()
getNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public void setCurNumberOfParameters(int n)
setCurNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public void run(java.util.Stack stack) throws ParseException
run
in interface org.nfunk.jep.function.PostfixMathCommandI
ParseException
public RawDataType getRawDataType()
public void setRawData(RawData rawData)
rawData
- The raw data object to usepublic RawData getRawData()
public java.lang.Object raw(java.lang.String propertyName) throws ParseException
propertyName
- The name of the raw data property. Null is not allowed.ParseException
- If required arguments is null