View Javadoc

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