01: package org.acm.seguin.pretty.line;
02:
03: import java.io.PrintWriter;
04: import org.acm.seguin.pretty.LineQueue;
05:
06: class NumberedLineQueue extends LineQueue {
07: NumberedLineQueue(PrintWriter output) {
08: super (output);
09: }
10:
11: /** Writes the line to the output stream */
12: protected void writeln(String value) {
13: PrintWriter out = getOutput();
14: // Insert initial spaces
15: if (lineNumber < 10) {
16: out.print(" " + lineNumber + " ");
17: } else if (lineNumber < 100) {
18: out.print(" " + lineNumber + " ");
19: } else if (lineNumber < 1000) {
20: out.print(" " + lineNumber + " ");
21: } else if (lineNumber < 10000) {
22: out.print(" " + lineNumber + " ");
23: } else if (lineNumber < 100000) {
24: out.print(lineNumber + " ");
25: }
26:
27: // Print the line
28: super.writeln(value);
29: }
30: }
|