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