KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > report > SimpleReport


1 package net.firstpartners.nounit.report;
2
3 /**
4  * Title: NoUnit - Identify Classes that are not being unit Tested
5  *
6  * Copyright (C) 2001 Paul Browne , FirstPartners.net
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @author Paul Browne
24  * @version 0.7
25  */

26
27 import java.io.File JavaDoc;
28 import java.io.FileNotFoundException JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 import javax.xml.transform.TransformerConfigurationException JavaDoc;
32 import javax.xml.transform.TransformerException JavaDoc;
33
34 import org.apache.log4j.Logger;
35
36 import net.firstpartners.nounit.ui.common.CommandPackage;
37 import net.firstpartners.nounit.ui.common.SystemValues;
38 import net.firstpartners.nounit.utility.NoUnitException;
39
40 /*
41  * Runs Any Report , using the standard XML (@see nounit-standard.dtd).
42  * Uses the StyleSheet (XSLT) to present this information to the user
43  * (For an Example @see simplereport.xsl) which shows that structure of
44  * the project.<BR>
45  * This Simple report is ideal if you like XSLT and are happy doing most
46  * of the tranformation work there , and none in Java. <BR>
47  * @see CallsReport if you prefer doing more transformations in Java!
48  */

49 public class SimpleReport
50 extends AbstractReport{
51     
52     /**
53      * Key that the XSLT report is stored under in the WebPackage
54      */

55     public static final String JavaDoc XSLT_REPORT="report_name";
56     
57     /**
58      * Key that the final output name is stored under in the WebPackage
59      */

60     public static final String JavaDoc OUTPUT_FILE="output_file";
61     
62     //handle to logger
63
static Logger log = Logger.getLogger(SimpleReport.class);
64     
65     /**
66      * Transform the XML into a simple report - uses Xalan (XML->HTML convertor)
67      * @param inPackage - CommandPackage with required parameters
68      * @exception TransformerException
69      * @exception TransformerConfigurationException
70      * @exception IOException
71      * @exception FileNotFoundException
72      */

73     public void makeReport(CommandPackage inPackage)
74     throws TransformerException JavaDoc, TransformerConfigurationException JavaDoc,
75            IOException JavaDoc, FileNotFoundException JavaDoc , NoUnitException {
76         
77         //Local Variables
78
File JavaDoc xsltFile = new File JavaDoc(inPackage.getString(XSLT_REPORT) );
79         File JavaDoc outFile =
80             new File JavaDoc( inPackage.getString(CommandPackage.OUTPUT_DIR),
81                       inPackage.getString(OUTPUT_FILE) );
82         File JavaDoc xmlInFile =
83             new File JavaDoc( inPackage.getString(CommandPackage.OUTPUT_DIR),
84                       SystemValues.XML_OUTPUT_NAME );
85         
86         //Check on incoming values
87
if ((outFile==null)||outFile.equals("")){
88             throw new NoUnitException("Please specify a value for "+OUTPUT_FILE);
89         }
90         
91         if ((xsltFile==null)||xsltFile.equals("")){
92             throw new NoUnitException("Please specify a value for "+XSLT_REPORT);
93         }
94         
95         log.debug("Generating Report:");
96         log.debug("XML in:"+xmlInFile);
97         log.debug("XSLT file:"+xsltFile);
98         log.debug("Output file:"+outFile);
99         log.debug("");
100          
101         //Do the transformation
102
super.transformFile( xmlInFile, xsltFile, outFile );
103     }
104 }
105
Popular Tags