Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.ST$AttributeList


    String templates =
      "t(x,y) ::= \"<u()>\"\n"+
      "u() ::= \"<x><y>\"\n";
    Misc.writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("t");
    st.add("x", 1);
    st.add("y", 2);

    for (int i = 0; i < reps; i++) {
      st.render();
    }
  }
View Full Code Here


      "u15(a) ::= \"<u16({eh})>\"\n"+
      "u16(a) ::= \"<z({eh})>\"\n"+
      "z(a) ::= \"<x><y>\"\n";
    Misc.writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("t");
    st.add("x", 1);
    st.add("y", 2);

    for (int i = 0; i < reps; i++) {
      st.render();
    }
  }
View Full Code Here

  }

  public void timeSingle(int reps) {
    String template =
      "A smallish string to write out";
    ST st = new ST(template);
    for (int i = 0; i < reps; i++) {
      st.render();
    }
  }
View Full Code Here

      st.render();
    }
  }

  public void timeSingleBigger(int reps) {
    ST st = new ST(bigTemplate);
    for (int i = 0; i < reps; i++) {
      st.render();
    }
  }
View Full Code Here

      STGroup group = new STGroup();
//      System.out.println("running "+test);
      group.defineTemplate("t", "x", "<x>");
      group.defineTemplate("u", "x", "<x>");
      group.defineTemplate("test", "x", test.template);
      ST st = group.getInstanceOf("test");
      if ( test.x!=UNDEF ) {
        st.add("x", test.x);
      }
      String result = st.render();
      if ( !result.equals(test.expecting) ) {
        test.result = result;
        failed.add(test);
      }
    }
View Full Code Here


  @Test public void testSeparatorWithNullFirstValue() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "hi <name; separator=\", \">!");
    ST st = group.getInstanceOf("test");
    st.add("name", null); // null is added to list, but ignored in iteration
    st.add("name", "Tom");
    st.add("name", "Sumana");
    String expected = "hi Tom, Sumana!";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  @Test public void testTemplateAppliedToNullIsEmpty() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "<name:t()>");
    group.defineTemplate("t", "x", "<x>");
    ST st = group.getInstanceOf("test");
    st.add("name", null);
    String expected = "";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  @Test public void testTemplateAppliedToMissingValueIsEmpty() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "<name:t()>");
    group.defineTemplate("t", "x", "<x>");
    ST st = group.getInstanceOf("test");
    String expected = "";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

    @Test public void testSeparatorWithNull2ndValue() throws Exception {
        STGroup group = new STGroup();
        group.defineTemplate("test", "name", "hi <name; separator=\", \">!");
        ST st = group.getInstanceOf("test");
        st.add("name", "Ter");
        st.add("name", null);
        st.add("name", "Sumana");
        String expected = "hi Ter, Sumana!";
        String result = st.render();
        assertEquals(expected, result);
    }
View Full Code Here

    }

    @Test public void testSeparatorWithNullLastValue() throws Exception {
        STGroup group = new STGroup();
        group.defineTemplate("test", "name", "hi <name; separator=\", \">!");
        ST st = group.getInstanceOf("test");
        st.add("name", "Ter");
        st.add("name", "Tom");
        st.add("name", null);
        String expected = "hi Ter, Tom!";
        String result = st.render();
        assertEquals(expected, result);
    }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.ST$AttributeList

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.