Switch to side-by-side view

--- a/tool/run/licenses/GPL.java
+++ b/tool/run/licenses/GPL.java
@@ -2,6 +2,8 @@
 import java.io.File;
 import java.util.Date;
 import script.License;
+import script.LicenseID;
+import utils.time;
 
 /*
  * SPDXVersion: SPDX-1.1
@@ -34,12 +36,55 @@
  */
 public class GPL implements License {
     
-    // the list of id's that we can use to identify a license
-    String[] list = {
+    // the initial trigger before we dig deeper into the source code
+    String[] initialTrigger = {
         "gnu general public license",
         "gnu gpl",
-        "gplv2 or later"
+        "gpl"
     };
+    
+    // default values for our short identifier and full name
+//    private String shortIdentifier = "GPL";
+//    private String fullName = "GNU General Public License";
+    
+    
+    LicenseID gplv2_only = new LicenseID();
+    LicenseID gplv2_plus = new LicenseID();
+    
+    // set the default ID when asked
+    LicenseID defaultLicense; 
+    
+    
+    LicenseID[] pool = {
+        gplv2_only, 
+        gplv2_plus
+    };
+    
+    /**
+     * Constructor
+     */
+    public GPL(){
+        // how can we identify the different license variants?
+        
+        gplv2_only.shortID = "GPL-2.0";
+        gplv2_only.longID = "GNU General Public License v2.0 only";
+        gplv2_only.URL = "http://spdx.org/licenses/GPL-2.0";
+        gplv2_plus.datePublished = time.getDate(1991, 6, 01);
+        
+        gplv2_plus.shortID = "GPL-2.0+";
+        gplv2_plus.longID = "GNU General Public License v2.0 or later";
+        gplv2_plus.URL = "http://spdx.org/licenses/GPL-2.0+";
+        gplv2_plus.datePublished = time.getDate(1991, 6, 01);
+        gplv2_plus.identifiers = new String[]{
+            "either version 2 of the License",
+            "Version 2, June 1991"
+            };
+        
+        
+         // set the default ID when asked
+        defaultLicense = gplv2_only;
+    }
+    
     
     /**
      * Verifies if the provided text applies to the triggers that
@@ -49,9 +94,10 @@
      */
     @Override
     public Boolean isApplicable(String text){
-        // iterate all our ids
-        for(String id : list){
-            if(text.contains(id)){
+        // iterate all our ids to see if something triggers further interest
+        for(String trigger : initialTrigger){
+            if(text.contains(trigger)){
+                investigateLicense(text);
                 return true;
             }
         }
@@ -60,21 +106,22 @@
 
     @Override
     public Boolean isApplicable(File file) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return null;
     }
 
     @Override
     public String getShortIdentifier() {
-        return "GPL";
+        return defaultLicense.shortID;
     }
 
     @Override
     public String getURL() {
-        return "http://spdx.org/licenses/GPL-1.0+#licenseText";
+        return defaultLicense.URL;
     }
 
     @Override
     public Boolean supportsBinaries() {
+        // are we able to detect a license text inside binary files?
         return false;
     }
 
@@ -86,7 +133,7 @@
    
     @Override
     public Date getDatePublished() {
-        return null; //utils.time.getDate(2004, 02, 01);
+        return defaultLicense.datePublished; //utils.time.getDate(2004, 02, 01);
     }
 
     @Override
@@ -102,7 +149,23 @@
 
     @Override
     public String getFullName() {
-        return "GNU General Public License";
+        return defaultLicense.longID;
+    }
+
+    /**
+     * Looks better into the provided text and tries to determinate which
+     * specific type of license is being applied
+     * @param text 
+     */
+    private void investigateLicense(String text) {
+        for(LicenseID thisId: pool){
+            if(thisId.hasId(text)){
+                defaultLicense = thisId;
+                return;
+            }
+        }
+        
+       
     }
 
 }