Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.AutoIndentWriter


          new DebugInterpreter(outputFileST.groupThatCreatedThisInstance,
              outputFileST.impl.nativeGroup.errMgr,
              debug);
      InstanceScope scope = new InstanceScope(null, outputFileST);
      StringWriter sw = new StringWriter();
      AutoIndentWriter out = new AutoIndentWriter(sw);
      interp.exec(out, scope);

      for (String e : interp.evals) {
        if (e.contains(pattern)) {
          evals.add(e);
View Full Code Here


  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

    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

    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

    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

    @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

        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

        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

        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

        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

TOP

Related Classes of org.stringtemplate.v4.AutoIndentWriter

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.