Examples of StatementExpression


Examples of com.firefly.template.parser.StatementExpression

//    System.out.println(preprocessing("3 + 4 + -(-(2 - 1) + 1)"));
//    System.out.println(getReversePolishNotation("3 + 4 + -(-(2 - 1) + 1)"));
//    System.out.println(preprocessing("${apple.price} > 7f && -(${apple.price} + 2) * 0.4 + 4 <= 3"));
    System.out.println(getReversePolishNotation("!(${apple.price} > 7f && -(${apple.price} + 2) * 0.4 + 4 <= 3)"));
   
    StatementExpression se = new StatementExpression();
    System.out.println(se.parse("-(3 + 4) > 8 && !(${i} > 0)"));
    System.out.println(se.parse("(0-(0 - ${i})) * 4"));
    System.out.println(se.parse("-(3 + 4) +-( -(2 - 1) + 1)"));
    System.out.println(se.parse("!(${apple.price} > 7f && -(${apple.price} + 2) * 0.4 + 4 <= 3)"));
    System.out.println(se.parse("${i} != null && ${i.size} > 0"));
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    System.out.println(se.parse("${i} != null && ${i.size} > 0"));
  }
 
  public static void main5(String[] args) {
    System.out.println(((Object)"Bob").equals("Bob"));
    StatementExpression se = new StatementExpression();
    System.out.println(se.parse("'pt1 !'!= ${i}"));
    System.out.println(se.parse("${i}!= 'pt1 !'"));
    System.out.println(se.parse("'pt1 !' != 'pt1 !'"));
//    String str = null;
//    System.out.println("".equals(null));
    List<Fragment> list = getReversePolishNotation("${i} != null && ${i} != ${k}");
    System.out.println(list.toString());
    for(Fragment f : list) {
      System.out.print(f.type + ", ");
    }
    System.out.println();
    System.out.println(se.parse("${i} != null && null == ${j} && ${i} != ${k}"));
   
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    for(Fragment f : list) {
      System.out.print(f.type + ", ");
    }
    System.out.println();
   
    StatementExpression se = new StatementExpression();
   
    System.out.println(se.parse("!(${apple.price} > 7f && ${apple.price} <= 3)"));
    System.out.println(se.parse("${apple.price} > 7f && ${apple.price} <= 3"));
    System.out.println(se.parse("!${i} || !${j} && ${k}"));
    System.out.println(se.parse("5 > 3 && 5 > 2"));
    System.out.println(se.parse("${i} || 5 < 3 && 5 > 2"));
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    System.out.println(Float.parseFloat("3.5") + Long.parseLong("4"));
   
    System.out.println(getReversePolishNotation("3 + 3 * 5 / 2"));
    System.out.println(getReversePolishNotation("3 + 3 * 5 / 2"));
    System.out.println("================================================");
    StatementExpression se = new StatementExpression();
   
    System.out.println(se.parse("3L + 3L * 5L / 2L"));
    System.out.println(se.parse("3 + 3 * 5 / 2"));
    System.out.println(se.parse("3.0 + 3 * 5.0 / 2.0"));
    System.out.println(se.parse("3 + 3f * 5 / 2f"));
    System.out.println(se.parse("\"hello \" + \"firefly \""));
    System.out.println(se.parse("'hello ' + 'firefly ' + '!'"));
    System.out.println(se.parse("'hello ' + 'firefly ' + ${i} + '!'"));
//    System.out.println(se.parse("${i} + ${j} + ${k}"));
   
    System.out.println(se.parse("${i} + 3 + 5 + 2 / 1.0"));
    System.out.println(se.parse("(3f + ${j}) / 2 + ${i} + 1.0"));
    System.out.println(se.parse("1L +" + Integer.MAX_VALUE));
    System.out.println(1 + Integer.MAX_VALUE);
    System.out.println(se.parse("(3f + ${apple.price}) / 2 + ${i} + 1.0"));
    System.out.println(se.parse("(3f + ${apple.price}) / 2 + ${i} + 1.0 >= 2"));
    System.out.println(se.parse("!${i} || !${j} && ${k}"));
    System.out.println(se.parse("1 | 2 & ${i}"));
    System.out.println(se.parse("${i} & ${j}"));
//    System.out.println(se.parse("${apple.price} + 1f >= 5 && ${apple.price} + 1f < 10"));
//    System.out.println(se.parse("! ${user1.pass} == !true && ${user2.pass} == true "));
   
    System.out.println(se.parse("!${user.pass}"));
//    System.out.println(se.parse("(3f + ${j} --) / 2 + ${i}++ + 1.0"));
   
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    Assert.assertThat(list.get(1).type, is(RPNUtils.Type.DOUBLE));
  }
 
  @Test
  public void testELParse() {
    StatementExpression se = new StatementExpression();
    Assert.assertThat(se.parse("3 + 3 * 5 / 2"), is("10"));
    Assert.assertThat(se.parse("3L + 3L * 5L / 2L"), is("10"));
    Assert.assertThat(se.parse("3.0 + 3.0 * 5.0 / 2.0"), is("10.5"));
    Assert.assertThat(se.parse("3f + 3f * 5f / 2f"), is("10.5"));
    Assert.assertThat(se.parse("3.0 + 3 * 5.0 / 2.0"), is("10.5"));
    Assert.assertThat(se.parse("3 + 3f * 5 / 2f"), is("10.5"));
    Assert.assertThat(se.parse("1L +" + Integer.MAX_VALUE), is("2147483648"));
    Assert.assertThat(se.parse("1 +" + Integer.MAX_VALUE), is("-2147483648"));
   
    Assert.assertThat(se.parse("\"hello \" + \"firefly \\\" ***!! \""), is("\"hello firefly \\\" ***!! \""));
    Assert.assertThat(se.parse("\"hello \" + \"firefly \" + \"!\""), is("\"hello firefly !\""));
    Assert.assertThat(se.parse("'hello ' + 'firefly ' + '!'"), is("\"hello firefly !\""));
    Assert.assertThat(se.parse("'hello ' + 'firefly ' + ${i} + '!'"), is("\"hello firefly \" + objNav.getValue(model ,\"i\") + \"!\""));
    Assert.assertThat(se.parse("(3f + ${j}) / 2 + ${i} + 1.0"), is("(((3 + objNav.getFloat(model ,\"j\")) / 2 + objNav.getFloat(model ,\"i\")) + 1.0)"));
   
    Assert.assertThat(se.parse("true"), is("true"));
    Assert.assertThat(se.parse("false"), is("false"));
    Assert.assertThat(se.parse("! true"), is("! true"));
    Assert.assertThat(se.parse("1|2"), is("3"));
    Assert.assertThat(se.parse("!${user.pass}"), is("!objNav.getBoolean(model ,\"user.pass\")"));
    Assert.assertThat(se.parse("${user.pass}"), is("objNav.getBoolean(model ,\"user.pass\")"));
    Assert.assertThat(se.parse("1 | 2 & ${i}"), is("(1 | (2 & objNav.getInteger(model ,\"i\")))"));
    Assert.assertThat(se.parse("!${i} || !${j} && ${k}"), is("(!objNav.getBoolean(model ,\"i\") || (!objNav.getBoolean(model ,\"j\") && objNav.getBoolean(model ,\"k\")))"));
    Assert.assertThat(se.parse("${i} & ${j}"), is("(objNav.getBoolean(model ,\"i\") & objNav.getBoolean(model ,\"j\"))"));
    Assert.assertThat(se.parse("${apple.price} > 7f && ${apple.price} <= 3"), is("(objNav.getFloat(model ,\"apple.price\") > 7) && (objNav.getInteger(model ,\"apple.price\") <= 3)"));
    Assert.assertThat(se.parse("${i} != 'pt1 !'"), is("!((Object)(\"pt1 !\")).equals(objNav.find(model ,\"i\"))"));
    Assert.assertThat(se.parse("'pt1 !'!='pt1 !'"), is("false"));
    Assert.assertThat(se.parse("${i} == ${j} && ${i} != ${k}"), is("objNav.find(model ,\"i\").equals(objNav.find(model ,\"j\")) && !objNav.find(model ,\"i\").equals(objNav.find(model ,\"k\"))"));
    Assert.assertThat(se.parse("${i} != null && null == ${j} && ${i} != ${k}"), is("objNav.find(model ,\"i\") != null && null == objNav.find(model ,\"j\") && !objNav.find(model ,\"i\").equals(objNav.find(model ,\"k\"))"));
    Assert.assertThat(se.parse("3 + 4 +-( -(2 - 1) + 1)"), is("7"));
    Assert.assertThat(se.parse("-(3 + 4) +-( -(2 - 1) + 1)"), is("-7"));
    Assert.assertThat(se.parse("!(${apple.price} > 7f && -(${apple.price} + 2) * 0.4 + 4 <= 3)"), is("((Object)((objNav.getFloat(model ,\"apple.price\") > 7) && (((0 - (objNav.getInteger(model ,\"apple.price\") + 2)) * 0.4 + 4) <= 3))).equals(false)"));
    Assert.assertThat(se.parse("${i} != null && ${i.size} > 0"), is("objNav.find(model ,\"i\") != null && (objNav.getInteger(model ,\"i.size\") > 0)"));
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    Assert.assertThat(se.parse("${i} != null && ${i.size} > 0"), is("objNav.find(model ,\"i\") != null && (objNav.getInteger(model ,\"i.size\") > 0)"));
  }
 
  @Test(expected = ExpressionError.class)
  public void testELParseError() {
    StatementExpression se = new StatementExpression();
    se.parse("${i} + ${j} + ${k}");
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    se.parse("${i} + ${j} + ${k}");
  }
 
  @Test(expected = ExpressionError.class)
  public void testELParseError2() {
    StatementExpression se = new StatementExpression();
    se.parse("${i} + ${j} + 2");
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    se.parse("${i} + ${j} + 2");
  }
 
  @Test(expected = ExpressionError.class)
  public void testELParseError3() {
    StatementExpression se = new StatementExpression();
    se.parse("${i}-- + ${j} + 2");
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    Assert.assertThat(list.get(1).type, is(RPNUtils.Type.DOUBLE));
  }
 
  @Test
  public void testELParse() {
    StatementExpression se = new StatementExpression();
    Assert.assertThat(se.parse("3 + 3 * 5 / 2"), is("10"));
    Assert.assertThat(se.parse("3L + 3L * 5L / 2L"), is("10"));
    Assert.assertThat(se.parse("3.0 + 3.0 * 5.0 / 2.0"), is("10.5"));
    Assert.assertThat(se.parse("3f + 3f * 5f / 2f"), is("10.5"));
    Assert.assertThat(se.parse("3.0 + 3 * 5.0 / 2.0"), is("10.5"));
    Assert.assertThat(se.parse("3 + 3f * 5 / 2f"), is("10.5"));
    Assert.assertThat(se.parse("1L +" + Integer.MAX_VALUE), is("2147483648"));
    Assert.assertThat(se.parse("1 +" + Integer.MAX_VALUE), is("-2147483648"));
   
    Assert.assertThat(se.parse("\"hello \" + \"firefly \\\" ***!! \""), is("\"hello firefly \\\" ***!! \""));
    Assert.assertThat(se.parse("\"hello \" + \"firefly \" + \"!\""), is("\"hello firefly !\""));
    Assert.assertThat(se.parse("'hello ' + 'firefly ' + '!'"), is("\"hello firefly !\""));
    Assert.assertThat(se.parse("'hello ' + 'firefly ' + ${i} + '!'"), is("\"hello firefly \" + objNav.getValue(model ,\"i\") + \"!\""));
    Assert.assertThat(se.parse("(3f + ${j}) / 2 + ${i} + 1.0"), is("(((3 + objNav.getFloat(model ,\"j\")) / 2 + objNav.getFloat(model ,\"i\")) + 1.0)"));
   
    Assert.assertThat(se.parse("true"), is("true"));
    Assert.assertThat(se.parse("false"), is("false"));
    Assert.assertThat(se.parse("! true"), is("! true"));
    Assert.assertThat(se.parse("1|2"), is("3"));
    Assert.assertThat(se.parse("!${user.pass}"), is("!objNav.getBoolean(model ,\"user.pass\")"));
    Assert.assertThat(se.parse("${user.pass}"), is("objNav.getBoolean(model ,\"user.pass\")"));
    Assert.assertThat(se.parse("1 | 2 & ${i}"), is("(1 | (2 & objNav.getInteger(model ,\"i\")))"));
    Assert.assertThat(se.parse("!${i} || !${j} && ${k}"), is("(!objNav.getBoolean(model ,\"i\") || (!objNav.getBoolean(model ,\"j\") && objNav.getBoolean(model ,\"k\")))"));
    Assert.assertThat(se.parse("${i} & ${j}"), is("(objNav.getBoolean(model ,\"i\") & objNav.getBoolean(model ,\"j\"))"));
    Assert.assertThat(se.parse("${apple.price} > 7f && ${apple.price} <= 3"), is("(objNav.getFloat(model ,\"apple.price\") > 7) && (objNav.getInteger(model ,\"apple.price\") <= 3)"));
    Assert.assertThat(se.parse("${i} != 'pt1 !'"), is("!((Object)(\"pt1 !\")).equals(objNav.find(model ,\"i\"))"));
    Assert.assertThat(se.parse("'pt1 !'!='pt1 !'"), is("false"));
    Assert.assertThat(se.parse("${i} == ${j} && ${i} != ${k}"), is("objNav.find(model ,\"i\").equals(objNav.find(model ,\"j\")) && !objNav.find(model ,\"i\").equals(objNav.find(model ,\"k\"))"));
    Assert.assertThat(se.parse("${i} != null && null == ${j} && ${i} != ${k}"), is("objNav.find(model ,\"i\") != null && null == objNav.find(model ,\"j\") && !objNav.find(model ,\"i\").equals(objNav.find(model ,\"k\"))"));
    Assert.assertThat(se.parse("3 + 4 +-( -(2 - 1) + 1)"), is("7"));
    Assert.assertThat(se.parse("-(3 + 4) +-( -(2 - 1) + 1)"), is("-7"));
    Assert.assertThat(se.parse("!(${apple.price} > 7f && -(${apple.price} + 2) * 0.4 + 4 <= 3)"), is("((Object)((objNav.getFloat(model ,\"apple.price\") > 7) && (((0 - (objNav.getInteger(model ,\"apple.price\") + 2)) * 0.4 + 4) <= 3))).equals(false)"));
    Assert.assertThat(se.parse("${i} != null && ${i.size} > 0"), is("objNav.find(model ,\"i\") != null && (objNav.getInteger(model ,\"i.size\") > 0)"));
  }
View Full Code Here

Examples of com.firefly.template.parser.StatementExpression

    Assert.assertThat(se.parse("${i} != null && ${i.size} > 0"), is("objNav.find(model ,\"i\") != null && (objNav.getInteger(model ,\"i.size\") > 0)"));
  }
 
  @Test
  public void testELParseError() {
    StatementExpression se = new StatementExpression();
    Assert.assertThat(se.parse("${i} + ${j} + ${k}"), is("objNav.getValue(model ,\"i\") + objNav.getValue(model ,\"j\") + objNav.getValue(model ,\"k\")"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.