Package org.apache.poi.ss.formula.eval

Examples of org.apache.poi.ss.formula.eval.StringEval


  }

  public void testWildCards() {
    I_MatchPredicate mp;

    mp = createCriteriaPredicate(new StringEval("a*b"));
    confirmPredicate(false, mp, "abc");
    confirmPredicate(true, mp, "ab");
    confirmPredicate(true, mp, "axxb");
    confirmPredicate(false, mp, "xab");

    mp = createCriteriaPredicate(new StringEval("a?b"));
    confirmPredicate(false, mp, "abc");
    confirmPredicate(false, mp, "ab");
    confirmPredicate(false, mp, "axxb");
    confirmPredicate(false, mp, "xab");
    confirmPredicate(true, mp, "axb");

    mp = createCriteriaPredicate(new StringEval("a~?"));
    confirmPredicate(false, mp, "a~a");
    confirmPredicate(false, mp, "a~?");
    confirmPredicate(true, mp, "a?");

    mp = createCriteriaPredicate(new StringEval("~*a"));
    confirmPredicate(false, mp, "~aa");
    confirmPredicate(false, mp, "~*a");
    confirmPredicate(true, mp, "*a");

    mp = createCriteriaPredicate(new StringEval("12?12"));
    confirmPredicate(false, mp, 12812);
    confirmPredicate(true, mp, "12812");
    confirmPredicate(false, mp, "128812");
  }
View Full Code Here


  }
  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");


    mp = createCriteriaPredicate(new StringEval("a~b"));
    confirmPredicate(false, mp, "ab");
    confirmPredicate(false, mp, "axb");
    confirmPredicate(false, mp, "a~~b");
    confirmPredicate(true, mp, "a~b");

    mp = createCriteriaPredicate(new StringEval(">a*b"));
    confirmPredicate(false, mp, "a(b");
    confirmPredicate(true, mp, "aab");
    confirmPredicate(false, mp, "a*a");
    confirmPredicate(true, mp, "a*c");
  }
 
View Full Code Here

  private static void confirmPredicate(boolean expectedResult, I_MatchPredicate matchPredicate, int value) {
    assertEquals(expectedResult, matchPredicate.matches(new NumberEval(value)));
  }
  private static void confirmPredicate(boolean expectedResult, I_MatchPredicate matchPredicate, String value) {
    ValueEval ev = value == null ? BlankEval.instance : new StringEval(value);
    assertEquals(expectedResult, matchPredicate.matches(ev));
  }
View Full Code Here

        public MockAreaEval(String... holidays) {
            this(0, 0, 0, holidays.length - 1);
            this.holidays = new ArrayList<ValueEval>();
            for (String holiday : holidays) {
                this.holidays.add(new StringEval(holiday));
            }
        }
View Full Code Here

* @author cedric dot walter @ gmail dot com
*/
public final class TestDelta extends TestCase {

  private static ValueEval invokeValue(String number1, String number2) {
    ValueEval[] args = new ValueEval[] { new StringEval(number1), new StringEval(number2), };
    return new Delta().evaluate(args, -1, -1);
  }
View Full Code Here

  }

  public void testSimpleString() {
        // Arrange
    ValueEval[] values = {
      new StringEval("Albert"),
      new StringEval("Charles"),
      new StringEval("Ed"),
      new StringEval("Greg"),
      new StringEval("Ian"),
    };

    AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);

    // Note String comparisons are case insensitive
    confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_LARGEST_LTE));
    confirmInt(3, invokeMatch(new StringEval("eD"), ae, MATCH_LARGEST_LTE));
    confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_EXACT));
    confirmInt(3, invokeMatch(new StringEval("ed"), ae, MATCH_EXACT));

    assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Hugh"), ae, MATCH_EXACT));
  }
