01: package net.firstpartners.nounit.report;
02:
03: /**
04: * Title: NoUnit - Identify Classes that are not being unit Tested
05: *
06: * Copyright (C) 2001 Paul Browne , FirstPartners.net
07: *
08: *
09: * 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 net.firstpartners.nounit.ui.common.CommandPackage;
28: import net.firstpartners.nounit.utility.NoUnitException;
29:
30: /**
31: * Creates the Report Class , as requested by the user , to generate the report
32: */
33: public class ReportPicker {
34:
35: /**
36: * Return the Appropriate Report to handle this user request
37: * @param inCommandPackage containing the request details
38: * @return IReport Object , Class to generate class
39: * @exception NoUnitException thrown if any page names are invalid
40: * @exception IllegalAccessException Thrown when there's a problem retrieving
41: * the concrete reports's class
42: * @exception InstantiationException Thrown when there's a problem creating an
43: * instance of the report bean from it's class.
44: */
45: public static IReport getReportMaker(CommandPackage inCommandPackage)
46: throws NoUnitException {
47:
48: //Internal Objects
49: IReport outReport = null;
50: Object tmpObject = new Object();
51:
52: //Get the report as requested by the user
53: String reportName = inCommandPackage
54: .getString(CommandPackage.REPORT_CLASS);
55:
56: //Quick Check ...
57: if ((reportName == null) || (reportName.equals(""))) {
58: throw new NoUnitException("Please Specify a report name");
59: }
60:
61: //Check for appropriate report to handle request
62:
63: try {
64:
65: Class outReportClass = Class.forName(reportName);
66: if (outReportClass != null) {
67: outReport = (IReport) outReportClass.newInstance();
68: }
69:
70: } catch (ClassNotFoundException cnfe) {
71: throw new NoUnitException("Could not find Report:"
72: + reportName);
73: } catch (InstantiationException ie) {
74: throw new NoUnitException("Could not create Report:"
75: + reportName);
76: } catch (IllegalAccessException iae) {
77: throw new NoUnitException("Error in creating Report:"
78: + reportName);
79: }
80:
81: return outReport;
82: }
83:
84: }
|