1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.base.io; |
17 |
|
|
18 |
|
import java.io.IOException; |
19 |
|
import java.io.OutputStream; |
20 |
|
import java.io.PrintStream; |
21 |
|
import java.io.UnsupportedEncodingException; |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 11 |
Complexity Density: 0.58 |
|
29 |
|
public class TextOutput extends AbstractOutput { |
30 |
|
|
31 |
|
|
32 |
|
private final PrintStream output; |
33 |
|
|
34 |
|
|
35 |
|
private final String name; |
36 |
|
|
37 |
|
|
38 |
|
private long position; |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@param |
44 |
|
@param |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
46 |
1
|
public TextOutput(final String name, final PrintStream output) {... |
47 |
1
|
super(); |
48 |
1
|
this.name = name; |
49 |
1
|
this.output = output; |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
59 |
6
|
public TextOutput(final String name, final OutputStream output, final String encoding) {... |
60 |
6
|
super(); |
61 |
6
|
this.name = name; |
62 |
6
|
try { |
63 |
6
|
this.output = new PrintStream(output, false, encoding); |
64 |
|
} catch (UnsupportedEncodingException e) { |
65 |
1
|
throw new RuntimeException(e); |
66 |
|
} |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
72 |
96
|
public final void flush() {... |
73 |
96
|
super.flush(); |
74 |
96
|
output.flush(); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
1
|
public final void close() {... |
81 |
1
|
output.close(); |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
@return |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
9
|
public final boolean checkError() {... |
90 |
9
|
return output.checkError(); |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@return |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
3
|
public final String getName() {... |
99 |
3
|
return name; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
@return |
108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
109 |
4
|
public final IOException getError() {... |
110 |
4
|
if (checkError()) { |
111 |
1
|
return new IOException("Writing failed."); |
112 |
|
} else { |
113 |
3
|
return null; |
114 |
|
} |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
117 |
273
|
public void append(final String text) {... |
118 |
273
|
position += text.length(); |
119 |
273
|
output.print(text); |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
3
|
public long getPosition() {... |
123 |
3
|
return position; |
124 |
|
} |
125 |
|
|
126 |
|
} |