View Full Code Here

  }

    public void testSimpleWildcardValuesString() {
        // Arrange
        ValueEval[] values = {
                new StringEval("Albert"),
                new StringEval("Charles"),
                new StringEval("Ed"),
                new StringEval("Greg"),
                new StringEval("Ian"),
        };

        AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);

        // Note String comparisons are case insensitive
        confirmInt(3, invokeMatch(new StringEval("e*"), ae, MATCH_EXACT));
        confirmInt(3, invokeMatch(new StringEval("*d"), ae, MATCH_EXACT));

        confirmInt(1, invokeMatch(new StringEval("Al*"), ae, MATCH_EXACT));
        confirmInt(2, invokeMatch(new StringEval("Char*"), ae, MATCH_EXACT));

        confirmInt(4, invokeMatch(new StringEval("*eg"), ae, MATCH_EXACT));
        confirmInt(4, invokeMatch(new StringEval("G?eg"), ae, MATCH_EXACT));
        confirmInt(4, invokeMatch(new StringEval("??eg"), ae, MATCH_EXACT));
        confirmInt(4, invokeMatch(new StringEval("G*?eg"), ae, MATCH_EXACT));
        confirmInt(4, invokeMatch(new StringEval("Hugh"), ae, MATCH_LARGEST_LTE));

        confirmInt(5, invokeMatch(new StringEval("*Ian*"), ae, MATCH_EXACT));
        confirmInt(5, invokeMatch(new StringEval("*Ian*"), ae, MATCH_LARGEST_LTE));
    }
View Full Code Here

    }

    public void testTildeString() {

        ValueEval[] values = {
                new StringEval("what?"),
                new StringEval("all*")
        };

        AreaEval ae = EvalFactory.createAreaEval("A1:A2", values);

        confirmInt(1, invokeMatch(new StringEval("what~?"), ae, MATCH_EXACT));
        confirmInt(2, invokeMatch(new StringEval("all~*"), ae, MATCH_EXACT));
    }
View Full Code Here

    ValueEval[] values = {
        new NumberEval(4),
        BoolEval.FALSE,
        new NumberEval(5),
        new StringEval("Albert"),
        BoolEval.FALSE,
        BoolEval.TRUE,
        new NumberEval(10),
        new StringEval("Charles"),
        new StringEval("Ed"),
        new NumberEval(10),
        new NumberEval(25),
        BoolEval.TRUE,
        new StringEval("Ed"),
    };

    AreaEval ae = EvalFactory.createAreaEval("A1:A13", values);

    assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Aaron"), ae, MATCH_LARGEST_LTE));

    confirmInt(5, invokeMatch(BoolEval.FALSE, ae, MATCH_LARGEST_LTE));
    confirmInt(2, invokeMatch(BoolEval.FALSE, ae, MATCH_EXACT));
    confirmInt(3, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
    confirmInt(3, invokeMatch(new NumberEval(5), ae, MATCH_EXACT));

    confirmInt(8, invokeMatch(new StringEval("CHARLES"), ae, MATCH_EXACT));
        //wildcard values
        confirmInt(8, invokeMatch(new StringEval("CHAR*"), ae, MATCH_EXACT));
        confirmInt(8, invokeMatch(new StringEval("*CHARLES"), ae, MATCH_EXACT));

    confirmInt(4, invokeMatch(new StringEval("Ben"), ae, MATCH_LARGEST_LTE));

    confirmInt(13, invokeMatch(new StringEval("ED"), ae, MATCH_LARGEST_LTE));
    confirmInt(13, invokeMatch(new StringEval("ED*"), ae, MATCH_LARGEST_LTE));
    confirmInt(13, invokeMatch(new StringEval("*ED"), ae, MATCH_LARGEST_LTE));
    confirmInt(9, invokeMatch(new StringEval("ED"), ae, MATCH_EXACT));
    confirmInt(9, invokeMatch(new StringEval("ED*"), ae, MATCH_EXACT));

    confirmInt(13, invokeMatch(new StringEval("Hugh"), ae, MATCH_LARGEST_LTE));
    assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Hugh"), ae, MATCH_EXACT));

    confirmInt(11, invokeMatch(new NumberEval(30), ae, MATCH_LARGEST_LTE));
    confirmInt(12, invokeMatch(BoolEval.TRUE, ae, MATCH_LARGEST_LTE));
  }
View Full Code Here

* @author cedric dot walter @ gmail dot com
*/
public final class TestOct2Dec extends TestCase {

    private static ValueEval invokeValue(String number1) {
    ValueEval[] args = new ValueEval[] { new StringEval(number1) };
    return new Oct2Dec().evaluate(args, -1, -1);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.eval.StringEval

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.