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  import org.apache.rat.license.ILicenseFamilyBuilder;
24  
25  /**
26   * An ILicense implementation that represents an unknown license.
27   * <p>
28   * The UnknownLicense is used during processing to report that a document license can not be determined.
29   * </p>
30   */
31  public class UnknownLicense implements ILicense {
32      
33      /**
34       * The single instance of this class.
35       */
36      static final UnknownLicense INSTANCE = new UnknownLicense();
37      
38      private final ILicenseFamily family ;
39      
40      /**
41       * Do not allow other constructions.
42       */
43      private UnknownLicense() {
44          family = new ILicenseFamilyBuilder().setLicenseFamilyCategory("?????")
45                  .setLicenseFamilyName("Unknown license").build();
46      }
47      
48      @Override
49      public String getId() {
50          return "?????";
51      }
52  
53      @Override
54      public void reset() {
55          // do nothing
56      }
57  
58      @Override
59      public State matches(String line) {
60          return State.f;
61      }
62  
63      @Override
64      public State finalizeState() {
65          return State.f;
66      }
67  
68      @Override
69      public State currentState() {
70          return State.f;
71      }
72  
73      @Override
74      public int compareTo(ILicense arg0) {
75          return getLicenseFamily().compareTo(arg0.getLicenseFamily());
76      }
77  
78      @Override
79      public ILicenseFamily getLicenseFamily() {
80          return family;
81      }
82  
83      @Override
84      public String getNotes() {
85          return null;
86      }
87  
88      @Override
89      public String getName() {
90          return family.getFamilyName();
91      }
92  
93      @Override
94      public String derivedFrom() {
95          return null;
96      }
97  }