KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > ant > SourceHtmlReportStyle


1 /*
2  * @(#)SourceHtmlReportStyle.java
3  *
4  * Copyright (C) 2003-2004 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

26
27 package net.sourceforge.groboutils.codecoverage.v2.ant;
28
29 import java.io.File JavaDoc;
30 import java.io.IOException JavaDoc;
31
32 import org.apache.tools.ant.BuildException;
33 import org.apache.tools.ant.Project;
34 import org.w3c.dom.Document JavaDoc;
35
36
37 /**
38  * Describes a report style, used to generate readable reports from the
39  * XML output. This is a combo report, which means that it only works
40  * with the combined coverage file.
41  *
42  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
43  * @version $Date: 2004/04/15 05:48:25 $
44  * @since November 22, 2003
45  */

46 public class SourceHtmlReportStyle extends SourceXslReportStyle
47 {
48     private File JavaDoc stylesheet = null;
49     private String JavaDoc title = null;
50     private String JavaDoc footerText = null;
51     private String JavaDoc footerLink = null;
52     
53     private boolean hasSetup = false;
54     
55     
56     public SourceHtmlReportStyle()
57     {
58         SourceXslReportStyle.StyleType st;
59         
60         st = new SourceXslReportStyle.StyleType();
61         st.setUrl( "xsl/1x1.png" );
62         st.setDest( "/1x1.png" );
63         addFile( st );
64         
65         st = new SourceXslReportStyle.StyleType();
66         st.setUrl( "xsl/source-frame-html.xsl" );
67         st.setDest( ".html" );
68         addSourceStyle( st );
69         
70         st = new SourceXslReportStyle.StyleType();
71         st.setUrl( "xsl/source-frame-html.xsl" );
72         st.setDest( "/package-frame.html" );
73         addPackageStyle( st );
74         
75         st = new SourceXslReportStyle.StyleType();
76         st.setUrl( "xsl/overview-frame.xsl" );
77         st.setDest( "/package-classes.html" );
78         addPackageStyle( st );
79         
80         st = new SourceXslReportStyle.StyleType();
81         st.setUrl( "xsl/index.xsl" );
82         st.setDest( "/index.html" );
83         addRootStyle( st );
84         
85         st = new SourceXslReportStyle.StyleType();
86         st.setUrl( "xsl/overview-frame.xsl" );
87         st.setDest( "/overview-frame.html" );
88         addRootStyle( st );
89         
90         st = new SourceXslReportStyle.StyleType();
91         st.setUrl( "xsl/allclasses-frame.xsl" );
92         st.setDest( "/allclasses-frame.html" );
93         addRootStyle( st );
94         
95         st = new SourceXslReportStyle.StyleType();
96         st.setUrl( "xsl/source-frame-html.xsl" );
97         st.setDest( "/overview-summary.html" );
98         addRootStyle( st );
99     }
100     
101     
102     /** Well-defined XSL parameters */
103     public void setTitle( String JavaDoc title )
104     {
105         this.title = title;
106     }
107     
108     
109     public void setFooterText( String JavaDoc t )
110     {
111         this.footerText = t;
112     }
113     
114     
115     public void setFooterHref( String JavaDoc t )
116     {
117         this.footerLink = t;
118     }
119     
120     
121     public void setStylesheet( File JavaDoc f )
122     {
123         this.stylesheet = f;
124     }
125     
126     
127     public void generateReport( Project project, Document JavaDoc doc,
128             String JavaDoc moduleName )
129             throws BuildException, IOException JavaDoc
130     {
131         if (!this.hasSetup)
132         {
133             SourceXslReportStyle.StyleType st =
134                 new SourceXslReportStyle.StyleType();
135             st.setDest( "stylesheet.css" );
136             if (this.stylesheet == null)
137             {
138                 st.setUrl( "xsl/stylesheet.css" );
139             }
140             else
141             {
142                 st.setFile( this.stylesheet );
143             }
144             addFile( st );
145             st = null;
146             
147             addMyParam( "title", this.title );
148             addMyParam( "footerText", this.footerText );
149             addMyParam( "footerLink", this.footerLink );
150             
151             this.hasSetup = true;
152         }
153         
154         super.generateReport( project, doc, moduleName );
155     }
156     
157     
158     private void addMyParam( String JavaDoc name, String JavaDoc value )
159     {
160         if (value != null)
161         {
162             SimpleXslReportStyle.ParamType pt =
163                 new SimpleXslReportStyle.ParamType();
164             pt.setName( name );
165             pt.setExpression( value );
166             addParam( pt );
167         }
168     }
169 }
Popular Tags