Package de.odysseus.el.tree

Examples of de.odysseus.el.tree.Tree


    assertEquals(expression, tree.getRoot().getStructuralId(null));
    return tree;
  }

  static Tree verifyEvalExpression(String canonical) {
    Tree tree = parse(canonical);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return tree;
  }
View Full Code Here


    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return tree;
  }

  static Tree verifyEvalExpression(String canonical, String expression) {
    Tree tree = parse(expression);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical);
  }
View Full Code Here

    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical);
  }

  static Tree verifyEvalExpression(String canonical, String expression1, String expression2) {
    Tree tree = parse(expression2);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical, expression1);
  }
View Full Code Here

    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical, expression1);
  }

  static Tree verifyCompositeExpression(String canonical) {
    Tree tree = parse(canonical);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return tree;
  }
View Full Code Here

    verifyLiteralExpression("\"foo\"");
    verifyLiteralExpression("'foo'");
  }

  Tree verifyBinary(AstBinary.Operator op, String canonical) {
    Tree tree = verifyEvalExpression(canonical);
    assertTrue((tree.getRoot()).getChild(0) instanceof AstBinary);
    assertEquals(op, ((AstBinary)tree.getRoot().getChild(0)).getOperator());
    return tree;
  }
View Full Code Here

    context.setVariable("var_var_long_1", new TreeValueExpression(new TreeStore(BUILDER, null), null, context.getVariableMapper(), null, "${var_long_1}", long.class))
    context.setVariable("var_property_long_1", new TreeValueExpression(new TreeStore(BUILDER, null), null, context.getVariableMapper(), null, "${property_long_1}", long.class))
  }

  public void testEval() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).eval(bindings, context); fail(); } catch (ELException e) {}
   
    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).eval(bindings, context));

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).eval(bindings, context));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals("foo", getNode(tree).eval(bindings, context));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).eval(bindings, context));

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).eval(bindings, context));
  }
View Full Code Here

  public void testIsLeftValue() {
    assertTrue(parseNode("${foo}").isLeftValue());
  }

  public void testGetType() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(Object.class, getNode(tree).getType(bindings, context));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(Object.class, getNode(tree).getType(bindings, context));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));
  }
View Full Code Here

    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));
  }

  public void testIsReadOnly() {
    Tree tree = null;
    Bindings bindings = null;
   
    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertFalse(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertFalse(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));
  }
View Full Code Here

    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));
  }

  public void testSetValue() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    getNode(tree).setValue(bindings, context, "good");
    assertEquals("good", getNode(tree).getValue(bindings, context, null));

    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, 2l); fail(); } catch (ELException e) {}

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).getValue(bindings, context, null));
    getNode(tree).setValue(bindings, context, 2l);
    assertEquals(2l, getNode(tree).getValue(bindings, context, null));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, 2l); fail(); } catch (ELException e) {}

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(2l, getNode(tree).getValue(bindings, context, null));
    getNode(tree).setValue(bindings, context, 1l);
    assertEquals(1l, getNode(tree).getValue(bindings, context, null));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, "bar"); fail(); } catch (ELException e) {}
  }
View Full Code Here

    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, "bar"); fail(); } catch (ELException e) {}
  }

  public void testGetValue() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).getValue(bindings, context, null); fail(); } catch (ELException e) {}
   
    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).getValue(bindings, context, null));
    assertEquals("1", getNode(tree).getValue(bindings, context, String.class));
  }
View Full Code Here

TOP

Related Classes of de.odysseus.el.tree.Tree

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.