Package de.odysseus.el.tree

Examples of de.odysseus.el.tree.Bindings


    try { parse("${g1()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
    try { parse("${g1(1,2)}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
  }

  public void testBindVariables() throws Exception {
    Bindings bindings = null;
       
    bindings = parse("${v0}").bind(null, context.getVariableMapper());
    assertSame(context.getVariableMapper().resolveVariable("v0"), bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}

    bindings = parse("${v1}").bind(null, context.getVariableMapper());
    assertSame(context.getVariableMapper().resolveVariable("v1"), bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}

    bindings = parse("${v0+v1}").bind(null, context.getVariableMapper());
    assertSame(context.getVariableMapper().resolveVariable("v0"), bindings.getVariable(0));
    assertSame(context.getVariableMapper().resolveVariable("v1"), bindings.getVariable(1));
    try { bindings.getVariable(2); fail(); } catch (Exception e) {}

    bindings = parse("${foo}").bind(null, context.getVariableMapper());
    assertNull(bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}
  }
View Full Code Here


    assertNull(bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}
  }

  public void testBindFunctionsAndVariables() throws Exception {
    Bindings bindings = parse("${ns:f0()+v0+g1(1)+v1+foo}").bind(context.getFunctionMapper(), context.getVariableMapper());
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
    assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(1));
    try { bindings.getFunction(2); fail(); } catch (Exception e) {}
    assertSame(context.getVariableMapper().resolveVariable("v0"), bindings.getVariable(0));
    assertSame(context.getVariableMapper().resolveVariable("v1"), bindings.getVariable(1));
    assertNull(bindings.getVariable(2));
    try { bindings.getVariable(3); fail(); } catch (Exception e) {}
  }
View Full Code Here

          return null;
        }
      };
      out.print(">> ");
      try {
        out.println(tree.getRoot().getValue(new Bindings(null, null), context, null));
      } catch (ELException e) {
        out.println(e.getMessage());
      }
    }
    out.flush();
View Full Code Here

          return null;
        }
      };
      out.print(">> ");
      try {
        out.println(tree.getRoot().getValue(new Bindings(null, null), context, null));
      } catch (ELException e) {
        out.println(e.getMessage());
      }
    }
    out.flush();
View Full Code Here

    // variable v
    context.setVariable("v", new ObjectValueExpression(TypeConverter.DEFAULT, new Long(0), long.class));
  }

  public void testSerialize() throws Exception {
    Bindings bindings = null;

    bindings = new Bindings(null, null);
    assertEquals(bindings, deserialize(serialize(bindings)));

    bindings = parse("${ns:f()+v+g(1)+x}").bind(context.getFunctionMapper(), context.getVariableMapper());
    assertEquals(bindings, deserialize(serialize(bindings)));
  }
View Full Code Here

    bindings = parse("${ns:f()+v+g(1)+x}").bind(context.getFunctionMapper(), context.getVariableMapper());
    assertEquals(bindings, deserialize(serialize(bindings)));
  }
 
  public void testEqualsAndHashcode() throws Exception {
    Bindings bindings1 = null;
    Bindings bindings2 = null;

    bindings1 = new Bindings(null, null);
    bindings2 = new Bindings(null, null);
    assertEquals(bindings1, bindings2);
    assertEquals(bindings1.hashCode(), bindings2.hashCode());

    bindings1 = new Bindings(new Method[0], new ValueExpression[0]);
    bindings2 = new Bindings(null, null);
    assertEquals(bindings1, bindings2);
    assertEquals(bindings1.hashCode(), bindings2.hashCode());

    Tree tree = parse("${ns:f()+v+g(1)}+x");
    bindings1 = tree.bind(context.getFunctionMapper(), context.getVariableMapper());
    bindings2 = tree.bind(context.getFunctionMapper(), context.getVariableMapper());
    assertEquals(bindings1, bindings2);
    assertEquals(bindings1.hashCode(), bindings2.hashCode());
  }
View Full Code Here

    context.setVariable("v0", new ObjectValueExpression(TypeConverter.DEFAULT, 0, long.class));
    context.setVariable("v1", new ObjectValueExpression(TypeConverter.DEFAULT, 1, long.class));
  }

  public void testBindFunctions() throws Exception {
    Bindings bindings = null;
   
    bindings = parse("${ns:f0()}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}
   
    bindings = parse("${ns:f1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f1"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}

    bindings = parse("${ns:f0()+ns:f1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f1"), bindings.getFunction(1));
    try { bindings.getFunction(2); fail(); } catch (Exception e) {}

    // the same for default namespace functions g0(), g1()
    bindings = parse("${g0()}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("", "g0"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}
   
    bindings = parse("${g1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}

    bindings = parse("${g0()+g1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("", "g0"), bindings.getFunction(0));
    assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(1));
    try { bindings.getFunction(2); fail(); } catch (Exception e) {}

    try { parse("${foo()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
    try { parse("${g1()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
    try { parse("${g1(1,2)}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
  }
View Full Code Here

    try { parse("${g1()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
    try { parse("${g1(1,2)}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
  }

  public void testBindVariables() throws Exception {
    Bindings bindings = null;
       
    bindings = parse("${v0}").bind(null, context.getVariableMapper());
    assertSame(context.getVariableMapper().resolveVariable("v0"), bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}

    bindings = parse("${v1}").bind(null, context.getVariableMapper());
    assertSame(context.getVariableMapper().resolveVariable("v1"), bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}

    bindings = parse("${v0+v1}").bind(null, context.getVariableMapper());
    assertSame(context.getVariableMapper().resolveVariable("v0"), bindings.getVariable(0));
    assertSame(context.getVariableMapper().resolveVariable("v1"), bindings.getVariable(1));
    try { bindings.getVariable(2); fail(); } catch (Exception e) {}

    bindings = parse("${foo}").bind(null, context.getVariableMapper());
    assertNull(bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}
  }
View Full Code Here

    assertNull(bindings.getVariable(0));
    try { bindings.getVariable(1); fail(); } catch (Exception e) {}
  }

  public void testBindFunctionsAndVariables() throws Exception {
    Bindings bindings = parse("${ns:f0()+v0+g1(1)+v1+foo}").bind(context.getFunctionMapper(), context.getVariableMapper());
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
    assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(1));
    try { bindings.getFunction(2); fail(); } catch (Exception e) {}
    assertSame(context.getVariableMapper().resolveVariable("v0"), bindings.getVariable(0));
    assertSame(context.getVariableMapper().resolveVariable("v1"), bindings.getVariable(1));
    assertNull(bindings.getVariable(2));
    try { bindings.getVariable(3); fail(); } catch (Exception e) {}
  }
View Full Code Here

    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) {}
   
View Full Code Here

TOP

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

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.