Package com.firefly.template

Examples of com.firefly.template.Function


  public static void main(String[] args) throws IOException, URISyntaxException {
    User user = new User();
    user.setName("Jim");
    user.setAge(25);
   
    Function function = new Function(){
      @Override
      public void render(Model model, OutputStream out, Object... obj) {
        Integer i = (Integer)obj[0];
        String str = (String)obj[1];
        String o = String.valueOf(obj[2]);
       
        try {
          out.write((i + "|" + str + "|" + o).getBytes("UTF-8"));
        } catch (IOException e) {
          e.printStackTrace();
        }
      }};
    FunctionRegistry.add("testFunction", function);
   
    Function function2 = new Function(){
      @Override
      public void render(Model model, OutputStream out, Object... obj) {
        try {
          out.write("testFunction2".getBytes("UTF-8"));
        } catch (IOException e) {
View Full Code Here


        System.out.println("freemark: " + (end - start) + "ms\t" + (int)(times / (double)(end - start) * 1000) + "tps");
//        System.out.println(new String(ret, "UTF-8"));
       
        // firefly
        final TemplateFactory t = new TemplateFactory(new File(TestConfig.class.getResource("/").toURI())).init();
        FunctionRegistry.add("book_count", new Function() {

      @Override
      public void render(Model model, OutputStream out, Object... obj) throws Throwable {
        Book book = (Book)obj[0];
        out.write(String.valueOf(book.getPrice() * book.getDiscount() / 100).getBytes(t.getConfig().getCharset()));
View Full Code Here

  private AddService addService;

  @Inject
  public void init(AddService addService) {
    this.addService = addService;
    FunctionRegistry.add("url", new Function() {

      @Override
      public void render(Model model, OutputStream out, Object... objs)
          throws Throwable {
        String url = (String) objs[0];
View Full Code Here

  public static void main(String[] args) throws IOException, URISyntaxException {
    User user = new User();
    user.setName("Jim");
    user.setAge(25);
   
    Function function = new Function(){
      @Override
      public void render(Model model, OutputStream out, Object... obj) {
        Integer i = (Integer)obj[0];
        String str = (String)obj[1];
        String o = String.valueOf(obj[2]);
       
        try {
          out.write((i + "|" + str + "|" + o).getBytes("UTF-8"));
        } catch (IOException e) {
          e.printStackTrace();
        }
      }};
    FunctionRegistry.add("testFunction", function);
   
    Function function2 = new Function(){
      @Override
      public void render(Model model, OutputStream out, Object... obj) {
        try {
          out.write("testFunction2".getBytes("UTF-8"));
        } catch (IOException e) {
View Full Code Here

        System.out.println("freemark: " + (end - start) + "ms\t" + (int)(times / (double)(end - start) * 1000) + "tps");
//        System.out.println(new String(ret, "UTF-8"));
       
        // firefly
        final TemplateFactory t = new TemplateFactory(new File(TestConfig.class.getResource("/").toURI())).init();
        FunctionRegistry.add("book_count", new Function() {

      @Override
      public void render(Model model, OutputStream out, Object... obj) throws Throwable {
        Book book = (Book)obj[0];
        out.write(String.valueOf(book.getPrice() * book.getDiscount() / 100).getBytes(t.getConfig().getCharset()));
View Full Code Here

TOP

Related Classes of com.firefly.template.Function

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.