Package net.sf.basedb.util.jep
Class SimpleJepFunction
java.lang.Object
net.sf.basedb.util.jep.SimpleJepFunction
- All Implemented Interfaces:
JepFunction
,org.nfunk.jep.function.PostfixMathCommandI
public class SimpleJepFunction extends Object implements JepFunction
A simple base class for registering a JEP function by name and number
of parameters. The default implementation will simply return a random
number between 0 and 100. This is intended to be re-implemented by
subclasses.
- Since:
- 3.3
- Author:
- nicklas
-
Field Summary
Fields Modifier and Type Field Description private int
actualParameters
private String
name
private int
numParameters
-
Constructor Summary
Constructors Constructor Description SimpleJepFunction(String name, int numParameters)
-
Method Summary
Modifier and Type Method Description boolean
checkNumberOfParameters(int n)
String
getFunctionName()
Get the name of this function.int
getNumberOfParameters()
void
run(Stack stack)
void
setCurNumberOfParameters(int actualParameters)
-
Field Details
-
name
-
numParameters
private final int numParameters -
actualParameters
private int actualParameters
-
-
Constructor Details
-
SimpleJepFunction
-
-
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
- See Also:
JEP.addFunction(String, PostfixMathCommandI)
-
getNumberOfParameters
public int getNumberOfParameters()- Specified by:
getNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
checkNumberOfParameters
public boolean checkNumberOfParameters(int n)- Specified by:
checkNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
setCurNumberOfParameters
public void setCurNumberOfParameters(int actualParameters)- Specified by:
setCurNumberOfParameters
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
-
run
- Specified by:
run
in interfaceorg.nfunk.jep.function.PostfixMathCommandI
- Throws:
ParseException
-