Coverage Report - org.apache.maven.doxia.siterenderer.SiteRenderingContext
 
Classes in this File Line Coverage Branch Coverage Complexity
SiteRenderingContext
67%
35/52
N/A
1
 
 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.List;
 26  
 import java.util.Locale;
 27  
 import java.util.Map;
 28  
 
 29  
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 30  
 import org.codehaus.plexus.util.ReaderFactory;
 31  
 import org.codehaus.plexus.util.WriterFactory;
 32  
 
 33  
 /**
 34  
  * Context for a site rendering.
 35  
  *
 36  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 37  
  * @version $Id: SiteRenderingContext.java 1087124 2011-03-30 22:45:41Z hboutemy $
 38  
  */
 39  12
 public class SiteRenderingContext
 40  
 {
 41  12
     private String inputEncoding = ReaderFactory.UTF_8;
 42  
 
 43  12
     private String outputEncoding = WriterFactory.UTF_8;
 44  
 
 45  
     private String templateName;
 46  
 
 47  
     private ClassLoader templateClassLoader;
 48  
 
 49  
     private Map<String, ?> templateProperties;
 50  
 
 51  12
     private Locale locale = Locale.getDefault();
 52  
 
 53  12
     private List<Locale> siteLocales = new ArrayList<Locale>();
 54  
 
 55  
     private DecorationModel decoration;
 56  
 
 57  
     private String defaultWindowTitle;
 58  
 
 59  
     private File skinJarFile;
 60  
 
 61  
     private boolean usingDefaultTemplate;
 62  
 
 63  12
     private List<File> siteDirectories = new ArrayList<File>();
 64  
 
 65  
     private Map<String, String> moduleExcludes;
 66  
 
 67  12
     private List<ModuleReference> modules = new ArrayList<ModuleReference>();
 68  
 
 69  
     private boolean validate;
 70  
 
 71  
     /**
 72  
      * If input documents should be validated before parsing.
 73  
      * By default no validation is performed.
 74  
      *
 75  
      * @return true if validation is switched on.
 76  
      * @since 1.1.3
 77  
      */
 78  
     public boolean isValidate()
 79  
     {
 80  66
         return validate;
 81  
     }
 82  
 
 83  
     /**
 84  
      * Switch on/off validation.
 85  
      *
 86  
      * @param validate true to switch on validation.
 87  
      * @since 1.1.3
 88  
      */
 89  
     public void setValidate( boolean validate )
 90  
     {
 91  12
         this.validate = validate;
 92  12
     }
 93  
 
 94  
     /**
 95  
      * <p>Getter for the field <code>templateName</code>.</p>
 96  
      *
 97  
      * @return a {@link java.lang.String} object.
 98  
      */
 99  
     public String getTemplateName()
 100  
     {
 101  204
         return templateName;
 102  
     }
 103  
 
 104  
     /**
 105  
      * <p>Getter for the field <code>templateClassLoader</code>.</p>
 106  
      *
 107  
      * @return a {@link java.lang.ClassLoader} object.
 108  
      */
 109  
     public ClassLoader getTemplateClassLoader()
 110  
     {
 111  408
         return templateClassLoader;
 112  
     }
 113  
 
 114  
     /**
 115  
      * <p>Setter for the field <code>templateClassLoader</code>.</p>
 116  
      *
 117  
      * @param templateClassLoader a {@link java.lang.ClassLoader} object.
 118  
      */
 119  
     public void setTemplateClassLoader( ClassLoader templateClassLoader )
 120  
     {
 121  12
         this.templateClassLoader = templateClassLoader;
 122  12
     }
 123  
 
 124  
     /**
 125  
      * <p>Getter for the field <code>templateProperties</code>.</p>
 126  
      *
 127  
      * @return a {@link java.util.Map} object.
 128  
      */
 129  
     public Map<String, ?> getTemplateProperties()
 130  
     {
 131  204
         return templateProperties;
 132  
     }
 133  
 
 134  
     /**
 135  
      * <p>Setter for the field <code>templateProperties</code>.</p>
 136  
      *
 137  
      * @param templateProperties a {@link java.util.Map} object.
 138  
      */
 139  
     public void setTemplateProperties( Map<String, ?> templateProperties )
 140  
     {
 141  12
         this.templateProperties = Collections.unmodifiableMap( templateProperties );
 142  12
     }
 143  
 
 144  
     /**
 145  
      * <p>Getter for the field <code>locale</code>.</p>
 146  
      *
 147  
      * @return a {@link java.util.Locale} object.
 148  
      */
 149  
     public Locale getLocale()
 150  
     {
 151  204
         return locale;
 152  
     }
 153  
 
 154  
     /**
 155  
      * <p>Setter for the field <code>locale</code>.</p>
 156  
      *
 157  
      * @param locale a {@link java.util.Locale} object.
 158  
      */
 159  
     public void setLocale( Locale locale )
 160  
     {
 161  0
         this.locale = locale;
 162  0
     }
 163  
 
 164  
    /**
 165  
      * <p>Getter for the field <code>siteLocales</code> -
 166  
      * a list of locales available for this site context.</p>
 167  
      *
 168  
      * @return a {@link java.util.List} object with {@link java.util.Locale} objects.
 169  
      */
 170  
     public List<Locale> getSiteLocales()
 171  
     {
 172  204
         return siteLocales;
 173  
     }
 174  
 
 175  
    /**
 176  
     * <p>Adds passed locales to the list of site locales.</p>
 177  
     *
 178  
     * @param locales List of {@link java.util.Locale} objects to add to the site locales list.
 179  
     */
 180  
     public void addSiteLocales( List<Locale> locales )
 181  
     {
 182  0
         siteLocales.addAll( locales );
 183  0
     }
 184  
 
 185  
     /**
 186  
      * <p>Getter for the field <code>decoration</code>.</p>
 187  
      *
 188  
      * @return a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object.
 189  
      */
 190  
     public DecorationModel getDecoration()
 191  
     {
 192  204
         return decoration;
 193  
     }
 194  
 
 195  
     /**
 196  
      * <p>Setter for the field <code>decoration</code>.</p>
 197  
      *
 198  
      * @param decoration a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object.
 199  
      */
 200  
     public void setDecoration( DecorationModel decoration )
 201  
     {
 202  12
         this.decoration = decoration;
 203  12
     }
 204  
 
 205  
     /**
 206  
      * <p>Setter for the field <code>defaultWindowTitle</code>.</p>
 207  
      *
 208  
      * @param defaultWindowTitle a {@link java.lang.String} object.
 209  
      */
 210  
     public void setDefaultWindowTitle( String defaultWindowTitle )
 211  
     {
 212  0
         this.defaultWindowTitle = defaultWindowTitle;
 213  0
     }
 214  
 
 215  
     /**
 216  
      * <p>Getter for the field <code>defaultWindowTitle</code>.</p>
 217  
      *
 218  
      * @return a {@link java.lang.String} object.
 219  
      */
 220  
     public String getDefaultWindowTitle()
 221  
     {
 222  0
         return defaultWindowTitle;
 223  
     }
 224  
 
 225  
     /**
 226  
      * <p>Getter for the field <code>skinJarFile</code>.</p>
 227  
      *
 228  
      * @return a {@link java.io.File} object.
 229  
      */
 230  
     public File getSkinJarFile()
 231  
     {
 232  12
         return skinJarFile;
 233  
     }
 234  
 
 235  
     /**
 236  
      * <p>Setter for the field <code>skinJarFile</code>.</p>
 237  
      *
 238  
      * @param skinJarFile a {@link java.io.File} object.
 239  
      */
 240  
     public void setSkinJarFile( File skinJarFile )
 241  
     {
 242  0
         this.skinJarFile = skinJarFile;
 243  0
     }
 244  
 
 245  
     /**
 246  
      * <p>Setter for the field <code>templateName</code>.</p>
 247  
      *
 248  
      * @param templateName a {@link java.lang.String} object.
 249  
      */
 250  
     public void setTemplateName( String templateName )
 251  
     {
 252  12
         this.templateName = templateName;
 253  12
     }
 254  
 
 255  
     /**
 256  
      * <p>Setter for the field <code>usingDefaultTemplate</code>.</p>
 257  
      *
 258  
      * @param usingDefaultTemplate a boolean.
 259  
      */
 260  
     public void setUsingDefaultTemplate( boolean usingDefaultTemplate )
 261  
     {
 262  12
         this.usingDefaultTemplate = usingDefaultTemplate;
 263  12
     }
 264  
 
 265  
     /**
 266  
      * <p>isUsingDefaultTemplate.</p>
 267  
      *
 268  
      * @return a boolean.
 269  
      */
 270  
     public boolean isUsingDefaultTemplate()
 271  
     {
 272  12
         return usingDefaultTemplate;
 273  
     }
 274  
 
 275  
     /**
 276  
      * <p>addSiteDirectory.</p>
 277  
      *
 278  
      * @param file a {@link java.io.File} object.
 279  
      */
 280  
     public void addSiteDirectory( File file )
 281  
     {
 282  12
         this.siteDirectories.add( file );
 283  12
     }
 284  
 
 285  
     /**
 286  
      * Add a module source directory.
 287  
      *
 288  
      * @param moduleBasedir The base directory for module's source files.
 289  
      * @param moduleParserId a {@link java.lang.String} object.
 290  
      */
 291  
     public void addModuleDirectory( File moduleBasedir, String moduleParserId )
 292  
     {
 293  0
         this.modules.add( new ModuleReference( moduleParserId, moduleBasedir ) );
 294  0
     }
 295  
 
 296  
     /**
 297  
      * <p>Getter for the field <code>siteDirectories</code>.</p>
 298  
      *
 299  
      * @return List of site directories files.
 300  
      */
 301  
     public List<File> getSiteDirectories()
 302  
     {
 303  24
         return siteDirectories;
 304  
     }
 305  
 
 306  
     /**
 307  
      * <p>Getter for the field <code>modules</code>.</p>
 308  
      *
 309  
      * @return a {@link java.util.List} object.
 310  
      */
 311  
     public List<ModuleReference> getModules()
 312  
     {
 313  12
         return modules;
 314  
     }
 315  
 
 316  
     /**
 317  
      * <p>Getter for the field <code>moduleExcludes</code>.</p>
 318  
      *
 319  
      * @return a map defining exclude patterns (comma separated) by parser id.
 320  
      */
 321  
     public Map<String, String> getModuleExcludes()
 322  
     {
 323  12
         return moduleExcludes;
 324  
     }
 325  
 
 326  
     /**
 327  
      * <p>Setter for the field <code>moduleExcludes</code>.</p>
 328  
      *
 329  
      * @param moduleExcludes a {@link java.util.Map} object.
 330  
      */
 331  
     public void setModuleExcludes( Map<String, String> moduleExcludes )
 332  
     {
 333  0
         this.moduleExcludes = moduleExcludes;
 334  0
     }
 335  
 
 336  
     /**
 337  
      * <p>Getter for the field <code>inputEncoding</code>.</p>
 338  
      *
 339  
      * @return a {@link java.lang.String} object.
 340  
      */
 341  
     public String getInputEncoding()
 342  
     {
 343  138
         return inputEncoding;
 344  
     }
 345  
 
 346  
     /**
 347  
      * <p>Setter for the field <code>inputEncoding</code>.</p>
 348  
      *
 349  
      * @param inputEncoding a {@link java.lang.String} object.
 350  
      */
 351  
     public void setInputEncoding( String inputEncoding )
 352  
     {
 353  0
         this.inputEncoding = inputEncoding;
 354  0
     }
 355  
 
 356  
     /**
 357  
      * <p>Getter for the field <code>outputEncoding</code>.</p>
 358  
      *
 359  
      * @return a {@link java.lang.String} object.
 360  
      */
 361  
     public String getOutputEncoding()
 362  
     {
 363  210
         return outputEncoding;
 364  
     }
 365  
 
 366  
     /**
 367  
      * <p>Setter for the field <code>outputEncoding</code>.</p>
 368  
      *
 369  
      * @param outputEncoding a {@link java.lang.String} object.
 370  
      */
 371  
     public void setOutputEncoding( String outputEncoding )
 372  
     {
 373  0
         this.outputEncoding = outputEncoding;
 374  0
     }
 375  
 }