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