|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
IFunction interface represents a user defined callback function that takes n
parameters. During evaluation of an expression, MathParser calls
IFunction.run(IParameter[] p)
to request the value of the function when it takes p.length number of parameters.
For example, a user could define a function like this:
public class MyFunc implements IFunction {
   public double run(IParameter[] p){
     return do_something_with_params( p );
   }
}
Another user defined function "if" could be used as "if(1,3,4)". In this case,
implementation of IFunction.run(IParameter[]) could
return 3.0 if first parameter is >0 and it could return 4.0
if first parameter is 0 (false, to mimic "if" behavior).
User defined functions can be registered using createFunc method of MathParser.
Example:
   mathParser.createFunc("myfunc", new MyFunc());
| Method Summary | |
int |
getNumberOfParams()
This method returns the length of the parameters array that will be passed to the run(IParameter[]) method. For example, for a function like F(X, Y, Z), this function should return 3. |
double |
run(IParameter[] p)
|
| Method Detail |
public double run(IParameter[] p)
public int getNumberOfParams()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||