01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.renderers;
05
06 import java.io.IOException;
07 import java.util.Properties;
08
09 import net.sourceforge.pmd.PMD;
10 import net.sourceforge.pmd.lang.dfa.report.ReportHTMLPrintVisitor;
11 import net.sourceforge.pmd.lang.dfa.report.ReportTree;
12
13 /**
14 * Renderer to another HTML format.
15 */
16 public class YAHTMLRenderer extends AbstractAccumulatingRenderer {
17
18 public static final String NAME = "yahtml";
19
20 public static final String OUTPUT_DIR = "outputDir";
21
22 private String outputDir;
23
24 public YAHTMLRenderer(Properties properties) {
25 // YA = Yet Another?
26 super(NAME, "Yet Another HTML format.", properties);
27 defineProperty(OUTPUT_DIR, "Output directory.");
28
29 this.outputDir = properties.getProperty(OUTPUT_DIR);
30 }
31
32 /**
33 * {@inheritDoc}
34 */
35 @Override
36 public void end() throws IOException {
37 ReportTree tree = report.getViolationTree();
38 tree.getRootNode().accept(new ReportHTMLPrintVisitor(outputDir == null ? ".." : outputDir));
39 writer.write("<h3 align=\"center\">The HTML files are located "
40 + (outputDir == null ? "above the project directory" : "in '" + outputDir + '\'') + ".</h3>" + PMD.EOL);
41 }
42 }
|