1 /*
2 * $Id$
3 */
4
5 package org.apache.maven.model;
6
7 //---------------------------------/
8 //- Imported classes and packages -/
9 //---------------------------------/
10
11 import java.util.Date;
12
13 /**
14 * Section for management of reports and their configuration.
15 *
16 * @version $Revision$ $Date$
17 */
18 public class Reporting implements java.io.Serializable {
19
20
21 //--------------------------/
22 //- Class/Member Variables -/
23 //--------------------------/
24
25 /**
26 * If true, then the default reports are not included in the
27 * site generation.
28 * This includes the reports in the "Project Info"
29 * menu.
30 */
31 private Boolean excludeDefaultsValue;
32
33 /**
34 *
35 *
36 * Where to store all of the generated reports. The
37 * default is
38 * <code>${project.build.directory}/site</code>
39 * .
40 *
41 *
42 */
43 private String outputDirectory;
44
45 /**
46 * Field plugins.
47 */
48 private java.util.List plugins;
49
50
51 //-----------/
52 //- Methods -/
53 //-----------/
54
55 /**
56 * Method addPlugin.
57 *
58 * @param reportPlugin
59 */
60 public void addPlugin( ReportPlugin reportPlugin )
61 {
62 if ( !(reportPlugin instanceof ReportPlugin) )
63 {
64 throw new ClassCastException( "Reporting.addPlugins(reportPlugin) parameter must be instanceof " + ReportPlugin.class.getName() );
65 }
66 getPlugins().add( reportPlugin );
67 } //-- void addPlugin( ReportPlugin )
68
69 /**
70 * Get
71 *
72 * Where to store all of the generated reports. The
73 * default is
74 * <code>${project.build.directory}/site</code>
75 * .
76 *
77 *
78 *
79 * @return String
80 */
81 public String getOutputDirectory()
82 {
83 return this.outputDirectory;
84 } //-- String getOutputDirectory()
85
86 /**
87 * Method getPlugins.
88 *
89 * @return java.util.List
90 */
91 public java.util.List getPlugins()
92 {
93 if ( this.plugins == null )
94 {
95 this.plugins = new java.util.ArrayList();
96 }
97
98 return this.plugins;
99 } //-- java.util.List getPlugins()
100
101 /**
102 * Get if true, then the default reports are not included in
103 * the site generation.
104 * This includes the reports in the "Project Info"
105 * menu.
106 *
107 * @return Boolean
108 */
109 public Boolean isExcludeDefaultsValue()
110 {
111 return this.excludeDefaultsValue;
112 } //-- Boolean isExcludeDefaultsValue()
113
114 /**
115 * Method removePlugin.
116 *
117 * @param reportPlugin
118 */
119 public void removePlugin( ReportPlugin reportPlugin )
120 {
121 if ( !(reportPlugin instanceof ReportPlugin) )
122 {
123 throw new ClassCastException( "Reporting.removePlugins(reportPlugin) parameter must be instanceof " + ReportPlugin.class.getName() );
124 }
125 getPlugins().remove( reportPlugin );
126 } //-- void removePlugin( ReportPlugin )
127
128 /**
129 * Set if true, then the default reports are not included in
130 * the site generation.
131 * This includes the reports in the "Project Info"
132 * menu.
133 *
134 * @param excludeDefaultsValue
135 */
136 public void setExcludeDefaultsValue( Boolean excludeDefaultsValue )
137 {
138 this.excludeDefaultsValue = excludeDefaultsValue;
139 } //-- void setExcludeDefaultsValue( Boolean )
140
141 /**
142 * Set
143 *
144 * Where to store all of the generated reports. The
145 * default is
146 * <code>${project.build.directory}/site</code>
147 * .
148 *
149 *
150 *
151 * @param outputDirectory
152 */
153 public void setOutputDirectory( String outputDirectory )
154 {
155 this.outputDirectory = outputDirectory;
156 } //-- void setOutputDirectory( String )
157
158 /**
159 * Set the reporting plugins to use and their configuration.
160 *
161 * @param plugins
162 */
163 public void setPlugins( java.util.List plugins )
164 {
165 this.plugins = plugins;
166 } //-- void setPlugins( java.util.List )
167
168
169
170 java.util.Map reportPluginMap;
171
172 /**
173 * Reset the <code>reportPluginMap</code> field to <code>null</code>
174 */
175 public void flushReportPluginMap()
176 {
177 this.reportPluginMap = null;
178 }
179
180 /**
181 * @return a Map of plugins field with <code>ReportPlugin#getKey()</code> as key
182 * @see org.apache.maven.model.ReportPlugin#getKey()
183 */
184 public java.util.Map getReportPluginsAsMap()
185 {
186 if ( reportPluginMap == null )
187 {
188 reportPluginMap = new java.util.LinkedHashMap();
189 if ( getPlugins() != null )
190 {
191 for ( java.util.Iterator it = getPlugins().iterator(); it.hasNext(); )
192 {
193 ReportPlugin reportPlugin = (ReportPlugin) it.next();
194 reportPluginMap.put( reportPlugin.getKey(), reportPlugin );
195 }
196 }
197 }
198
199 return reportPluginMap;
200 }
201
202 public boolean isExcludeDefaults()
203 {
204 return excludeDefaultsValue != null ? excludeDefaultsValue.booleanValue() : false;
205 }
206
207 public void setExcludeDefaults( boolean excludeDefaults )
208 {
209 excludeDefaultsValue = excludeDefaults ? Boolean.TRUE : Boolean.FALSE;
210 }
211
212 public void setExcludeDefaultsValue( String excludeDefaults )
213 {
214 excludeDefaultsValue = excludeDefaults != null ? Boolean.valueOf( excludeDefaults ) : null;
215 }
216
217
218 private String modelEncoding = "UTF-8";
219
220 /**
221 * Set an encoding used for reading/writing the model.
222 *
223 * @param modelEncoding the encoding used when reading/writing the model.
224 */
225 public void setModelEncoding( String modelEncoding )
226 {
227 this.modelEncoding = modelEncoding;
228 }
229
230 /**
231 * @return the current encoding used when reading/writing this model.
232 */
233 public String getModelEncoding()
234 {
235 return modelEncoding;
236 }
237 }