com.bestcode.mathparser
Class TwoParamFunc
java.lang.Object
|
+--com.bestcode.mathparser.TwoParamFunc
- All Implemented Interfaces:
- IFunction
- public abstract class TwoParamFunc
- extends java.lang.Object
- implements IFunction
TwoParamFunc abstract class represents a user defined callback function that takes two
parameters. This is a convenience implementation of IFunction interface.
During evaluation of an expression, MathParser calls
TwoParamFunc.run(IParameter[] p)
to request the value of the function when it takes p[] array of parameters.
For example, a user could define a function like this:
public class MyFunc extends TwoParamFunc {
   public double run(IParameter[] p){
     return do_something_with_xy( p[0], p[1] );
   }
}
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. |
abstract double |
run(IParameter[] p)
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TwoParamFunc
public TwoParamFunc()
getNumberOfParams
public int getNumberOfParams()
- Description copied from interface:
IFunction
- 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.
- Specified by:
getNumberOfParams in interface IFunction
run
public abstract double run(IParameter[] p)
- Specified by:
run in interface IFunction