Examples of AutoIndentWriter


Examples of org.stringtemplate.v4.AutoIndentWriter

  public void write(ST code, String fileName) {
    try {
//      long start = System.currentTimeMillis();
      Writer w = tool.getOutputFileWriter(g, fileName);
      STWriter wr = new AutoIndentWriter(w);
      wr.setLineWidth(lineWidth);
      code.write(wr);
      w.close();
//      long stop = System.currentTimeMillis();
    }
    catch (IOException ioe) {
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

    ST st = new ST(
      "<values:{v|<if(v)>x<endif>}; separator=\" \">"
    );
    st.add("values", new boolean[] {true, false, true});
    StringWriter sw = new StringWriter();
    st.write(new AutoIndentWriter(sw));
    String result = sw.toString();
    String expecting = "x  x";
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

    writeFile(dir, "group.stg", groupFile);
    STGroupFile group = new STGroupFile(dir+"/group.stg");

    ST st = group.getInstanceOf("t");
    StringWriter sw = new StringWriter();
    st.write(new AutoIndentWriter(sw));
    String result = sw.toString();
    String expecting = "a,,c,";
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

    ST st = new ST(
      "<values; separator=\" \">"
    );
    st.add("values", new String[]{"x", "", "y"});
    StringWriter sw = new StringWriter();
    st.write(new AutoIndentWriter(sw));
    String result = sw.toString();
    String expecting = "x  y";
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

    @Test public void testCharLiterals() throws Exception {
        ST st = new ST(
                "Foo <\\n><\\n><\\t> bar\n"
                );
        StringWriter sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        String result = sw.toString();
        String expecting ="Foo \n\n\t bar\n";     // expect \n in output
        assertEquals(expecting, result);

        st = new ST(
                "Foo <\\n><\\t> bar" +newline);
        sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        expecting ="Foo \n\t bar\n";     // expect \n in output
        result = sw.toString();
        assertEquals(expecting, result);

        st = new ST(
                "Foo<\\ >bar<\\n>");
        sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        result = sw.toString();
        expecting ="Foo bar\n"; // forced \n
        assertEquals(expecting, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

        ST st = new ST(
                "Foo <\\\\>"+newline+
                "  \t  bar" +newline
                );
        StringWriter sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        String result = sw.toString();
        String expecting ="Foo bar\n";     // expect \n in output
        assertEquals(expecting, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

        ST st = new ST(
                "Foo <\\\\>       "+newline+
                "  \t  bar" +newline
                );
        StringWriter sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        String result = sw.toString();
        String expecting ="Foo bar\n";
        assertEquals(expecting, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

        ST st = new ST(
                "Foo <\\\\>"+newline+
                "bar\n"
                );
        StringWriter sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        String result = sw.toString();
        String expecting ="Foo bar\n";
        assertEquals(expecting, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

        ST st = new ST(
                "Foo\r\n"+
                "Bar\n"
                );
        StringWriter sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
        String result = sw.toString();
        String expecting ="Foo\nBar\n";     // expect \n in output
        assertEquals(expecting, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.AutoIndentWriter

        ST st = new ST(
                "Foo\r\n"+
                "Bar\n"
                );
        StringWriter sw = new StringWriter();
        st.write(new AutoIndentWriter(sw,"\r\n")); // force \r\n as newline
        String result = sw.toString();
        String expecting ="Foo\r\nBar\r\n";     // expect \r\n in output
        assertEquals(expecting, result);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.