Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.STGroupFile


      "  <t()>\n" +
      "  <(t())>\n" +
      ">>\n";

    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    String result = st.render();
    String expected =
      "  abc" + newline +
      "  abc" + newline +
      "    abc" + newline +
View Full Code Here


      "  <t()>\n" +
      "  <(t())>\n" +
      ">>\n";

    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST st = group.getInstanceOf("main");
    StringWriter sw = new StringWriter();
    NoIndentWriter w = new NoIndentWriter(sw);
    st.write(w);
    String result = sw.toString();
    String expected =
View Full Code Here

    String templates =
        "typeInit ::= [\"int\":\"0\", \"float\":\"0.0\"] "+newline+
        "var(type,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
        ;
    writeFile(tmpdir, "test.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
    ST st = group.getInstanceOf("var");
    st.add("type", "int");
    st.add("name", "x");
    String expecting = "int x = 0;";
    String result = st.render();
    assertEquals(expecting, result);
View Full Code Here

        String templates =
                "typeInit ::= [\"int\":{0<w>}, \"float\":{0.0<w>}] "+newline+
                "var(type,w,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
                ;
        writeFile(tmpdir, "test.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
        ST st = group.getInstanceOf("var");
    st.impl.dump();
        st.add("w", "L");
        st.add("type", "int");
        st.add("name", "x");
        String expecting = "int x = 0L;";
View Full Code Here

        String templates =
                "typeInit ::= [\"int\":{0<w>}, \"float\":{0.0<w>}] "+newline+
                "var(type,w,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
                ;
        writeFile(tmpdir, "test.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
        ST st = group.getInstanceOf("var");
        st.add("w", "L");
        st.add("type", new ST("int"));
        st.add("name", "x");
        String expecting = "int x = 0L;";
        String result = st.render();
View Full Code Here

        // Make sure we try rendering stuff to string if not found as regular object
        String templates =
                "foo(m,k) ::= \"<m.(k)>\""+newline
                ;
        writeFile(tmpdir, "test.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
        ST st = group.getInstanceOf("foo");
        Map<HashableUser,String> m = new HashMap<HashableUser,String>();
        m.put(new HashableUser(99,"parrt"), "first");
        m.put(new HashableUser(172036,"tombu"), "second");
        m.put(new HashableUser(391,"sriram"), "third");
        st.add("m", m);
View Full Code Here

    String templates =
        "typeInit ::= [\"int\":\"0\", \"float\":\"0.0\"] "+newline+
        "var(type,w,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
        ;
    writeFile(tmpdir, "test.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
    ST st = group.getInstanceOf("var");
    st.add("w", "L");
    st.add("type", "double"); // double not in typeInit map
    st.add("name", "x");
    String expecting = "double x = ;";
    String result = st.render();
View Full Code Here

    String templates =
        "typeInit ::= [\"int\":\"0\", \"float\":\"0.0\"] "+newline+
        "var(type,w,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
        ;
    writeFile(tmpdir, "test.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
    ST st = group.getInstanceOf("var");
    st.add("w", "L");
    st.add("type", null); // double not in typeInit map
    st.add("name", "x");
    String expecting = " x = ;";
    String result = st.render();
View Full Code Here

        String templates =
                "typeInit ::= [\"int\":\"0\", \"float\":\"0.0\"] "+newline+
                "var(typeInit,type,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
                ;
        writeFile(tmpdir, "test.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
        ST st = group.getInstanceOf("var");
        st.add("type", "int");
        st.add("name", "x");
        String expecting = "int x = ;";
        String result = st.render();
        assertEquals(expecting, result);
View Full Code Here

        String templates =
                "typeInit ::= [\"int\":\"0\", \"float\":, \"double\":<<0.0L>>] "+newline+
                "var(type,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
                ;
        writeFile(tmpdir, "test.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"test.stg");
        ST st = group.getInstanceOf("var");
        st.add("type", "float");
        st.add("name", "x");
        String expecting = "float x = ;";
        String result = st.render();
        assertEquals(expecting, result);
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.STGroupFile

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.