|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.jep.ReporterFunction
public class ReporterFunction
A JEP function class that adds a rep(string)
function to a
JEP expression parser. The function will look up the value of the reporter
property with the given name. For example:
rep('sequence')
To be able to use this function it must be registered with the JEP parser and, before the expression is evaluated, a reporter object must be set. For example we can evaluate an expression for every reporter object:
DbControl dc = ... RawBioAssay assay = ... String expression = "rep('sequence')"; ReporterFunction rep = new RepFunction(); JEP jep = JepUtil.newJep(expression, rep); DataResultIterator<RawData> result = assay.getRawData().iterate(dc); while (result.hasNext()) { rep.setReporter(result.next().getReporter()); String value = jep.getValue(); // Do something with the value } result.close();
Jep
,
BioAssaySetUtil.createJepExpression(DbControl, String, DynamicQuery)
Field Summary | |
---|---|
private DbControl |
dc
|
private Metadata<ReporterData> |
metaData
|
private int |
numParameters
|
private ReporterData |
reporter
|
Constructor Summary | |
---|---|
ReporterFunction()
Create a new instance of this function. |
|
ReporterFunction(DbControl dc,
RawDataType rawDataType)
Create a new instance of this function working with reporters. |
Method Summary | |
---|---|
boolean |
checkNumberOfParameters(int n)
|
String |
getFunctionName()
Get the name of this function. |
int |
getNumberOfParameters()
|
ReporterData |
getReporter()
Get the current reporter object used when evaluating the JEP expression. |
Object |
raw(String propertyName)
Get the value of the specified property of the current raw data object. |
void |
run(Stack stack)
|
void |
setCurNumberOfParameters(int n)
|
void |
setReporter(ReporterData reporter)
Set a new reporter object that will be used the next time the JEP expression is evaluated. |
Expression |
toExpression(Node node)
Use the Dynamic.reporter(String) method to create an
expression referencing a reporter property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final Metadata<ReporterData> metaData
private final DbControl dc
private int numParameters
private ReporterData reporter
Constructor Detail |
---|
public ReporterFunction()
Expression
:s.
Jep.formulaToExpression(String, JepFunction[])
public ReporterFunction(DbControl dc, RawDataType rawDataType)
Method Detail |
---|
public String getFunctionName()
JepFunction
JEP
parser.
getFunctionName
in interface JepFunction
JEP.addFunction(String, PostfixMathCommandI)
public Expression toExpression(Node node)
Dynamic.reporter(String)
method to create an
expression referencing a reporter property.
toExpression
in interface JepExpressionFunction
node
- The node representing this function
Expression
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(Stack stack) throws ParseException
run
in interface org.nfunk.jep.function.PostfixMathCommandI
ParseException
public void setReporter(ReporterData reporter)
reporter
- The reporter object to usepublic ReporterData getReporter()
public Object raw(String propertyName) throws ParseException
propertyName
- The name of the raw data property
ParseException
- If the argument is null or 'reporter' not specified.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |