Package com.firefly.template.support

Examples of com.firefly.template.support.ObjectNavigator


    model.put("a", "fffff");
    model.put("b", map2);
    model.put("arr", arr);
    model.put("list", list);
   
    ObjectNavigator o = ObjectNavigator.getInstance();
    Assert.assertThat(o.find(model, "a").toString(), is("fffff"));
    Assert.assertThat(o.find(model, "b['ccc']").toString(), is("ddd"));
    Assert.assertThat(o.find(model, "b['eee']").toString(), is("fff"));
    Assert.assertThat(o.find(model, "b[\"ccc\"]").toString(), is("ddd"));
    Assert.assertThat((Integer)o.find(model, "arr[2]"), is(333));
    Assert.assertThat(o.find(model, "list[2]").toString(), is("list333"));
  }
View Full Code Here


    foo.setMap(fooMap);
   
    Model model = new ModelMock();
    model.put("foo", foo);
   
    ObjectNavigator o = ObjectNavigator.getInstance();
    Assert.assertThat(String.valueOf(o.find(model, "foo.bar.info")), is("bar1"));
    Assert.assertThat(String.valueOf(o.find(model, "foo.bar.serialNumber")), is("33"));
    Assert.assertThat(String.valueOf(o.find(model, "foo.bar.price")), is("3.3"));
    Assert.assertThat(String.valueOf(o.find(model, "foo.numbers[2]")), is("5"));
    Assert.assertThat(String.valueOf(o.find(model, "foo.map['bar2'].price")), is("2.3"));
    Assert.assertThat(o.find(model, "foo.map['bar5']"), nullValue());
    Assert.assertThat(o.find(model, "ok"), nullValue());
  }
View Full Code Here

    Assert.assertThat(o.find(model, "foo.map['bar5']"), nullValue());
    Assert.assertThat(o.find(model, "ok"), nullValue());
  }
 
  public static void main(String[] args) {
    ObjectNavigator o = ObjectNavigator.getInstance();
   
    Foo foo = new Foo();
    Bar bar = new Bar();
    bar.setInfo("bar1");
    bar.setSerialNumber(33L);
    bar.setPrice(3.30);
    foo.setBar(bar);
   
   
    Map<String, Bar> fooMap = new HashMap<String, Bar>();
    bar = new Bar();
    bar.setInfo("bar2");
    bar.setSerialNumber(23L);
    bar.setPrice(2.30);
    fooMap.put("bar2", bar);
    foo.setMap(fooMap);
   
    Model model = new ModelMock();
    model.put("foo", foo);
   
    System.out.println(o.find(model, "foo.bar.info"));
    System.out.println(o.find(model, "foo.bar.info"));
    System.out.println(o.find(model, "foo.bar.serialNumber"));
    System.out.println(o.find(model, "foo.bar.price"));
    System.out.println(o.find(model, "foo.numbers[2]"));
    System.out.println(o.find(model, "foo.bags[2]"));
    System.out.println(o.find(model, "foo.map['bar2']"));
    System.out.println(o.find(model, "foo.map['bar2'].price"));
    System.out.println(o.find(model, "foo.map['bar4']"));
    System.out.println(o.find(model, "user.name"));
   
//    long start = System.currentTimeMillis();
//    for (int i = 0; i < 1000000; i++) {
//      o.find(model, "foo.numbers[2]");
//    }
View Full Code Here

  public _book_create(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
    FunctionRegistry.get("url").render(model, out, "/app/book/create");
    out.write(_TEXT_1);
  }
View Full Code Here

  public _index2(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
  }
View Full Code Here

  public _index_3(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
  }
View Full Code Here

  public _book(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
    out.write(objNav.getValue(model ,"book.id").getBytes("UTF-8"));
    out.write(_TEXT_1);
    out.write(objNav.getValue(model ,"book.title").getBytes("UTF-8"));
    out.write(_TEXT_2);
    out.write(objNav.getValue(model ,"book.text").getBytes("UTF-8"));
    out.write(_TEXT_3);
    out.write(objNav.getValue(model ,"book.price").getBytes("UTF-8"));
    out.write(_TEXT_4);
    out.write(objNav.getValue(model ,"book.sell").getBytes("UTF-8"));
    out.write(_TEXT_5);
  }
View Full Code Here

  public _index_1(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
  }
View Full Code Here

  public _index(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
    out.write(objNav.getValue(model ,"hello").getBytes("UTF-8"));
    out.write(_TEXT_1);
    templateFactory.getView("/index_1.html").render(model, out);
    templateFactory.getView("/index_2.html").render(model, out);
    templateFactory.getView("/index_3.html").render(model, out);
    templateFactory.getView("/index_3.html").render(model, out);
View Full Code Here

  public _fileUpload(TemplateFactory templateFactory){this.templateFactory = templateFactory;}

  @Override
  protected void main(Model model, OutputStream out) throws Throwable {
    ObjectNavigator objNav = ObjectNavigator.getInstance();
    out.write(_TEXT_0);
    FunctionRegistry.get("url").render(model, out, "/app/upload");
    out.write(_TEXT_1);
  }
View Full Code Here

TOP

Related Classes of com.firefly.template.support.ObjectNavigator

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.