1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.annotation.internal.renderer; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import org.xwiki.annotation.content.AlteredContent; |
25 |
|
import org.xwiki.annotation.content.ContentAlterer; |
26 |
|
import org.xwiki.rendering.listener.HeaderLevel; |
27 |
|
import org.xwiki.rendering.listener.ListType; |
28 |
|
import org.xwiki.rendering.listener.chaining.ListenerChain; |
29 |
|
import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer; |
30 |
|
import org.xwiki.rendering.syntax.Syntax; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 34.9% |
Uncovered Elements: 69 (106) |
Complexity: 48 |
Complexity Density: 0.87 |
|
38 |
|
public class PlainTextNormalizingChainingRenderer extends AbstractChainingPrintRenderer |
39 |
|
{ |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private ContentAlterer textCleaner; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private boolean isInWhitespace = true; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private boolean hasPrinted; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@param |
62 |
|
@param |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
64 |
98 |
public PlainTextNormalizingChainingRenderer(ContentAlterer textCleaner, ListenerChain listenerChain)... |
65 |
|
{ |
66 |
98 |
this.textCleaner = textCleaner; |
67 |
98 |
setListenerChain(listenerChain); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
939 |
@Override... |
71 |
|
public void onWord(String word) |
72 |
|
{ |
73 |
939 |
printText(word); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
216 |
@Override... |
77 |
|
public void onSpecialSymbol(char symbol) |
78 |
|
{ |
79 |
216 |
printText("" + symbol); |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
82 |
0 |
@Override... |
83 |
|
public void onVerbatim(String content, boolean inline, Map<String, String> parameters) |
84 |
|
{ |
85 |
0 |
if (!inline || Character.isWhitespace(content.charAt(0))) { |
86 |
|
|
87 |
|
|
88 |
0 |
printSpace(); |
89 |
|
} |
90 |
|
|
91 |
0 |
AlteredContent cleanedContent = textCleaner.alter(content); |
92 |
0 |
printText(cleanedContent.getContent().toString()); |
93 |
|
|
94 |
0 |
if (!inline || Character.isWhitespace(content.charAt(content.length() - 1))) { |
95 |
|
|
96 |
0 |
printSpace(); |
97 |
|
} |
98 |
|
} |
99 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
100 |
0 |
@Override... |
101 |
|
public void onRawText(String text, Syntax syntax) |
102 |
|
{ |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
0 |
if (Character.isWhitespace(text.charAt(0))) { |
107 |
|
|
108 |
0 |
printSpace(); |
109 |
|
} |
110 |
|
|
111 |
0 |
AlteredContent cleanedContent = textCleaner.alter(text); |
112 |
0 |
printText(cleanedContent.getContent().toString()); |
113 |
|
|
114 |
0 |
if (Character.isWhitespace(text.charAt(text.length() - 1))) { |
115 |
|
|
116 |
0 |
printSpace(); |
117 |
|
} |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
828 |
@Override... |
121 |
|
public void onSpace() |
122 |
|
{ |
123 |
828 |
printSpace(); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
1070 |
protected void printSpace()... |
130 |
|
{ |
131 |
|
|
132 |
1070 |
isInWhitespace = true; |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
@param |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
140 |
1155 |
protected void printText(String text)... |
141 |
|
{ |
142 |
|
|
143 |
|
|
144 |
1155 |
if (isInWhitespace && hasPrinted) { |
145 |
839 |
getPrinter().print(" "); |
146 |
|
} |
147 |
1155 |
getPrinter().print(text); |
148 |
1155 |
hasPrinted = true; |
149 |
1155 |
isInWhitespace = false; |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
152 |
0 |
@Override... |
153 |
|
public void onEmptyLines(int count) |
154 |
|
{ |
155 |
0 |
if (count > 0) { |
156 |
0 |
printSpace(); |
157 |
|
} |
158 |
|
} |
159 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
160 |
4 |
@Override... |
161 |
|
public void onNewLine() |
162 |
|
{ |
163 |
4 |
printSpace(); |
164 |
|
} |
165 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
166 |
0 |
@Override... |
167 |
|
public void onHorizontalLine(Map<String, String> parameters) |
168 |
|
{ |
169 |
0 |
printSpace(); |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
0 |
@Override... |
175 |
|
public void beginDefinitionDescription() |
176 |
|
{ |
177 |
0 |
printSpace(); |
178 |
|
} |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
180 |
0 |
@Override... |
181 |
|
public void endDefinitionDescription() |
182 |
|
{ |
183 |
0 |
printSpace(); |
184 |
|
} |
185 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
186 |
0 |
@Override... |
187 |
|
public void beginDefinitionList(Map<String, String> parameters) |
188 |
|
{ |
189 |
0 |
printSpace(); |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0 |
@Override... |
193 |
|
public void endDefinitionList(Map<String, String> parameters) |
194 |
|
{ |
195 |
0 |
printSpace(); |
196 |
|
} |
197 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
198 |
0 |
@Override... |
199 |
|
public void beginDefinitionTerm() |
200 |
|
{ |
201 |
0 |
printSpace(); |
202 |
|
} |
203 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
204 |
0 |
@Override... |
205 |
|
public void endDefinitionTerm() |
206 |
|
{ |
207 |
0 |
printSpace(); |
208 |
|
} |
209 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
210 |
0 |
@Override... |
211 |
|
public void beginGroup(Map<String, String> parameters) |
212 |
|
{ |
213 |
0 |
printSpace(); |
214 |
|
} |
215 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
216 |
0 |
@Override... |
217 |
|
public void endGroup(Map<String, String> parameters) |
218 |
|
{ |
219 |
0 |
printSpace(); |
220 |
|
} |
221 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
222 |
0 |
@Override... |
223 |
|
public void beginHeader(HeaderLevel level, String id, Map<String, String> parameters) |
224 |
|
{ |
225 |
0 |
printSpace(); |
226 |
|
} |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
@Override... |
229 |
|
public void endHeader(HeaderLevel level, String id, Map<String, String> parameters) |
230 |
|
{ |
231 |
0 |
printSpace(); |
232 |
|
} |
233 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
234 |
0 |
@Override... |
235 |
|
public void beginList(ListType type, Map<String, String> parameters) |
236 |
|
{ |
237 |
0 |
printSpace(); |
238 |
|
} |
239 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
240 |
0 |
@Override... |
241 |
|
public void endList(ListType type, Map<String, String> parameters) |
242 |
|
{ |
243 |
0 |
printSpace(); |
244 |
|
} |
245 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
246 |
0 |
@Override... |
247 |
|
public void beginListItem() |
248 |
|
{ |
249 |
0 |
printSpace(); |
250 |
|
} |
251 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
252 |
0 |
@Override... |
253 |
|
public void endListItem() |
254 |
|
{ |
255 |
0 |
printSpace(); |
256 |
|
} |
257 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
258 |
112 |
@Override... |
259 |
|
public void beginParagraph(Map<String, String> parameters) |
260 |
|
{ |
261 |
112 |
printSpace(); |
262 |
|
} |
263 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
264 |
112 |
@Override... |
265 |
|
public void endParagraph(Map<String, String> parameters) |
266 |
|
{ |
267 |
112 |
printSpace(); |
268 |
|
} |
269 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
270 |
0 |
@Override... |
271 |
|
public void beginQuotation(Map<String, String> parameters) |
272 |
|
{ |
273 |
0 |
printSpace(); |
274 |
|
} |
275 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
276 |
0 |
@Override... |
277 |
|
public void endQuotation(Map<String, String> parameters) |
278 |
|
{ |
279 |
0 |
printSpace(); |
280 |
|
} |
281 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
282 |
0 |
@Override... |
283 |
|
public void beginQuotationLine() |
284 |
|
{ |
285 |
0 |
printSpace(); |
286 |
|
} |
287 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
288 |
0 |
@Override... |
289 |
|
public void endQuotationLine() |
290 |
|
{ |
291 |
0 |
printSpace(); |
292 |
|
} |
293 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
294 |
1 |
@Override... |
295 |
|
public void beginTable(Map<String, String> parameters) |
296 |
|
{ |
297 |
1 |
printSpace(); |
298 |
|
} |
299 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
300 |
1 |
@Override... |
301 |
|
public void endTable(Map<String, String> parameters) |
302 |
|
{ |
303 |
1 |
printSpace(); |
304 |
|
} |
305 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
306 |
2 |
@Override... |
307 |
|
public void beginTableRow(Map<String, String> parameters) |
308 |
|
{ |
309 |
2 |
printSpace(); |
310 |
|
} |
311 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
312 |
2 |
@Override... |
313 |
|
public void endTableRow(Map<String, String> parameters) |
314 |
|
{ |
315 |
2 |
printSpace(); |
316 |
|
} |
317 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
318 |
0 |
@Override... |
319 |
|
public void beginTableHeadCell(Map<String, String> parameters) |
320 |
|
{ |
321 |
0 |
printSpace(); |
322 |
|
} |
323 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
324 |
0 |
@Override... |
325 |
|
public void endTableHeadCell(Map<String, String> parameters) |
326 |
|
{ |
327 |
0 |
printSpace(); |
328 |
|
} |
329 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
330 |
4 |
@Override... |
331 |
|
public void beginTableCell(Map<String, String> parameters) |
332 |
|
{ |
333 |
4 |
printSpace(); |
334 |
|
} |
335 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
336 |
4 |
@Override... |
337 |
|
public void endTableCell(Map<String, String> parameters) |
338 |
|
{ |
339 |
4 |
printSpace(); |
340 |
|
} |
341 |
|
} |