creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1548131 - in /creadur/rat/branches/gsoc/apache-rat-core/src: main/java/org/apache/rat/document/impl/guesser/ArchiveGuesser.java test/java/org/apache/rat/document/impl/guesser/ArchiveGuesserTest.java
Date Thu, 05 Dec 2013 13:25:46 GMT
Author: rdonkin
Date: Thu Dec  5 13:25:46 2013
New Revision: 1548131

URL: http://svn.apache.org/r1548131
Log:
Prepare to refactor static methods into object by reducing visibility of methods and removing
duplicate tests.

Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/document/impl/guesser/ArchiveGuesser.java
    creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/ArchiveGuesserTest.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/document/impl/guesser/ArchiveGuesser.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/document/impl/guesser/ArchiveGuesser.java?rev=1548131&r1=1548130&r2=1548131&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/document/impl/guesser/ArchiveGuesser.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/document/impl/guesser/ArchiveGuesser.java
Thu Dec  5 13:25:46 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.document.impl.guesser;
 
 import java.util.Locale;
@@ -23,13 +23,9 @@ import java.util.Locale;
 import org.apache.rat.api.Document;
 
 public class ArchiveGuesser {
-    
-    public static final String[] ARCHIVE_EXTENSIONS = {
-        "jar", "gz",
-        "zip", "tar",
-        "bz", "bz2",
-        "rar", "war",
-    };
+
+    private static final String[] ARCHIVE_EXTENSIONS = { "jar", "gz", "zip",
+            "tar", "bz", "bz2", "rar", "war", };
 
     public static final boolean isArchive(final Document document) {
         return isArchive(document.getName());
@@ -38,11 +34,13 @@ public class ArchiveGuesser {
     /**
      * Is a file by that name an archive?
      */
-    public static final boolean isArchive(final String name) {
-        if (name == null) {return false;}
-        String nameToLower = name.toLowerCase(Locale.US);
-        for (int i = 0; i < ArchiveGuesser.ARCHIVE_EXTENSIONS.length; i++) {
-            if (nameToLower.endsWith("." + ArchiveGuesser.ARCHIVE_EXTENSIONS[i])) {
+    private static final boolean isArchive(final String name) {
+        if (name == null) {
+            return false;
+        }
+        final String nameToLower = name.toLowerCase(Locale.US);
+        for (final String element : ArchiveGuesser.ARCHIVE_EXTENSIONS) {
+            if (nameToLower.endsWith("." + element)) {
                 return true;
             }
         }

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/ArchiveGuesserTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/ArchiveGuesserTest.java?rev=1548131&r1=1548130&r2=1548131&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/ArchiveGuesserTest.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/ArchiveGuesserTest.java
Thu Dec  5 13:25:46 2013
@@ -15,14 +15,14 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.document.impl.guesser;
 
+import static org.junit.Assert.assertTrue;
+
 import org.apache.rat.document.MockDocument;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
-
 public class ArchiveGuesserTest {
 
     @Test
@@ -34,16 +34,4 @@ public class ArchiveGuesserTest {
         assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.bz")));
         assertTrue(ArchiveGuesser.isArchive(new MockDocument("42.bz2")));
     }
-    
-    @Test
-    public void isArchive() {
-        assertTrue(ArchiveGuesser.isArchive("42.jar"));
-        assertTrue(ArchiveGuesser.isArchive("42.tar.gz"));
-        assertTrue(ArchiveGuesser.isArchive("42.zip"));
-        assertTrue(ArchiveGuesser.isArchive("42.tar"));
-        assertTrue(ArchiveGuesser.isArchive("42.bz"));
-        assertTrue(ArchiveGuesser.isArchive("42.bz2"));
-    }
-    
-
 }



Mime
View raw message