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.artifact.Artifact; 31 import org.apache.maven.doxia.site.decoration.DecorationModel; 32 import org.apache.maven.doxia.site.skin.SkinModel; 33 import org.codehaus.plexus.util.ReaderFactory; 34 import org.codehaus.plexus.util.WriterFactory; 35 36 /** 37 * Context for a site rendering. 38 * 39 * @author <a href="mailto:brett@apache.org">Brett Porter</a> 40 */ 41 public class SiteRenderingContext 42 { 43 private String inputEncoding = ReaderFactory.FILE_ENCODING; 44 45 private String outputEncoding = WriterFactory.UTF_8; 46 47 private String templateName; 48 49 private ClassLoader templateClassLoader; 50 51 private Map<String, ?> templateProperties; 52 53 private Locale locale = Locale.ROOT; 54 55 private List<Locale> siteLocales = new ArrayList<Locale>(); 56 57 private DecorationModel decoration; 58 59 private String defaultWindowTitle; 60 61 private Artifact skin; 62 63 private SkinModel skinModel; 64 65 private File rootDirectory; 66 67 private List<File> siteDirectories = new ArrayList<File>(); 68 69 private Map<String, String> moduleExcludes; 70 71 private List<ExtraDoxiaModuleReference> modules = new ArrayList<ExtraDoxiaModuleReference>(); 72 73 private boolean validate; 74 75 private Date publishDate; 76 77 private File processedContentOutput; 78 79 /** 80 * If input documents should be validated before parsing. 81 * By default no validation is performed. 82 * 83 * @return true if validation is switched on. 84 * @since 1.1.3 85 */ 86 public boolean isValidate() 87 { 88 return validate; 89 } 90 91 /** 92 * Switch on/off validation. 93 * 94 * @param validate true to switch on validation. 95 * @since 1.1.3 96 */ 97 public void setValidate( boolean validate ) 98 { 99 this.validate = validate; 100 } 101 102 /** 103 * <p>Getter for the field <code>templateName</code>.</p> 104 * 105 * @return a {@link java.lang.String} object. 106 */ 107 public String getTemplateName() 108 { 109 return templateName; 110 } 111 112 /** 113 * <p>Getter for the field <code>templateClassLoader</code>.</p> 114 * 115 * @return a {@link java.lang.ClassLoader} object. 116 */ 117 public ClassLoader getTemplateClassLoader() 118 { 119 return templateClassLoader; 120 } 121 122 /** 123 * <p>Setter for the field <code>templateClassLoader</code>.</p> 124 * 125 * @param templateClassLoader a {@link java.lang.ClassLoader} object. 126 */ 127 public void setTemplateClassLoader( ClassLoader templateClassLoader ) 128 { 129 this.templateClassLoader = templateClassLoader; 130 } 131 132 /** 133 * <p>Getter for the field <code>templateProperties</code>.</p> 134 * 135 * @return a {@link java.util.Map} object. 136 */ 137 public Map<String, ?> getTemplateProperties() 138 { 139 return templateProperties; 140 } 141 142 /** 143 * <p>Setter for the field <code>templateProperties</code>.</p> 144 * 145 * @param templateProperties a {@link java.util.Map} object. 146 */ 147 public void setTemplateProperties( Map<String, ?> templateProperties ) 148 { 149 this.templateProperties = Collections.unmodifiableMap( templateProperties ); 150 } 151 152 /** 153 * <p>Getter for the field <code>locale</code>.</p> 154 * 155 * @return a {@link java.util.Locale} object. 156 */ 157 public Locale getLocale() 158 { 159 return locale; 160 } 161 162 /** 163 * <p>Setter for the field <code>locale</code>.</p> 164 * 165 * @param locale a {@link java.util.Locale} object. 166 */ 167 public void setLocale( Locale locale ) 168 { 169 this.locale = locale; 170 } 171 172 /** 173 * <p>Getter for the field <code>siteLocales</code> - 174 * a list of locales available for this site context.</p> 175 * 176 * @return a {@link java.util.List} object with {@link java.util.Locale} objects. 177 */ 178 public List<Locale> getSiteLocales() 179 { 180 return siteLocales; 181 } 182 183 /** 184 * <p>Adds passed locales to the list of site locales.</p> 185 * 186 * @param locales List of {@link java.util.Locale} objects to add to the site locales list. 187 */ 188 public void addSiteLocales( List<Locale> locales ) 189 { 190 siteLocales.addAll( locales ); 191 } 192 193 /** 194 * <p>Getter for the field <code>decoration</code>.</p> 195 * 196 * @return a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object. 197 */ 198 public DecorationModel getDecoration() 199 { 200 return decoration; 201 } 202 203 /** 204 * <p>Setter for the field <code>decoration</code>.</p> 205 * 206 * @param decoration a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object. 207 */ 208 public void setDecoration( DecorationModel decoration ) 209 { 210 this.decoration = decoration; 211 } 212 213 /** 214 * <p>Setter for the field <code>defaultWindowTitle</code>.</p> 215 * 216 * @param defaultWindowTitle a {@link java.lang.String} object. 217 */ 218 public void setDefaultWindowTitle( String defaultWindowTitle ) 219 { 220 this.defaultWindowTitle = defaultWindowTitle; 221 } 222 223 /** 224 * <p>Getter for the field <code>defaultWindowTitle</code>.</p> 225 * 226 * @return a {@link java.lang.String} object. 227 */ 228 public String getDefaultWindowTitle() 229 { 230 return defaultWindowTitle; 231 } 232 233 /** 234 * <p>Getter for the field <code>skin</code>.</p> 235 * 236 * @return a {@link Artifact} object. 237 */ 238 public Artifact getSkin() 239 { 240 return skin; 241 } 242 243 /** 244 * <p>Setter for the field <code>skinJarFile</code>.</p> 245 * 246 * @param skin an {@link Artifact} object. 247 */ 248 public void setSkin( Artifact skin ) 249 { 250 this.skin = skin; 251 } 252 253 /** 254 * <p>Getter for the field <code>skinModel</code>.</p> 255 * 256 * @return a {@link SkinModel} object. 257 */ 258 public SkinModel getSkinModel() 259 { 260 return skinModel; 261 } 262 263 /** 264 * <p>Setter for the field <code>skinModel</code>.</p> 265 * 266 * @param skinModel a {@link SkinModel} object. 267 */ 268 public void setSkinModel( SkinModel skinModel ) 269 { 270 this.skinModel = skinModel; 271 } 272 273 /** 274 * <p>Setter for the field <code>templateName</code>.</p> 275 * 276 * @param templateName a {@link java.lang.String} object. 277 */ 278 public void setTemplateName( String templateName ) 279 { 280 this.templateName = templateName; 281 } 282 283 /** 284 * Add a site directory, expected to have a Doxia Site layout, ie one directory per Doxia parser module containing 285 * files with parser extension. Typical values are <code>src/site</code> or <code>target/generated-site</code>. 286 * 287 * @param siteDirectory a {@link java.io.File} object. 288 */ 289 public void addSiteDirectory( File siteDirectory ) 290 { 291 this.siteDirectories.add( siteDirectory ); 292 } 293 294 /** 295 * Add a extra-module source directory: used for Maven 1.x <code>${basedir}/xdocs</code> layout, which contains 296 * <code>xdoc</code> and <code>fml</code>. 297 * 298 * @param moduleBasedir The base directory for module's source files. 299 * @param moduleParserId module's Doxia parser id. 300 */ 301 public void addModuleDirectory( File moduleBasedir, String moduleParserId ) 302 { 303 this.modules.add( new ExtraDoxiaModuleReference( moduleParserId, moduleBasedir ) ); 304 } 305 306 /** 307 * <p>Getter for the field <code>siteDirectories</code>.</p> 308 * 309 * @return List of site directories files. 310 */ 311 public List<File> getSiteDirectories() 312 { 313 return siteDirectories; 314 } 315 316 /** 317 * <p>Getter for the field <code>modules</code>.</p> 318 * 319 * @return a {@link java.util.List} object. 320 */ 321 public List<ExtraDoxiaModuleReference> getModules() 322 { 323 return modules; 324 } 325 326 /** 327 * <p>Getter for the field <code>moduleExcludes</code>.</p> 328 * 329 * @return a map defining exclude patterns (comma separated) by parser id. 330 */ 331 public Map<String, String> getModuleExcludes() 332 { 333 return moduleExcludes; 334 } 335 336 /** 337 * <p>Setter for the field <code>moduleExcludes</code>.</p> 338 * 339 * @param moduleExcludes a {@link java.util.Map} object. 340 */ 341 public void setModuleExcludes( Map<String, String> moduleExcludes ) 342 { 343 this.moduleExcludes = moduleExcludes; 344 } 345 346 /** 347 * <p>Getter for the field <code>inputEncoding</code>.</p> 348 * 349 * @return a {@link java.lang.String} object. 350 */ 351 public String getInputEncoding() 352 { 353 return inputEncoding; 354 } 355 356 /** 357 * <p>Setter for the field <code>inputEncoding</code>.</p> 358 * 359 * @param inputEncoding a {@link java.lang.String} object. 360 */ 361 public void setInputEncoding( String inputEncoding ) 362 { 363 this.inputEncoding = inputEncoding; 364 } 365 366 /** 367 * <p>Getter for the field <code>outputEncoding</code>.</p> 368 * 369 * @return a {@link java.lang.String} object. 370 */ 371 public String getOutputEncoding() 372 { 373 return outputEncoding; 374 } 375 376 /** 377 * <p>Setter for the field <code>outputEncoding</code>.</p> 378 * 379 * @param outputEncoding a {@link java.lang.String} object. 380 */ 381 public void setOutputEncoding( String outputEncoding ) 382 { 383 this.outputEncoding = outputEncoding; 384 } 385 386 /** 387 * <p>If you want to specify a specific publish date instead of the current date.</p> 388 * 389 * @return the publish date, can be {@code null} 390 */ 391 public Date getPublishDate() 392 { 393 return publishDate; 394 } 395 396 /** 397 * <p>Specify a specific publish date instead of the current date.</p> 398 * 399 * @param publishDate the publish date 400 */ 401 public void setPublishDate( Date publishDate ) 402 { 403 this.publishDate = publishDate; 404 } 405 406 /** 407 * Directory where to save content after Velocity processing (<code>*.vm</code>), but before parsing it with Doxia. 408 * 409 * @return not null if the documents are to be saved 410 * @since 1.7 411 */ 412 public File getProcessedContentOutput() 413 { 414 return processedContentOutput; 415 } 416 417 /** 418 * Where to (eventually) save content after Velocity processing (<code>*.vm</code>), but before parsing it with 419 * Doxia? 420 * 421 * @param processedContentOutput not null if the documents are to be saved 422 * @since 1.7 423 */ 424 public void setProcessedContentOutput( File processedContentOutput ) 425 { 426 this.processedContentOutput = processedContentOutput; 427 } 428 429 /** 430 * Root directory, to calculate relative path to every site directories. 431 * Corresponds to the <code>pom.xml</code> directory for Maven build. 432 * 433 * @return the root directory 434 * @since 1.8 435 */ 436 public File getRootDirectory() 437 { 438 return rootDirectory; 439 } 440 441 /** 442 * Set the root directory. 443 * 444 * @param rootDirectory the root directory 445 * @since 1.8 446 */ 447 public void setRootDirectory( File rootDirectory ) 448 { 449 this.rootDirectory = rootDirectory; 450 } 451 }