creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1463013 - in /creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles: Archive.java License.java LicenseType.java Licenses.java Main.java
Date Sun, 31 Mar 2013 17:35:25 GMT
Author: rdonkin
Date: Sun Mar 31 17:35:25 2013
New Revision: 1463013

URL: http://svn.apache.org/r1463013
Log:
Move nested type to top level

Added:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/License.java   (with
props)
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Licenses.java   (with
props)
Modified:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Archive.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Archive.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Archive.java?rev=1463013&r1=1463012&r2=1463013&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Archive.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Archive.java Sun Mar
31 17:35:25 2013
@@ -26,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.creadur.tentacles.Main.License;
 
 public class Archive {
 

Added: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/License.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/License.java?rev=1463013&view=auto
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/License.java (added)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/License.java Sun Mar
31 17:35:25 2013
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.tentacles;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class License {
+    private final String text;
+    private final String key;
+    private final Set<Archive> archives = new HashSet<Archive>();
+    final List<File> locations = new ArrayList<File>();
+
+    public License(final String key, final String text) {
+        this.text = text;
+        this.key = key;
+    }
+
+    public String getText() {
+        return this.text;
+    }
+
+    public String getKey() {
+        return this.key;
+    }
+
+    public Set<Archive> getArchives() {
+        return this.archives;
+    }
+
+    public Set<URI> locations(final Archive archive) {
+        final URI contents = archive.contentsURI();
+        final Set<URI> locations = new HashSet<URI>();
+        for (final File file : this.locations) {
+            final URI uri = file.toURI();
+            final URI relativize = contents.relativize(uri);
+            if (!relativize.equals(uri)) {
+                locations.add(relativize);
+            }
+        }
+
+        return locations;
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final License license = (License) o;
+
+        if (!this.key.equals(license.key)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return this.key.hashCode();
+    }
+
+    public boolean implies(final License fullLicense) {
+        return fullLicense.key.contains(this.key);
+    }
+}
\ No newline at end of file

Propchange: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/License.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java?rev=1463013&r1=1463012&r2=1463013&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java Sun
Mar 31 17:35:25 2013
@@ -26,14 +26,14 @@ public enum LicenseType {
 
     ASL_2_0("asl-2.0"), CPL_1_0("cpl-1.0"), CDDL_1_0("cddl-1.0");
 
-    public static Map<String, String> loadLicensesFrom(
+    public static Licenses loadLicensesFrom(
             final TentaclesResources tentaclesResources) throws IOException {
         final Map<String, String> licenses =
                 new ConcurrentHashMap<String, String>();
         for (final LicenseType type : LicenseType.values()) {
             type.putTextInto(licenses, tentaclesResources);
         }
-        return licenses;
+        return new Licenses(licenses);
     }
 
     private final String resourceName;

Added: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Licenses.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Licenses.java?rev=1463013&view=auto
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Licenses.java (added)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Licenses.java Sun Mar
31 17:35:25 2013
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.tentacles;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class Licenses {
+
+    private final Map<String, String> licenses;
+
+    public Licenses(final Map<String, String> licenses) {
+        super();
+        this.licenses = Collections.unmodifiableMap(licenses);
+    }
+
+    public License license(final String text) {
+        final String key = toKey(text);
+        return new License(key, normalize(text));
+    }
+
+    private String toKey(final String text) {
+        return text.replaceAll("[ \\n\\t\\r]+", "").toLowerCase().intern();
+    }
+
+    private String normalize(String text) {
+        for (final Map.Entry<String, String> license : this.licenses.entrySet()) {
+            text =
+                    text.replace(
+                            license.getValue(),
+                            String.format("---[%s - full text]---\n\n",
+                                    license.getKey()));
+        }
+        text = text.intern();
+        return text;
+    }
+}

Propchange: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Licenses.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java?rev=1463013&r1=1463012&r2=1463013&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java Sun Mar 31
17:35:25 2013
@@ -56,7 +56,7 @@ public class Main {
             .getLogger(Main.class);
 
     private final Reports reports;
-    private final Map<String, String> licenses;
+    private final Licenses licenses;
 
     private final Layout layout;
     private final Platform platform;
@@ -154,7 +154,8 @@ public class Main {
             final List<File> files =
                     this.fileSystem.licensesFrom(archive.contentsDirectory());
             for (final File file : files) {
-                final License license = new License(this.ioSystem.slurp(file));
+                final License license =
+                        this.licenses.license(this.ioSystem.slurp(file));
 
                 License existing = licenses.get(license);
                 if (existing == null) {
@@ -205,7 +206,8 @@ public class Main {
 
         for (final File file : files) {
 
-            final License license = new License(this.ioSystem.slurp(file));
+            final License license =
+                    this.licenses.license(this.ioSystem.slurp(file));
 
             undeclared.remove(license);
 
@@ -375,79 +377,6 @@ public class Main {
         }
     }
 
-    public class License {
-        private final String text;
-        private final String key;
-        private final Set<Archive> archives = new HashSet<Archive>();
-        private final List<File> locations = new ArrayList<File>();
-
-        public License(String text) {
-            this.key =
-                    text.replaceAll("[ \\n\\t\\r]+", "").toLowerCase().intern();
-
-            for (final Map.Entry<String, String> license : Main.this.licenses
-                    .entrySet()) {
-                text =
-                        text.replace(license.getValue(), String.format(
-                                "---[%s - full text]---\n\n", license.getKey()));
-            }
-            this.text = text.intern();
-        }
-
-        public String getText() {
-            return this.text;
-        }
-
-        public String getKey() {
-            return this.key;
-        }
-
-        public Set<Archive> getArchives() {
-            return this.archives;
-        }
-
-        public Set<URI> locations(final Archive archive) {
-            final URI contents = archive.contentsURI();
-            final Set<URI> locations = new HashSet<URI>();
-            for (final File file : this.locations) {
-                final URI uri = file.toURI();
-                final URI relativize = contents.relativize(uri);
-                if (!relativize.equals(uri)) {
-                    locations.add(relativize);
-                }
-            }
-
-            return locations;
-        }
-
-        @Override
-        public boolean equals(final Object o) {
-            if (this == o) {
-                return true;
-            }
-            if (o == null || getClass() != o.getClass()) {
-                return false;
-            }
-
-            final License license = (License) o;
-
-            if (!this.key.equals(license.key)) {
-                return false;
-            }
-
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            return this.key.hashCode();
-        }
-
-        public boolean implies(final License fullLicense) {
-            return fullLicense.key.contains(this.key);
-        }
-    }
-
     private File copyToMirror(final File src) throws IOException {
         final URI uri = src.toURI();
 



Mime
View raw message