1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.owasp.dependencycheck.maven;
20
21 import java.io.IOException;
22 import java.io.OutputStream;
23 import java.io.OutputStreamWriter;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import org.apache.maven.doxia.logging.Log;
27 import org.apache.maven.doxia.sink.Sink;
28 import org.apache.maven.doxia.sink.SinkEventAttributes;
29
30
31
32
33
34 public class MySink implements Sink {
35
36 private OutputStreamWriter out = null;
37
38 public MySink(OutputStream os) {
39 out = new OutputStreamWriter(os);
40
41 }
42
43 private void writeTag(String tag) {
44 try {
45 out.write(tag);
46 } catch (IOException ex) {
47 Logger.getLogger(MySink.class.getName()).log(Level.SEVERE, "Error writing a tag; unable to generate the report");
48 Logger.getLogger(MySink.class.getName()).log(Level.FINE, null, ex);
49 }
50 }
51
52 public void head() {
53 writeTag("<head>");
54 }
55
56 public void head_() {
57 writeTag("</head>");
58 }
59
60 public void title() {
61 writeTag("<title>");
62 }
63
64 public void title_() {
65 writeTag("</title>");
66 }
67
68 public void author() {
69 writeTag("<author>");
70 }
71
72 public void author_() {
73 writeTag("</author>");
74 }
75
76 public void date() {
77 writeTag("<time>");
78 }
79
80 public void date_() {
81 writeTag("</time>");
82 }
83
84 public void body() {
85 writeTag("<body>");
86 }
87
88 public void body_() {
89 writeTag("</body>");
90 }
91
92 public void sectionTitle() {
93 writeTag("<h1>");
94 }
95
96 public void sectionTitle_() {
97 writeTag("</h1>");
98 }
99
100 public void section1() {
101 writeTag("<div>");
102 }
103
104 public void section1_() {
105 writeTag("</div>");
106 }
107
108 public void sectionTitle1() {
109 writeTag("<h2>");
110 }
111
112 public void sectionTitle1_() {
113 writeTag("</h2>");
114 }
115
116 public void section2() {
117 writeTag("<div>");
118 }
119
120 public void section2_() {
121 writeTag("</div>");
122 }
123
124 public void sectionTitle2() {
125 writeTag("<h3>");
126 }
127
128 public void sectionTitle2_() {
129 writeTag("</h3>");
130 }
131
132 public void section3() {
133 writeTag("<div>");
134 }
135
136 public void section3_() {
137 writeTag("</div>");
138 }
139
140 public void sectionTitle3() {
141 writeTag("<h4>");
142 }
143
144 public void sectionTitle3_() {
145 writeTag("</h4>");
146 }
147
148 public void section4() {
149 writeTag("<div>");
150 }
151
152 public void section4_() {
153 writeTag("</div>");
154 }
155
156 public void sectionTitle4() {
157 writeTag("<h5>");
158 }
159
160 public void sectionTitle4_() {
161 writeTag("</h5>");
162 }
163
164 public void section5() {
165 writeTag("<div>");
166 }
167
168 public void section5_() {
169 writeTag("</div>");
170 }
171
172 public void sectionTitle5() {
173 writeTag("<h6>");
174 }
175
176 public void sectionTitle5_() {
177 writeTag("</h6>");
178 }
179
180 public void list() {
181 writeTag("<ul>");
182 }
183
184 public void list_() {
185 writeTag("</ul>");
186 }
187
188 public void listItem() {
189 writeTag("<li>");
190 }
191
192 public void listItem_() {
193 writeTag("</li>");
194 }
195
196 public void numberedList(int numbering) {
197 writeTag("<ol>");
198 }
199
200 public void numberedList_() {
201 writeTag("</ol>");
202 }
203
204 public void numberedListItem() {
205 writeTag("<li>");
206 }
207
208 public void numberedListItem_() {
209 writeTag("</li>");
210 }
211
212 public void definitionList() {
213 writeTag("<dl>");
214 }
215
216 public void definitionList_() {
217 writeTag("</dl>");
218 }
219
220 public void definitionListItem() {
221 writeTag("<dt>");
222 }
223
224 public void definitionListItem_() {
225 writeTag("</dt>");
226 }
227
228 public void definition() {
229 writeTag("<dd>");
230 }
231
232 public void definition_() {
233 writeTag("</dd>");
234 }
235
236 public void definedTerm() {
237 writeTag("<dt>");
238 }
239
240 public void definedTerm_() {
241 writeTag("</dt>");
242 }
243
244 public void figure() {
245 throw new UnsupportedOperationException("Not supported yet.");
246 }
247
248 public void figure_() {
249 throw new UnsupportedOperationException("Not supported yet.");
250 }
251
252 public void figureCaption() {
253 throw new UnsupportedOperationException("Not supported yet.");
254 }
255
256 public void figureCaption_() {
257 throw new UnsupportedOperationException("Not supported yet.");
258 }
259
260 public void figureGraphics(String name) {
261 throw new UnsupportedOperationException("Not supported yet.");
262 }
263
264 public void table() {
265 writeTag("<table>");
266 }
267
268 public void table_() {
269 writeTag("</table>");
270 }
271
272 public void tableRows(int[] justification, boolean grid) {
273 writeTag("<tr>");
274 }
275
276 public void tableRows_() {
277 writeTag("</tr>");
278 }
279
280 public void tableRow() {
281 writeTag("<tr>");
282 }
283
284 public void tableRow_() {
285 writeTag("</tr>");
286 }
287
288 public void tableCell() {
289 writeTag("<td>");
290 }
291
292 public void tableCell(String width) {
293 writeTag("<td>");
294 }
295
296 public void tableCell_() {
297 writeTag("</td>");
298 }
299
300 public void tableHeaderCell() {
301 writeTag("<th>");
302 }
303
304 public void tableHeaderCell(String width) {
305 writeTag("<th>");
306 }
307
308 public void tableHeaderCell_() {
309 writeTag("</th>");
310 }
311
312 public void tableCaption() {
313 writeTag("<caption>");
314 }
315
316 public void tableCaption_() {
317 writeTag("</caption>");
318 }
319
320 public void paragraph() {
321 writeTag("<p>");
322 }
323
324 public void paragraph_() {
325 writeTag("</p>");
326 }
327
328 public void verbatim(boolean boxed) {
329 writeTag("<pre>");
330 }
331
332 public void verbatim_() {
333 writeTag("</pre>");
334 }
335
336 public void horizontalRule() {
337 writeTag("<hr/>");
338 }
339
340 public void pageBreak() {
341 writeTag("<br/>");
342 }
343
344 public void anchor(String name) {
345 writeTag("<a href=\"" + name + "\">");
346 }
347
348 public void anchor_() {
349 writeTag("</a>");
350 }
351
352 public void link(String name) {
353 writeTag("<link href=\"" + name + "\">");
354 }
355
356 public void link_() {
357 writeTag("</link>");
358 }
359
360 public void italic() {
361 writeTag("<i>");
362 }
363
364 public void italic_() {
365 writeTag("</i>");
366 }
367
368 public void bold() {
369 writeTag("<b>");
370 }
371
372 public void bold_() {
373 writeTag("</b>");
374 }
375
376 public void monospaced() {
377 writeTag("<pre>");
378 }
379
380 public void monospaced_() {
381 writeTag("</pre>");
382 }
383
384 public void lineBreak() {
385 writeTag("<br>");
386 }
387
388 public void nonBreakingSpace() {
389 writeTag(" ");
390 }
391
392 public void text(String text) {
393 try {
394
395 out.write(text);
396 } catch (IOException ex) {
397 Logger.getLogger(MySink.class.getName()).log(Level.SEVERE, "Error writing a text; unable to generate the report");
398 Logger.getLogger(MySink.class.getName()).log(Level.FINE, null, ex);
399 }
400 }
401
402 public void rawText(String text) {
403 try {
404 out.write(text);
405 } catch (IOException ex) {
406 Logger.getLogger(MySink.class.getName()).log(Level.SEVERE, "Error writing raw text; unable to generate the report");
407 Logger.getLogger(MySink.class.getName()).log(Level.FINE, null, ex);
408 }
409 }
410
411 public void flush() {
412 try {
413 out.flush();
414 } catch (IOException ex) {
415 Logger.getLogger(MySink.class.getName()).log(Level.FINEST, null, ex);
416 }
417 }
418
419 public void close() {
420 flush();
421 try {
422 out.close();
423 } catch (IOException ex) {
424 Logger.getLogger(MySink.class.getName()).log(Level.FINEST, null, ex);
425 }
426 }
427
428 @Override
429 public void head(SinkEventAttributes sea) {
430 throw new UnsupportedOperationException("Not supported yet.");
431 }
432
433 @Override
434 public void title(SinkEventAttributes sea) {
435 throw new UnsupportedOperationException("Not supported yet.");
436 }
437
438 @Override
439 public void author(SinkEventAttributes sea) {
440 throw new UnsupportedOperationException("Not supported yet.");
441 }
442
443 @Override
444 public void date(SinkEventAttributes sea) {
445 throw new UnsupportedOperationException("Not supported yet.");
446 }
447
448 @Override
449 public void body(SinkEventAttributes sea) {
450 throw new UnsupportedOperationException("Not supported yet.");
451 }
452
453 @Override
454 public void section(int i, SinkEventAttributes sea) {
455 throw new UnsupportedOperationException("Not supported yet.");
456 }
457
458 @Override
459 public void section_(int i) {
460 throw new UnsupportedOperationException("Not supported yet.");
461 }
462
463 @Override
464 public void sectionTitle(int i, SinkEventAttributes sea) {
465 throw new UnsupportedOperationException("Not supported yet.");
466 }
467
468 @Override
469 public void sectionTitle_(int i) {
470 throw new UnsupportedOperationException("Not supported yet.");
471 }
472
473 @Override
474 public void list(SinkEventAttributes sea) {
475 throw new UnsupportedOperationException("Not supported yet.");
476 }
477
478 @Override
479 public void listItem(SinkEventAttributes sea) {
480 throw new UnsupportedOperationException("Not supported yet.");
481 }
482
483 @Override
484 public void numberedList(int i, SinkEventAttributes sea) {
485 throw new UnsupportedOperationException("Not supported yet.");
486 }
487
488 @Override
489 public void numberedListItem(SinkEventAttributes sea) {
490 throw new UnsupportedOperationException("Not supported yet.");
491 }
492
493 @Override
494 public void definitionList(SinkEventAttributes sea) {
495 throw new UnsupportedOperationException("Not supported yet.");
496 }
497
498 @Override
499 public void definitionListItem(SinkEventAttributes sea) {
500 throw new UnsupportedOperationException("Not supported yet.");
501 }
502
503 @Override
504 public void definition(SinkEventAttributes sea) {
505 throw new UnsupportedOperationException("Not supported yet.");
506 }
507
508 @Override
509 public void definedTerm(SinkEventAttributes sea) {
510 throw new UnsupportedOperationException("Not supported yet.");
511 }
512
513 @Override
514 public void figure(SinkEventAttributes sea) {
515 throw new UnsupportedOperationException("Not supported yet.");
516 }
517
518 @Override
519 public void figureCaption(SinkEventAttributes sea) {
520 throw new UnsupportedOperationException("Not supported yet.");
521 }
522
523 @Override
524 public void figureGraphics(String string, SinkEventAttributes sea) {
525 throw new UnsupportedOperationException("Not supported yet.");
526 }
527
528 @Override
529 public void table(SinkEventAttributes sea) {
530 throw new UnsupportedOperationException("Not supported yet.");
531 }
532
533 @Override
534 public void tableRow(SinkEventAttributes sea) {
535 throw new UnsupportedOperationException("Not supported yet.");
536 }
537
538 @Override
539 public void tableCell(SinkEventAttributes sea) {
540 throw new UnsupportedOperationException("Not supported yet.");
541 }
542
543 @Override
544 public void tableHeaderCell(SinkEventAttributes sea) {
545 throw new UnsupportedOperationException("Not supported yet.");
546 }
547
548 @Override
549 public void tableCaption(SinkEventAttributes sea) {
550 throw new UnsupportedOperationException("Not supported yet.");
551 }
552
553 @Override
554 public void paragraph(SinkEventAttributes sea) {
555 throw new UnsupportedOperationException("Not supported yet.");
556 }
557
558 @Override
559 public void verbatim(SinkEventAttributes sea) {
560 throw new UnsupportedOperationException("Not supported yet.");
561 }
562
563 @Override
564 public void horizontalRule(SinkEventAttributes sea) {
565 throw new UnsupportedOperationException("Not supported yet.");
566 }
567
568 @Override
569 public void anchor(String string, SinkEventAttributes sea) {
570 throw new UnsupportedOperationException("Not supported yet.");
571 }
572
573 @Override
574 public void link(String string, SinkEventAttributes sea) {
575 throw new UnsupportedOperationException("Not supported yet.");
576 }
577
578 @Override
579 public void lineBreak(SinkEventAttributes sea) {
580 throw new UnsupportedOperationException("Not supported yet.");
581 }
582
583 @Override
584 public void text(String string, SinkEventAttributes sea) {
585 throw new UnsupportedOperationException("Not supported yet.");
586 }
587
588 @Override
589 public void comment(String string) {
590 throw new UnsupportedOperationException("Not supported yet.");
591 }
592
593 @Override
594 public void unknown(String string, Object[] os, SinkEventAttributes sea) {
595 throw new UnsupportedOperationException("Not supported yet.");
596 }
597
598 @Override
599 public void enableLogging(Log log) {
600 throw new UnsupportedOperationException("Not supported yet.");
601 }
602 }