View Javadoc

    1   /**
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package net.sourceforge.pmd.renderers;
    5
    6   import java.io.IOException;
    7
    8   import net.sourceforge.pmd.PMD;
    9   import net.sourceforge.pmd.lang.dfa.report.ReportHTMLPrintVisitor;
    10  import net.sourceforge.pmd.lang.dfa.report.ReportTree;
    11  import net.sourceforge.pmd.lang.rule.properties.StringProperty;
    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 StringProperty OUTPUT_DIR = new StringProperty("outputDir", "Output directory.", null, 0);
    21
    22      public YAHTMLRenderer() {
    23  	// YA = Yet Another?
    24  	super(NAME, "Yet Another HTML format.");
    25  	definePropertyDescriptor(OUTPUT_DIR);
    26      }
    27
    28      public String defaultFileExtension() { return "html"; }
    29
    30      /**
    31       * {@inheritDoc}
    32       */
    33      @Override
    34      public void end() throws IOException {
    35  	String outputDir = getProperty(OUTPUT_DIR);
    36  	ReportTree tree = report.getViolationTree();
    37  	tree.getRootNode().accept(new ReportHTMLPrintVisitor(outputDir == null ? ".." : outputDir));
    38  	writer.write("<h3 align=\"center\">The HTML files are located "
    39  		+ (outputDir == null ? "above the project directory" : "in '" + outputDir + '\'') + ".</h3>" + PMD.EOL);
    40      }
    41  }