KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > tools > html > PlainPrintBugDescriptions


1 /*
2  * Generate HTML file containing bug descriptions
3  * Copyright (C) 2004, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.tools.html;
21
22 import java.io.IOException JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import java.io.PrintStream JavaDoc;
25
26 import edu.umd.cs.findbugs.BugPattern;
27
28 public class PlainPrintBugDescriptions extends PrintBugDescriptions {
29     private String JavaDoc docTitle;
30     private PrintStream JavaDoc out;
31
32     public PlainPrintBugDescriptions(String JavaDoc docTitle, OutputStream JavaDoc out) {
33         this.docTitle = docTitle;
34         this.out = new PrintStream JavaDoc(out);
35     }
36
37     protected String JavaDoc getDocTitle() { return docTitle; }
38
39     protected PrintStream JavaDoc getPrintStream() { return out; }
40
41     @Override JavaDoc
42     protected void prologue() throws IOException JavaDoc {
43         out.println("<html><head><title>" + docTitle + "</title>");
44         header();
45         out.println("</head><body>");
46         beginBody();
47         out.println("<h1>" + docTitle + "</h1>");
48     }
49
50     @Override JavaDoc
51     protected void emit(BugPattern bugPattern) throws IOException JavaDoc {
52         out.println("<h2>" + bugPattern.getAbbrev() + ": " +
53             bugPattern.getShortDescription() + "</h2>");
54         out.println(bugPattern.getDetailText());
55     }
56
57     @Override JavaDoc
58     protected void epilogue() throws IOException JavaDoc {
59         endBody();
60         out.println("</body></html>");
61     }
62
63     /** Extra stuff that can be printed in the &lt;head&gt; element. */
64     protected void header() throws IOException JavaDoc {
65     }
66
67     /** Extra stuff printed at the beginning of the &lt;body&gt; element. */
68     protected void beginBody() throws IOException JavaDoc {
69     }
70
71     /** Extra stuff printed at the end of the &lt;body&gt; element. */
72     protected void endBody() throws IOException JavaDoc {
73     }
74
75     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
76         String JavaDoc docTitle = "FindBugs Bug Descriptions";
77         if (args.length > 0)
78             docTitle = args[0];
79         new PlainPrintBugDescriptions(docTitle, System.out).print();
80     }
81 }
82
83 // vim:ts=3
84
Popular Tags