View Javadoc
1   package net.logAnalyzer.reports;
2   
3   import net.logAnalyzer.analysis.LAAnalyzer;
4   
5   import org.w3c.dom.Document;
6   
7   /***
8    * This renderer generates an HTML report from analyzers results. Each analysis
9    * is serialized in XML format according to the class of its result. The XLM
10   * result is transform in HTML format with an xslt.
11   * <p>
12   * The report returned by {@link #render()} is an XML document of class
13   * {@link org.w3c.dom.Document} wrapped in a
14   * {@link net.logAnalyzer.reports.XMLReport}.
15   * </p>
16   * 
17   * @author David Vicente
18   * @version 0.1
19   */
20  public class HTMLReportRenderer extends XMLReportRenderer {
21  
22      /***
23       * LAReportRenderer definition.
24       */
25      private RendererDefinition definition = null;
26  
27      /***
28       * Analyzers to include in the report.
29       */
30      private LAAnalyzer[] analyzers = null;
31  
32      /***
33       * Creates a new report for specified analyzers.
34       * 
35       * @param definition
36       *            Renderer definition.
37       * @param analyzers
38       *            Analyzers to include in the report.
39       */
40      public HTMLReportRenderer(RendererDefinition definition,
41              LAAnalyzer[] analyzers) {
42          super(definition, analyzers);
43          this.definition = definition;
44          this.analyzers = analyzers;
45      }
46  
47      /***
48       * Render the report. The report is a {@link HTMLReport} wrapping a XML
49       * {@link Document} representation of all anlyzers results.
50       * 
51       * @return Generated report.
52       * @throws ReportException
53       * @see LAReportRenderer#render()
54       */
55      public LAReport[] render() throws ReportException {
56          Document report = createNewXMLDocument();
57          if (analyzers != null && analyzers.length > 0) {
58              for (int i = 0; i < analyzers.length; i++) {
59                  renderAnalysis(report, analyzers[i].getAnalysis());
60              }
61          }
62          // Puts reports in the Hashtable
63          LAReport[] reports = new LAReport[1];
64          reports[0] = new HTMLReport("FullReport", report);
65          return reports;
66      }
67  
68  }