View Javadoc

1   package org.apache.maven.doxia.siterenderer;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.Date;
26  import java.util.List;
27  import java.util.Locale;
28  import java.util.Map;
29  
30  import org.apache.maven.doxia.site.decoration.DecorationModel;
31  import org.codehaus.plexus.util.ReaderFactory;
32  import org.codehaus.plexus.util.WriterFactory;
33  
34  /**
35   * Context for a site rendering.
36   *
37   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
38   * @version $Id: SiteRenderingContext.java 1222981 2011-12-24 14:30:00Z rfscholte $
39   */
40  public class SiteRenderingContext
41  {
42      private String inputEncoding = ReaderFactory.UTF_8;
43  
44      private String outputEncoding = WriterFactory.UTF_8;
45  
46      private String templateName;
47  
48      private ClassLoader templateClassLoader;
49  
50      private Map<String, ?> templateProperties;
51  
52      private Locale locale = Locale.getDefault();
53  
54      private List<Locale> siteLocales = new ArrayList<Locale>();
55  
56      private DecorationModel decoration;
57  
58      private String defaultWindowTitle;
59  
60      private File skinJarFile;
61  
62      private boolean usingDefaultTemplate;
63  
64      private List<File> siteDirectories = new ArrayList<File>();
65  
66      private Map<String, String> moduleExcludes;
67  
68      private List<ModuleReference> modules = new ArrayList<ModuleReference>();
69  
70      private boolean validate;
71  
72      private Date publishDate;
73  
74      /**
75       * If input documents should be validated before parsing.
76       * By default no validation is performed.
77       *
78       * @return true if validation is switched on.
79       * @since 1.1.3
80       */
81      public boolean isValidate()
82      {
83          return validate;
84      }
85  
86      /**
87       * Switch on/off validation.
88       *
89       * @param validate true to switch on validation.
90       * @since 1.1.3
91       */
92      public void setValidate( boolean validate )
93      {
94          this.validate = validate;
95      }
96  
97      /**
98       * <p>Getter for the field <code>templateName</code>.</p>
99       *
100      * @return a {@link java.lang.String} object.
101      */
102     public String getTemplateName()
103     {
104         return templateName;
105     }
106 
107     /**
108      * <p>Getter for the field <code>templateClassLoader</code>.</p>
109      *
110      * @return a {@link java.lang.ClassLoader} object.
111      */
112     public ClassLoader getTemplateClassLoader()
113     {
114         return templateClassLoader;
115     }
116 
117     /**
118      * <p>Setter for the field <code>templateClassLoader</code>.</p>
119      *
120      * @param templateClassLoader a {@link java.lang.ClassLoader} object.
121      */
122     public void setTemplateClassLoader( ClassLoader templateClassLoader )
123     {
124         this.templateClassLoader = templateClassLoader;
125     }
126 
127     /**
128      * <p>Getter for the field <code>templateProperties</code>.</p>
129      *
130      * @return a {@link java.util.Map} object.
131      */
132     public Map<String, ?> getTemplateProperties()
133     {
134         return templateProperties;
135     }
136 
137     /**
138      * <p>Setter for the field <code>templateProperties</code>.</p>
139      *
140      * @param templateProperties a {@link java.util.Map} object.
141      */
142     public void setTemplateProperties( Map<String, ?> templateProperties )
143     {
144         this.templateProperties = Collections.unmodifiableMap( templateProperties );
145     }
146 
147     /**
148      * <p>Getter for the field <code>locale</code>.</p>
149      *
150      * @return a {@link java.util.Locale} object.
151      */
152     public Locale getLocale()
153     {
154         return locale;
155     }
156 
157     /**
158      * <p>Setter for the field <code>locale</code>.</p>
159      *
160      * @param locale a {@link java.util.Locale} object.
161      */
162     public void setLocale( Locale locale )
163     {
164         this.locale = locale;
165     }
166 
167    /**
168      * <p>Getter for the field <code>siteLocales</code> -
169      * a list of locales available for this site context.</p>
170      *
171      * @return a {@link java.util.List} object with {@link java.util.Locale} objects.
172      */
173     public List<Locale> getSiteLocales()
174     {
175         return siteLocales;
176     }
177 
178    /**
179     * <p>Adds passed locales to the list of site locales.</p>
180     *
181     * @param locales List of {@link java.util.Locale} objects to add to the site locales list.
182     */
183     public void addSiteLocales( List<Locale> locales )
184     {
185         siteLocales.addAll( locales );
186     }
187 
188     /**
189      * <p>Getter for the field <code>decoration</code>.</p>
190      *
191      * @return a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object.
192      */
193     public DecorationModel getDecoration()
194     {
195         return decoration;
196     }
197 
198     /**
199      * <p>Setter for the field <code>decoration</code>.</p>
200      *
201      * @param decoration a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object.
202      */
203     public void setDecoration( DecorationModel decoration )
204     {
205         this.decoration = decoration;
206     }
207 
208     /**
209      * <p>Setter for the field <code>defaultWindowTitle</code>.</p>
210      *
211      * @param defaultWindowTitle a {@link java.lang.String} object.
212      */
213     public void setDefaultWindowTitle( String defaultWindowTitle )
214     {
215         this.defaultWindowTitle = defaultWindowTitle;
216     }
217 
218     /**
219      * <p>Getter for the field <code>defaultWindowTitle</code>.</p>
220      *
221      * @return a {@link java.lang.String} object.
222      */
223     public String getDefaultWindowTitle()
224     {
225         return defaultWindowTitle;
226     }
227 
228     /**
229      * <p>Getter for the field <code>skinJarFile</code>.</p>
230      *
231      * @return a {@link java.io.File} object.
232      */
233     public File getSkinJarFile()
234     {
235         return skinJarFile;
236     }
237 
238     /**
239      * <p>Setter for the field <code>skinJarFile</code>.</p>
240      *
241      * @param skinJarFile a {@link java.io.File} object.
242      */
243     public void setSkinJarFile( File skinJarFile )
244     {
245         this.skinJarFile = skinJarFile;
246     }
247 
248     /**
249      * <p>Setter for the field <code>templateName</code>.</p>
250      *
251      * @param templateName a {@link java.lang.String} object.
252      */
253     public void setTemplateName( String templateName )
254     {
255         this.templateName = templateName;
256     }
257 
258     /**
259      * <p>Setter for the field <code>usingDefaultTemplate</code>.</p>
260      *
261      * @param usingDefaultTemplate a boolean.
262      */
263     public void setUsingDefaultTemplate( boolean usingDefaultTemplate )
264     {
265         this.usingDefaultTemplate = usingDefaultTemplate;
266     }
267 
268     /**
269      * <p>isUsingDefaultTemplate.</p>
270      *
271      * @return a boolean.
272      */
273     public boolean isUsingDefaultTemplate()
274     {
275         return usingDefaultTemplate;
276     }
277 
278     /**
279      * <p>addSiteDirectory.</p>
280      *
281      * @param file a {@link java.io.File} object.
282      */
283     public void addSiteDirectory( File file )
284     {
285         this.siteDirectories.add( file );
286     }
287 
288     /**
289      * Add a module source directory.
290      *
291      * @param moduleBasedir The base directory for module's source files.
292      * @param moduleParserId a {@link java.lang.String} object.
293      */
294     public void addModuleDirectory( File moduleBasedir, String moduleParserId )
295     {
296         this.modules.add( new ModuleReference( moduleParserId, moduleBasedir ) );
297     }
298 
299     /**
300      * <p>Getter for the field <code>siteDirectories</code>.</p>
301      *
302      * @return List of site directories files.
303      */
304     public List<File> getSiteDirectories()
305     {
306         return siteDirectories;
307     }
308 
309     /**
310      * <p>Getter for the field <code>modules</code>.</p>
311      *
312      * @return a {@link java.util.List} object.
313      */
314     public List<ModuleReference> getModules()
315     {
316         return modules;
317     }
318 
319     /**
320      * <p>Getter for the field <code>moduleExcludes</code>.</p>
321      *
322      * @return a map defining exclude patterns (comma separated) by parser id.
323      */
324     public Map<String, String> getModuleExcludes()
325     {
326         return moduleExcludes;
327     }
328 
329     /**
330      * <p>Setter for the field <code>moduleExcludes</code>.</p>
331      *
332      * @param moduleExcludes a {@link java.util.Map} object.
333      */
334     public void setModuleExcludes( Map<String, String> moduleExcludes )
335     {
336         this.moduleExcludes = moduleExcludes;
337     }
338 
339     /**
340      * <p>Getter for the field <code>inputEncoding</code>.</p>
341      *
342      * @return a {@link java.lang.String} object.
343      */
344     public String getInputEncoding()
345     {
346         return inputEncoding;
347     }
348 
349     /**
350      * <p>Setter for the field <code>inputEncoding</code>.</p>
351      *
352      * @param inputEncoding a {@link java.lang.String} object.
353      */
354     public void setInputEncoding( String inputEncoding )
355     {
356         this.inputEncoding = inputEncoding;
357     }
358 
359     /**
360      * <p>Getter for the field <code>outputEncoding</code>.</p>
361      *
362      * @return a {@link java.lang.String} object.
363      */
364     public String getOutputEncoding()
365     {
366         return outputEncoding;
367     }
368 
369     /**
370      * <p>Setter for the field <code>outputEncoding</code>.</p>
371      *
372      * @param outputEncoding a {@link java.lang.String} object.
373      */
374     public void setOutputEncoding( String outputEncoding )
375     {
376         this.outputEncoding = outputEncoding;
377     }
378 
379     /**
380      * <p>If you want to specify a specific publish date instead of the current date.</p>
381      * 
382      * @return the publish date, can be {@code null}
383      */
384     public Date getPublishDate()
385     {
386         return publishDate;
387     }
388 
389     /**
390      * <p>Specify a specific publish date instead of the current date.</p>
391      * 
392      * @param publishDate the publish date
393      */
394     public void setPublishDate( Date publishDate )
395     {
396         this.publishDate = publishDate;
397     }
398     
399 }