Exemple #1
0
  /** @return the number of evaluated cells in the range that match the specified criteria */
  private double countMatchingCellsInArea(ValueEval rangeArg, I_MatchPredicate criteriaPredicate) {

    if (rangeArg instanceof RefEval) {
      return CountUtils.countMatchingCellsInRef((RefEval) rangeArg, criteriaPredicate);
    } else if (rangeArg instanceof ThreeDEval) {
      return CountUtils.countMatchingCellsInArea((ThreeDEval) rangeArg, criteriaPredicate);
    } else {
      throw new IllegalArgumentException(
          "Bad range arg type (" + rangeArg.getClass().getName() + ")");
    }
  }
Exemple #2
0
  /**
   * Creates a criteria predicate object for the supplied criteria arg
   *
   * @return <code>null</code> if the arg evaluates to blank.
   */
  /* package */ static I_MatchPredicate createCriteriaPredicate(
      ValueEval arg, int srcRowIndex, int srcColumnIndex) {

    ValueEval evaluatedCriteriaArg = evaluateCriteriaArg(arg, srcRowIndex, srcColumnIndex);

    if (evaluatedCriteriaArg instanceof NumberEval) {
      return new NumberMatcher(((NumberEval) evaluatedCriteriaArg).getNumberValue(), CmpOp.OP_NONE);
    }
    if (evaluatedCriteriaArg instanceof BoolEval) {
      return new BooleanMatcher(((BoolEval) evaluatedCriteriaArg).getBooleanValue(), CmpOp.OP_NONE);
    }

    if (evaluatedCriteriaArg instanceof StringEval) {
      return createGeneralMatchPredicate((StringEval) evaluatedCriteriaArg);
    }
    if (evaluatedCriteriaArg instanceof ErrorEval) {
      return new ErrorMatcher(((ErrorEval) evaluatedCriteriaArg).getErrorCode(), CmpOp.OP_NONE);
    }
    if (evaluatedCriteriaArg == BlankEval.instance) {
      return null;
    }
    throw new RuntimeException(
        "Unexpected type for criteria (" + evaluatedCriteriaArg.getClass().getName() + ")");
  }
Exemple #3
0
 private void confirmError(
     Function function, ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
   ValueEval result = invoke(function, xArray, yArray);
   assertEquals(ErrorEval.class, result.getClass());
   assertEquals(expectedError.getErrorCode(), ((ErrorEval) result).getErrorCode());
 }
Exemple #4
0
 private void confirm(Function function, ValueEval xArray, ValueEval yArray, double expected) {
   ValueEval result = invoke(function, xArray, yArray);
   assertEquals(NumberEval.class, result.getClass());
   assertEquals(expected, ((NumberEval) result).getNumberValue(), 0);
 }