Class Function

java.lang.Object
cl.obcom.desktopfx.expr.Function

public abstract class Function extends Object
Function evaluator that can be used in an Expression.
See Also:
  • Constructor Details

    • Function

      public Function(String name, int argc)
      Constructs a new Function instance with given name.
      Parameters:
      name - the name of the function.
      argc - the number of required function arguments.
      Throws:
      NullPointerException - if name is null.
      IllegalArgumentException - if argc is negative.
  • Method Details

    • getName

      public final String getName()
      Returns the name of this function.
      Returns:
      the name of this function.
    • getArgc

      public final int getArgc()
      Returns the number of required arguments of this function.
      Returns:
      the number of required arguments of this function.
    • checkFunctionArgs

      protected final void checkFunctionArgs(List<Expression> args)
      Throws an exception if the number of args is less than the number of required function arguments (argc). If args is null, this method assumes zero arguments.
      Parameters:
      args - the arguments passed to evaluate (can be null).
      Throws:
      ExpressionException - if number of args is less than argc.
    • evaluate

      public abstract Object evaluate(List<Expression> args) throws Exception
      Evaluates this function using the supplied list of arguments.
      Parameters:
      args - the arguments required for the evaluation (can be null).
      Returns:
      the result of evaluating this function with supplied arguments.
      Throws:
      Exception - if an error occurs evaluating the function.