1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 */
19 package org.apache.rat;
20
21 import org.apache.rat.analysis.IHeaderMatcher;
22 import org.apache.rat.license.ILicenseFamily;
23
24 import java.util.List;
25
26
27 /**
28 * A configuration object is used by the frontend to invoke the
29 * {@link Report}. Basically, the sole purpose of the frontends is
30 * to create the configuration and invoke the {@link Report}.
31 */
32 public class ReportConfiguration {
33 private IHeaderMatcher headerMatcher;
34 private ILicenseFamily[] approvedLicenseNames;
35 private boolean addingLicenses;
36 private boolean addingLicensesForced;
37 private String copyrightMessage;
38 private boolean approveDefaultLicenses = true;
39
40 /**
41 * @return whether default licenses shall be approved by default.
42 */
43 public boolean isApproveDefaultLicenses() {
44 return approveDefaultLicenses;
45 }
46
47 public void setApproveDefaultLicenses(boolean approveDefaultLicenses) {
48 this.approveDefaultLicenses = approveDefaultLicenses;
49 }
50
51 /**
52 * Returns the header matcher.
53 *
54 * @return the header matcher.
55 */
56 public IHeaderMatcher getHeaderMatcher() {
57 return headerMatcher;
58 }
59
60 /**
61 * Sets the header matcher.
62 *
63 * @param headerMatcher header matcher.
64 */
65 public void setHeaderMatcher(IHeaderMatcher headerMatcher) {
66 this.headerMatcher = headerMatcher;
67 }
68
69 /**
70 * Returns the set of approved license names.
71 *
72 * @return the set of approved license names.
73 */
74 public ILicenseFamily[] getApprovedLicenseNames() {
75 return approvedLicenseNames;
76 }
77
78 /**
79 * Sets the set of approved license names.
80 *
81 * @param approvedLicenseNames set of approved license names.
82 */
83 public void setApprovedLicenseNames(ILicenseFamily[] approvedLicenseNames) {
84 this.approvedLicenseNames = approvedLicenseNames;
85 }
86
87 /**
88 * Sets the set of approved license names (convenience).
89 *
90 * @param approvedLicenseNames set of approved license names.
91 */
92 public void setApprovedLicenseNames(List<ILicenseFamily> approvedLicenseNames) {
93 if (approvedLicenseNames != null && approvedLicenseNames.size() > 0) {
94 setApprovedLicenseNames(approvedLicenseNames.toArray(new ILicenseFamily[approvedLicenseNames.size()]));
95 }
96 }
97
98 /**
99 * @return If Rat is adding license headers: Returns the optional
100 * copyright message. This value is ignored, if no
101 * license headers are added.
102 * @see #isAddingLicenses()
103 */
104 public String getCopyrightMessage() {
105 return copyrightMessage;
106 }
107
108 /**
109 * If Rat is adding license headers: Sets the optional
110 * copyright message. This value is ignored, if no
111 * license headers are added.
112 *
113 * @param copyrightMessage message to set.
114 * @see #setAddingLicenses(boolean)
115 */
116 public void setCopyrightMessage(String copyrightMessage) {
117 this.copyrightMessage = copyrightMessage;
118 }
119
120 /**
121 * @return If Rat is adding license headers: Returns, whether adding
122 * license headers is enforced. This value is ignored, if no
123 * license headers are added.
124 * @see #isAddingLicenses()
125 */
126 public boolean isAddingLicensesForced() {
127 return addingLicensesForced;
128 }
129
130 /**
131 * If Rat is adding license headers: Sets, whether adding
132 * license headers is enforced. This value is ignored, if no
133 * license headers are added.
134 *
135 * @param addingLicensesForced enable/disable forcibly adding licenses.
136 * @see #isAddingLicenses()
137 */
138 public void setAddingLicensesForced(boolean addingLicensesForced) {
139 this.addingLicensesForced = addingLicensesForced;
140 }
141
142 /**
143 * @return Returns, whether Rat should add missing license headers.
144 * @see #isAddingLicensesForced()
145 * @see #getCopyrightMessage()
146 */
147 public boolean isAddingLicenses() {
148 return addingLicenses;
149 }
150
151 /**
152 * Returns, whether Rat should add missing license headers.
153 *
154 * @param addingLicenses enables/disables adding of licenses.
155 * @see #setAddingLicensesForced(boolean)
156 * @see #setCopyrightMessage(String)
157 */
158 public void setAddingLicenses(boolean addingLicenses) {
159 this.addingLicenses = addingLicenses;
160 }
161
162 }