View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.properties.report;
17  
18  import java.io.File;
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import de.smartics.util.lang.Arg;
24  import de.smartics.util.lang.NullArgumentException;
25  
26  /**
27   * Provides information to control the creation of the report.
28   */
29  public final class ReportConfiguration
30  {
31    // ********************************* Fields *********************************
32  
33    // --- constants ------------------------------------------------------------
34  
35    // --- members --------------------------------------------------------------
36  
37    /**
38     * The list of source trees to be added for parsing.
39     */
40    private final List<File> sourceTrees = new ArrayList<File>();
41  
42    /**
43     * The class loader to instantiate classes of the project. The class loader is
44     * also required to instantiate classes from dependencies.
45     */
46    private ClassLoader projectClassLoader;
47  
48    /**
49     * The encoding to use to read the source files. Defaults to
50     * <code>UTF-8</code>.
51     */
52    private String encoding = "UTF-8";
53  
54    // ****************************** Initializer *******************************
55  
56    // ****************************** Constructors ******************************
57  
58    /**
59     * Default constructor.
60     */
61    public ReportConfiguration()
62    {
63    }
64  
65    // ****************************** Inner Classes *****************************
66  
67    // ********************************* Methods ********************************
68  
69    // --- init -----------------------------------------------------------------
70  
71    // --- get&set --------------------------------------------------------------
72  
73    /**
74     * Returns the list of source trees to be added for parsing.
75     *
76     * @return the list of source trees to be added for parsing.
77     */
78    public List<File> getSourceTrees()
79    {
80      return Collections.unmodifiableList(sourceTrees);
81    }
82  
83    /**
84     * Returns the class loader to instantiate classes of the project. The class
85     * loader is also required to instantiate classes from dependencies.
86     *
87     * @return the class loader to instantiate classes of the project.
88     */
89    public ClassLoader getProjectClassLoader()
90    {
91      return projectClassLoader;
92    }
93  
94    /**
95     * Sets the class loader to instantiate classes of the project. The class
96     * loader is also required to instantiate classes from dependencies.
97     *
98     * @param projectClassLoader the class loader to instantiate classes of the
99     *          project.
100    */
101   public void setProjectClassLoader(final ClassLoader projectClassLoader)
102   {
103     this.projectClassLoader = projectClassLoader;
104   }
105 
106   /**
107    * Returns the encoding to use to read the source files. Defaults to
108    * <code>UTF-8</code>.
109    *
110    * @return the encoding to use to read the source files.
111    */
112   public String getEncoding()
113   {
114     return encoding;
115   }
116 
117   /**
118    * Sets the encoding to use to read the source files. Defaults to
119    * <code>UTF-8</code>.
120    *
121    * @param encoding the encoding to use to read the source files.
122    */
123   public void setEncoding(final String encoding)
124   {
125     this.encoding = encoding;
126   }
127 
128   // --- business -------------------------------------------------------------
129 
130   /**
131    * Adds the given source tree to the list of source tree.
132    *
133    * @param sourceTree the source tree to add.
134    * @throws NullArgumentException if {@code sourceTree} is <code>null</code>.
135    */
136   public void addSourceTree(final File sourceTree) throws NullArgumentException
137   {
138     Arg.checkNotNull("sourceTree", sourceTree);
139     sourceTrees.add(sourceTree);
140   }
141 
142   // --- object basics --------------------------------------------------------
143 
144 }