1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.annotation;
20
21 import java.io.File;
22
23 import org.apache.rat.utils.Log;
24
25
26
27
28
29
30
31
32
33 public class ApacheV2LicenseAppender extends AbstractLicenseAppender {
34
35 private String copyright;
36
37
38
39
40 public ApacheV2LicenseAppender(final Log log) {
41 super(log);
42 }
43
44
45
46
47
48
49
50 public ApacheV2LicenseAppender(final Log log, String copyright) {
51 super(log);
52 this.copyright = copyright;
53 }
54
55 @Override
56 public String getLicenseHeader(File document) {
57 int type = getType(document);
58 StringBuilder sb = new StringBuilder();
59 if (copyright == null) {
60 sb.append(getFirstLine(type));
61 sb.append(getLine(type, "Licensed to the Apache Software Foundation (ASF) under one"));
62 sb.append(getLine(type, "or more contributor license agreements. See the NOTICE file"));
63 sb.append(getLine(type, "distributed with this work for additional information"));
64 sb.append(getLine(type, "regarding copyright ownership. The ASF licenses this file"));
65 sb.append(getLine(type, "to you under the Apache License, Version 2.0 (the"));
66 sb.append(getLine(type, "\"License\"); you may not use this file except in compliance"));
67 sb.append(getLine(type, "with the License. You may obtain a copy of the License at"));
68 sb.append(getLine(type, ""));
69 sb.append(getLine(type, " http://www.apache.org/licenses/LICENSE-2.0"));
70 sb.append(getLine(type, ""));
71 sb.append(getLine(type, "Unless required by applicable law or agreed to in writing,"));
72 sb.append(getLine(type, "software distributed under the License is distributed on an"));
73 sb.append(getLine(type, "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY"));
74 sb.append(getLine(type, "KIND, either express or implied. See the License for the"));
75 sb.append(getLine(type, "specific language governing permissions and limitations"));
76 sb.append(getLine(type, "under the License."));
77 sb.append(getLastLine(type));
78 } else {
79 sb.append(getFirstLine(type));
80 sb.append(getLine(type, copyright));
81 sb.append(getLine(type, ""));
82 sb.append(getLine(type, "Licensed under the Apache License, Version 2.0 (the \"License\");"));
83 sb.append(getLine(type, "you may not use this file except in compliance with the License."));
84 sb.append(getLine(type, "You may obtain a copy of the License at"));
85 sb.append(getLine(type, ""));
86 sb.append(getLine(type, " http://www.apache.org/licenses/LICENSE-2.0"));
87 sb.append(getLine(type, ""));
88 sb.append(getLine(type, "Unless required by applicable law or agreed to in writing,"));
89 sb.append(getLine(type, "software distributed under the License is distributed on an"));
90 sb.append(getLine(type, "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY"));
91 sb.append(getLine(type, "KIND, either express or implied. See the License for the"));
92 sb.append(getLine(type, "specific language governing permissions and limitations"));
93 sb.append(getLine(type, "under the License."));
94 sb.append(getLastLine(type));
95 }
96 return sb.toString();
97 }
98
99
100 }