KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > StyleSheetEntry


1 /*
2   * Hammurapi
3  * Automated Java code review system.
4  * Copyright (C) 2004 Hammurapi Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * URL: http://www.hammurapi.org
21  * e-Mail: support@hammurapi.biz
22  */

23 package org.hammurapi;
24
25 import java.io.File JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.apache.tools.ant.Project;
31
32 import com.pavelvlasov.ant.Param;
33 import com.pavelvlasov.config.ConfigurationException;
34 import com.pavelvlasov.config.Parameterizable;
35
36 /**
37  * @author Pavel Vlasov
38  * @version $Revision: 1.2 $
39   * @ant.element parent="output" name="stylesheet" display-name="Stylesheet nested element of output"
40  * @ant.non-required
41  */

42 public class StyleSheetEntry {
43
44     private String JavaDoc name;
45     private File JavaDoc file;
46     private String JavaDoc url;
47     private Map JavaDoc parameters=new HashMap JavaDoc();
48
49     /**
50      * @return
51      */

52     public String JavaDoc getName() {
53         return name;
54     }
55     
56     /**
57      * Stylesheet 'logical' name. Supported names are:
58      * <UL>
59     * <LI>compilation-unit</LI>
60     * <LI>summary</LI>
61     * <LI>left-panel</LI>
62     * <LI>package</LI>
63     * <LI>inspector-set</LI>
64     * <LI>inspector-descriptor</LI>
65     * <LI>inspector-summary</LI>
66     * <LI>metric-details</LI>
67      * </UL>
68      * @return
69      * @ant.required
70      */

71     public void setName(String JavaDoc name) {
72         this.name=name;
73     }
74
75     /**
76      * @return
77      */

78     public File JavaDoc getFile() {
79         return file;
80     }
81
82     /**
83      * @return
84      */

85     public String JavaDoc getUrl() {
86         return url;
87     }
88
89     /**
90      * Stylesheet to use. Mutually exclusive with URL
91      * @param file
92      * @ant.non-required
93      */

94     public void setFile(File JavaDoc file) {
95         this.file=file;
96     }
97
98     /**
99      * URL to download stylesheet from. Mutually exclusive with File.
100      * @param url
101      * @ant.non-required
102      */

103     public void setUrl(String JavaDoc url) {
104         this.url=url;
105     }
106
107     /**
108      * @return
109      */

110     public Map JavaDoc getParameters() {
111         return parameters;
112     }
113
114     /**
115      * @param parameters
116      * @ant.ignore
117      */

118     public void setParameters(Map JavaDoc parameters) {
119         this.parameters.putAll(parameters);
120     }
121     
122     /**
123      * Parameter which will be passed to transformer.
124      * @param param
125      * @ant.non-required
126      */

127     public void addConfiguredParameter(Param param) {
128         parameters.put(param.getName(), param);
129     }
130     
131     void setParameters(Project project, Parameterizable p) throws ConfigurationException {
132         Iterator JavaDoc pit=parameters.values().iterator();
133         while (pit.hasNext()) {
134             Param param=(Param) pit.next();
135             
136             param.setProject(project);
137             param.execute();
138             
139             Object JavaDoc value=param.getObject(null);
140             if (value!=null) {
141                 p.setParameter(param.getName(), value);
142             }
143         }
144     }
145 }
146
Popular Tags