
|
If you were logged in you would be able to see more operations.
|
|
|
ANTLR v3
Created: 16/Apr/07 01:21 PM
Updated: 17/Apr/07 10:03 AM
|
|
| Component/s: |
ANTLR Core
|
| Affects Version/s: |
3.0b7
|
| Fix Version/s: |
3.0b8
|
|
|
Mimic ST:
public String toString(int lineWidth) {
StringWriter out = new StringWriter();
// Write the output to a StringWriter
StringTemplateWriter wr = group.getStringTemplateWriter(out);
wr.setLineWidth(lineWidth);
try {
write(wr);
}
catch (IOException io) {
error("Got IOException writing to writer "+wr.getClass().getName());
}
// reset so next toString() does not wrap; normally this is a new writer
// each time, but just in case they override the group to reuse the
// writer.
wr.setLineWidth(StringTemplateWriter.NO_WRAP);
return out.toString();
}
to write directly to output file instead of to string first. as you can see we go to string first:
public void write(StringTemplate code, String fileName) throws IOException {
Writer w = tool.getOutputFile(grammar, fileName);
long start = System.currentTimeMillis();
String output = code.toString(lineWidth);
//String output = code.toString();
long stop = System.currentTimeMillis();
//System.out.println("render time for "+fileName+": "+(int)(stop-start)+"ms");
w.write(output);
w.close();
}
|
|
Description
|
Mimic ST:
public String toString(int lineWidth) {
StringWriter out = new StringWriter();
// Write the output to a StringWriter
StringTemplateWriter wr = group.getStringTemplateWriter(out);
wr.setLineWidth(lineWidth);
try {
write(wr);
}
catch (IOException io) {
error("Got IOException writing to writer "+wr.getClass().getName());
}
// reset so next toString() does not wrap; normally this is a new writer
// each time, but just in case they override the group to reuse the
// writer.
wr.setLineWidth(StringTemplateWriter.NO_WRAP);
return out.toString();
}
to write directly to output file instead of to string first. as you can see we go to string first:
public void write(StringTemplate code, String fileName) throws IOException {
Writer w = tool.getOutputFile(grammar, fileName);
long start = System.currentTimeMillis();
String output = code.toString(lineWidth);
//String output = code.toString();
long stop = System.currentTimeMillis();
//System.out.println("render time for "+fileName+": "+(int)(stop-start)+"ms");
w.write(output);
w.close();
}
|
Show » |
|