View Javadoc
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.analysis;
20  
21  import org.apache.rat.license.ILicense;
22  import org.apache.rat.license.ILicenseFamily;
23  
24  /**
25   * An ILicense implementation that represents an unknown license.
26   * <p>
27   * The UnknownLicense is used during processing to report that a document
28   * license can not be determined.
29   */
30  public final class UnknownLicense implements ILicense {
31  
32      /**
33       * The single instance of this class.
34       */
35      public static final UnknownLicense INSTANCE = new UnknownLicense();
36  
37      /**
38       * The license family for the unknown license.
39       */
40      private final ILicenseFamily family;
41  
42      /**
43       * Do not allow other constructions.
44       */
45      private UnknownLicense() {
46          family = ILicenseFamily.UNKNOWN;
47      }
48  
49      @Override
50      public String getId() {
51          return family.getFamilyCategory();
52      }
53  
54      @Override
55      public void reset() {
56          // do nothing
57      }
58  
59      @Override
60      public boolean matches(final IHeaders headers) {
61          return false;
62      }
63  
64      @Override
65      public boolean equals(final Object o) {
66          return super.equals(o);
67      }
68  
69      @Override
70      public int hashCode() {
71          return family.hashCode();
72      }
73  
74      @Override
75      public ILicenseFamily getLicenseFamily() {
76          return family;
77      }
78  
79      @Override
80      public String getNote() {
81          return null;
82      }
83  
84      @Override
85      public String getName() {
86          return family.getFamilyName();
87      }
88  
89      @Override
90      public IHeaderMatcher getMatcher() {
91          return null;
92      }
93  }