Package org.apache.poi.ss.formula.functions.CountUtils

Examples of org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate


            for (int c = 0; c < width; c++) {

                boolean matches = true;
                for(int i = 0; i < ranges.length; i++){
                    AreaEval aeRange = ranges[i];
                    I_MatchPredicate mp = predicates[i];

                    if (!mp.matches(aeRange.getRelativeValue(r, c))) {
                        matches = false;
                        break;
                    }

                }
View Full Code Here


    // when criteria is an expression (starting with a comparison operator)
    confirmCountIf(2, range, new StringEval(">0.5"));
  }

  public void testCriteriaPredicateNe_Bug46647() {
    I_MatchPredicate mp = Countif.createCriteriaPredicate(new StringEval("<>aa"), 0, 0);
    StringEval seA = new StringEval("aa"); // this should not match the criteria '<>aa'
    StringEval seB = new StringEval("bb"); // this should match
    if (mp.matches(seA) && !mp.matches(seB)) {
      throw new AssertionFailedError("Identified bug 46647");
    }
    assertFalse(mp.matches(seA));
    assertTrue(mp.matches(seB));

    // general tests for not-equal (<>) operator
    AreaEval range;
    ValueEval[] values;
View Full Code Here

    ValueEval v1 = new StringEval("abc");
    ValueEval v2 = ErrorEval.DIV_ZERO;

    AreaEval ev = EvalFactory.createAreaEval("A10:A12", new ValueEval[] { v0, v1, v2, });

    I_MatchPredicate mp;
    mp = Countif.createCriteriaPredicate(ev, 9, srcColIx);
    confirmPredicate(true, mp, srcColIx);
    confirmPredicate(false, mp, "abc");
    confirmPredicate(false, mp, ErrorEval.DIV_ZERO);
View Full Code Here

    confirmPredicate(false, mp, ErrorEval.DIV_ZERO);
    confirmPredicate(true, mp, ErrorEval.VALUE_INVALID);
  }

  public void testCountifEmptyStringCriteria() {
    I_MatchPredicate mp;

    // pred '=' matches blank cell but not empty string
    mp = createCriteriaPredicate(new StringEval("="));
    confirmPredicate(false, mp, "");
    confirmPredicate(true, mp, NULL);
View Full Code Here

    confirmPredicate(false, mp, NULL);
    confirmPredicate(true, mp, "");
  }

  public void testCountifComparisons() {
    I_MatchPredicate mp;

    mp = createCriteriaPredicate(new StringEval(">5"));
    confirmPredicate(false, mp, 4);
    confirmPredicate(false, mp, 5);
    confirmPredicate(true, mp, 6);
View Full Code Here

  /**
   * the criteria arg value can be an error code (the error does not
   * propagate to the COUNTIF result).
   */
  public void testCountifErrorCriteria() {
    I_MatchPredicate mp;

    mp = createCriteriaPredicate(new StringEval("#REF!"));
    confirmPredicate(false, mp, 4);
    confirmPredicate(false, mp, "#REF!");
    confirmPredicate(true, mp, ErrorEval.REF_INVALID);
View Full Code Here

    confirmPredicate(false, mp, ErrorEval.DIV_ZERO);
    confirmPredicate(false, mp, ErrorEval.REF_INVALID);
  }

  public void testWildCards() {
    I_MatchPredicate mp;

    mp = createCriteriaPredicate(new StringEval("a*b"));
    confirmPredicate(false, mp, "abc");
    confirmPredicate(true, mp, "ab");
    confirmPredicate(true, mp, "axxb");
View Full Code Here

    confirmPredicate(false, mp, 12812);
    confirmPredicate(true, mp, "12812");
    confirmPredicate(false, mp, "128812");
  }
  public void testNotQuiteWildCards() {
    I_MatchPredicate mp;

    // make sure special reg-ex chars are treated like normal chars
    mp = createCriteriaPredicate(new StringEval("a.b"));
    confirmPredicate(false, mp, "aab");
    confirmPredicate(true, mp, "a.b");
View Full Code Here

    }
  }

  public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {

    I_MatchPredicate mp = createCriteriaPredicate(arg1, srcRowIndex, srcColumnIndex);
    if(mp == null) {
      // If the criteria arg is a reference to a blank cell, countif always returns zero.
      return NumberEval.ZERO;
    }
    double result = countMatchingCellsInArea(arg0, mp);
View Full Code Here

    // when criteria is an expression (starting with a comparison operator)
    confirmCountIf(2, range, new StringEval(">0.5"));
  }

  public void testCriteriaPredicateNe_Bug46647() {
    I_MatchPredicate mp = Countif.createCriteriaPredicate(new StringEval("<>aa"), 0, 0);
    StringEval seA = new StringEval("aa"); // this should not match the criteria '<>aa'
    StringEval seB = new StringEval("bb"); // this should match
    if (mp.matches(seA) && !mp.matches(seB)) {
      throw new AssertionFailedError("Identified bug 46647");
    }
    assertFalse(mp.matches(seA));
    assertTrue(mp.matches(seB));

    // general tests for not-equal (<>) operator
    AreaEval range;
    ValueEval[] values;
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.