Class MultiOperandNumericFunction

java.lang.Object
io.keikai.range.formula.MultiOperandNumericFunction
All Implemented Interfaces:
Function

public abstract class MultiOperandNumericFunction extends Object implements Function
Base class for custom numeric functions whose arguments are accumulated into a flat double[] array.

Subclasses override evaluate(double[]). The base class walks each argument:

  • An AreaEval or TwoDEval is iterated cell-by-cell.
  • A RefEval resolves to its single inner value.
  • A NumberEval contributes its numeric value.
  • A BoolEval contributes 1.0 / 0.0 only when countBoolean=true (controlled by the constructor).
  • A BlankEval contributes 0.0 only when countBlank=true.
  • A StringEval is skipped unless strict=true, in which case it short-circuits to #VALUE!.
  • An ErrorEval short-circuits the entire result to that error.

Replaces org.apache.poi.ss.formula.functions.MultiOperandNumericFunction.

Since:
7.0.0
  • Constructor Details

    • MultiOperandNumericFunction

      protected MultiOperandNumericFunction(boolean countBoolean, boolean countBlank, boolean strict)
      Parameters:
      countBoolean - when true, BoolEval arguments contribute 1.0/0.0; when false, they are skipped.
      countBlank - when true, BlankEval arguments contribute 0.0; when false, they are skipped.
      strict - when true, a non-numeric scalar (StringEval, etc.) short-circuits the call to #VALUE!.
  • Method Details

    • evaluate

      public final ValueEval evaluate(ValueEval[] args, int srcCellRow, int srcCellCol)
      Description copied from interface: Function
      Evaluate this function with the supplied (already-evaluated) argument values.
      Specified by:
      evaluate in interface Function
      Parameters:
      args - evaluated function arguments; never null and never contains null entries
      srcCellRow - 0-based row index of the cell containing the formula
      srcCellCol - 0-based column index of the cell containing the formula
      Returns:
      the result as a ValueEval; return an ErrorEval for error cases
    • evaluate

      protected abstract double evaluate(double[] values) throws EvaluationException
      Concrete evaluation over the flattened double array. Throw EvaluationException (e.g. EvaluationException.numberError()) to return an Excel error code.
      Throws:
      EvaluationException