|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.utility; |
|
19 |
| |
|
20 |
| import java.io.IOException; |
|
21 |
| import java.io.OutputStream; |
|
22 |
| import java.io.PrintStream; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| public class TextOutput { |
|
31 |
| |
|
32 |
| |
|
33 |
| private final PrintStream output; |
|
34 |
| |
|
35 |
| |
|
36 |
| private final String name; |
|
37 |
| |
|
38 |
| |
|
39 |
| private StringBuffer spaces = new StringBuffer(); |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
0
| public TextOutput(final String name, final PrintStream output) {
|
|
48 |
0
| this.name = name;
|
|
49 |
0
| this.output = output;
|
|
50 |
| } |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
16
| public TextOutput(final String name, final OutputStream output) {
|
|
59 |
16
| this.name = name;
|
|
60 |
16
| this.output = new PrintStream(output);
|
|
61 |
| } |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
3412
| public void print(final String text) {
|
|
69 |
3412
| output.print(text);
|
|
70 |
| } |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
2268
| public void levelPrint(final String text) {
|
|
78 |
2268
| output.print(spaces);
|
|
79 |
2268
| output.print(text);
|
|
80 |
| } |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
0
| public void print(final Object object) {
|
|
88 |
0
| output.print(object);
|
|
89 |
| } |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
6851
| public final void println(final String line) {
|
|
97 |
6851
| output.println(line);
|
|
98 |
| } |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
4337
| public final void levelPrintln(final String line) {
|
|
106 |
4337
| output.print(spaces);
|
|
107 |
4337
| output.println(line);
|
|
108 |
| } |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
83
| public final void println(final Object object) {
|
|
116 |
83
| output.println(object);
|
|
117 |
| } |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
1980
| public final void println() {
|
|
123 |
1980
| output.println();
|
|
124 |
| } |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| |
|
129 |
14
| public final void flush() {
|
|
130 |
14
| output.flush();
|
|
131 |
| } |
|
132 |
| |
|
133 |
| |
|
134 |
| |
|
135 |
| |
|
136 |
14
| public final void close() {
|
|
137 |
14
| output.close();
|
|
138 |
| } |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
0
| public final void clearLevel() {
|
|
144 |
0
| spaces.setLength(0);
|
|
145 |
| } |
|
146 |
| |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
3358
| public final void popLevel() {
|
|
151 |
3358
| if (spaces.length() > 0) {
|
|
152 |
3358
| spaces.setLength(spaces.length() - 2);
|
|
153 |
| } |
|
154 |
| } |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
3358
| public final void pushLevel() {
|
|
160 |
3358
| spaces.append(" ");
|
|
161 |
| } |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
14
| public final boolean checkError() {
|
|
169 |
14
| return output.checkError();
|
|
170 |
| } |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
| |
|
177 |
11
| public final String getName() {
|
|
178 |
11
| return name;
|
|
179 |
| } |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
0
| public final IOException getError() {
|
|
189 |
0
| if (checkError()) {
|
|
190 |
0
| return new IOException("Writing failed.");
|
|
191 |
| } else { |
|
192 |
0
| return null;
|
|
193 |
| } |
|
194 |
| } |
|
195 |
| |
|
196 |
| } |