Package org.nutz.el

Examples of org.nutz.el.El


public class El2Test {
  El el;

  @Before
  public void setUp() {
    el = new El();
  }
View Full Code Here


    System.out.println("\n" + Strings.dup('=', 100));
   
    Stopwatch sw4 = Stopwatch.run(new Atom() {
      public void run() {
        try {
          El el2pre = new El(elstr);
          context.set("num", 0);
          context.set("z", z);
          for (int i = 0; i < max; i++)
            context.set("num", el2pre.eval(context.set("i", i)));
          System.out.println("Num: " + context.getInt("num"));
        }
        catch (Exception e) {
          throw Lang.wrapThrow(e);
        }
      }
    });
    System.out.println("\n" + Strings.dup('=', 100));
   
    Stopwatch sw5 = Stopwatch.run(new Atom() {
      public void run() {
        try {
          El el2pre = new El(elstr);
          context.set("num", 0);
          context.set("z", z);
          for (int i = 0; i < max; i++)
            context.set("num", el2pre.eval(context.set("i", i)));
          System.out.println("Num: " + context.getInt("num"));
        }
        catch (Exception e) {
          throw Lang.wrapThrow(e);
        }
View Full Code Here

  private MappingField entityField;

  public ElFieldMacro(MappingField field, String str) {
    this.entityField = field;
    this.bin = new El(str);
  }
View Full Code Here

    if (null != dest) {
      this.dest = new CharSegment(Strings.trim(dest));
      this.exps = new HashMap<String, El>();
      // 预先将每个占位符解析成表达式
      for (String key : this.dest.keys()) {
        this.exps.put(key, new El(key));
      }
    }
  }
View Full Code Here

        return SqlType.RUN;
    }

    public ElFieldMacro(MappingField field, String str) {
        this.entityField = field;
        this.bin = new El(str);
    }
View Full Code Here

        if (null != dest) {
            this.dest = new CharSegment(Strings.trim(dest));
            this.exps = new HashMap<String, El>();
            // 预先将每个占位符解析成表达式
            for (String key : this.dest.keys()) {
                this.exps.put(key, new El(key));
            }
        }
    }
View Full Code Here

        return SqlType.RUN;
    }

    public ElFieldMacro(MappingField field, String str) {
        this.entityField = field;
        this.bin = new El(str);
    }
View Full Code Here

    @Test
    public void test() throws InstantiationException, IllegalAccessException{
        String[] a = new String[]{"a","b"};
        Map<String, String[]> map = new HashMap<String, String[]>();
        map.put("a", a);
        El exp = new El("util.test(map['a'])");
        Context context = Lang.context();
        context.set("util",StringUtil.class.newInstance());
        context.set("map", map);
        assertEquals("ab", exp.eval(context));
    }
View Full Code Here

        String[] a = new String[]{"a","b"};
        String[] b = new String[]{"1","2"};
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("a", a);
        map.put("b", b);
        El exp = new El("util.test(map['a'][0],map['b'][0])")// 预编译结果为一个 El 对象
        Context context = Lang.context();
        context.set("util",new StringUtil());
        context.set("map", map);
        System.out.println(exp.eval(context));
    }
View Full Code Here

        System.out.println("\n" + Strings.dup('=', 100));
       
        Stopwatch sw4 = Stopwatch.run(new Atom() {
            public void run() {
                try {
                    El el2pre = new El(elstr);
                    context.set("num", 0);
                    context.set("z", z);
                    for (int i = 0; i < max; i++)
                        context.set("num", el2pre.eval(context.set("i", i)));
                    System.out.println("Num: " + context.getInt("num"));
                }
                catch (Exception e) {
                    throw Lang.wrapThrow(e);
                }
            }
        });
        System.out.println("\n" + Strings.dup('=', 100));
       
        Stopwatch sw5 = Stopwatch.run(new Atom() {
            public void run() {
                try {
                    El el2pre = new El(elstr);
                    context.set("num", 0);
                    context.set("z", z);
                    for (int i = 0; i < max; i++)
                        context.set("num", el2pre.eval(context.set("i", i)));
                    System.out.println("Num: " + context.getInt("num"));
                }
                catch (Exception e) {
                    throw Lang.wrapThrow(e);
                }
View Full Code Here

TOP

Related Classes of org.nutz.el.El

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.