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 Details

    • name

      private final String name
    • numParameters

      private final int numParameters
    • actualParameters

      private int actualParameters
  • Constructor Details

    • SimpleJepFunction

      public SimpleJepFunction(String name, int numParameters)
  • Method Details

    • getFunctionName

      public String getFunctionName()
      Description copied from interface: JepFunction
      Get the name of this function. It is used when registering the function with a JEP parser.
      Specified by:
      getFunctionName in interface JepFunction
      See Also:
    • getNumberOfParameters

      public int getNumberOfParameters()
      Specified by:
      getNumberOfParameters in interface org.nfunk.jep.function.PostfixMathCommandI
    • checkNumberOfParameters

      public boolean checkNumberOfParameters(int n)
      Specified by:
      checkNumberOfParameters in interface org.nfunk.jep.function.PostfixMathCommandI
    • setCurNumberOfParameters

      public void setCurNumberOfParameters(int actualParameters)
      Specified by:
      setCurNumberOfParameters in interface org.nfunk.jep.function.PostfixMathCommandI
    • run

      public void run(Stack stack) throws ParseException
      Specified by:
      run in interface org.nfunk.jep.function.PostfixMathCommandI
      Throws:
      ParseException