commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r911369 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ArchiveStreamFactory.java archivers/tar/TarArchiveEntry.java archivers/zip/ZipEncodingHelper.java compressors/CompressorStreamFactory.java
Date Thu, 18 Feb 2010 12:34:02 GMT
Author: bodewig
Date: Thu Feb 18 12:34:02 2010
New Revision: 911369

URL: http://svn.apache.org/viewvc?rev=911369&view=rev
Log:
equalsIgnoreCase does not depend on the current Locale.  My bad.  Revert unnecessary part
of earlier changes.

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=911369&r1=911368&r2=911369&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Thu Feb 18 12:34:02 2010
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Locale;
 
 import org.apache.commons.compress.archivers.ar.ArArchiveInputStream;
 import org.apache.commons.compress.archivers.ar.ArArchiveOutputStream;
@@ -72,13 +71,11 @@
  */
 public class ArchiveStreamFactory {
 
-    // constants used for case- and locale-insensitive comparisons.
-
-    private static final String AR_LC = "ar";
-    private static final String CPIO_LC = "cpio";
-    private static final String JAR_LC = "jar";
-    private static final String TAR_LC = "tar";
-    private static final String ZIP_LC = "zip";
+    private static final String AR = "ar";
+    private static final String CPIO = "cpio";
+    private static final String JAR = "jar";
+    private static final String TAR = "tar";
+    private static final String ZIP = "zip";
 
     /**
      * Create an archive input stream from an archiver name and an input stream.
@@ -101,21 +98,19 @@
         	throw new IllegalArgumentException("InputStream must not be null.");
         }
 
-        String archiverNameToCompare = archiverName.toLowerCase(Locale.ENGLISH);
-
-        if (AR_LC.equals(archiverNameToCompare)) {
+        if (AR.equalsIgnoreCase(archiverName)) {
             return new ArArchiveInputStream(in);
         }
-        if (ZIP_LC.equals(archiverNameToCompare)) {
+        if (ZIP.equalsIgnoreCase(archiverName)) {
             return new ZipArchiveInputStream(in);
         }
-        if (TAR_LC.equals(archiverNameToCompare)) {
+        if (TAR.equalsIgnoreCase(archiverName)) {
             return new TarArchiveInputStream(in);
         }
-        if (JAR_LC.equals(archiverNameToCompare)) {
+        if (JAR.equalsIgnoreCase(archiverName)) {
             return new JarArchiveInputStream(in);
         }
-        if (CPIO_LC.equals(archiverNameToCompare)) {
+        if (CPIO.equalsIgnoreCase(archiverName)) {
             return new CpioArchiveInputStream(in);
         }
         
@@ -141,21 +136,19 @@
         	throw new IllegalArgumentException("OutputStream must not be null.");
         }
 
-        String archiverNameToCompare = archiverName.toLowerCase(Locale.ENGLISH);
-
-        if (AR_LC.equals(archiverNameToCompare)) {
+        if (AR.equalsIgnoreCase(archiverName)) {
             return new ArArchiveOutputStream(out);
         }
-        if (ZIP_LC.equals(archiverNameToCompare)) {
+        if (ZIP.equalsIgnoreCase(archiverName)) {
             return new ZipArchiveOutputStream(out);
         }
-        if (TAR_LC.equals(archiverNameToCompare)) {
+        if (TAR.equalsIgnoreCase(archiverName)) {
             return new TarArchiveOutputStream(out);
         }
-        if (JAR_LC.equals(archiverNameToCompare)) {
+        if (JAR.equalsIgnoreCase(archiverName)) {
             return new JarArchiveOutputStream(out);
         }
-        if (CPIO_LC.equals(archiverNameToCompare)) {
+        if (CPIO.equalsIgnoreCase(archiverName)) {
             return new CpioArchiveOutputStream(out);
         }
         throw new ArchiveException("Archiver: " + archiverName + " not found.");

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=911369&r1=911368&r2=911369&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Thu Feb 18 12:34:02 2010
@@ -660,7 +660,7 @@
      */
     private static String normalizeFileName(String fileName,
                                             boolean preserveLeadingSlashes) {
-        String osname = System.getProperty("os.name").toLowerCase(Locale.US);
+        String osname = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
 
         if (osname != null) {
 

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java?rev=911369&r1=911368&r2=911369&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
Thu Feb 18 12:34:02 2010
@@ -22,7 +22,6 @@
 import java.nio.charset.Charset;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.HashMap;
-import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -192,14 +191,9 @@
     static final String UTF8 = "UTF8";
 
     /**
-     * name of the encoding UTF-8 used for comparisions.
-     */
-    private static final String UTF8_LC = UTF8.toLowerCase(Locale.ENGLISH);
-
-    /**
      * variant name of the encoding UTF-8 used for comparisions.
      */
-    private static final String UTF_DASH_8_LC = "utf-8";
+    private static final String UTF_DASH_8 = "utf-8";
 
     /**
      * name of the encoding UTF-8
@@ -250,7 +244,7 @@
             // check platform's default encoding
             encoding = System.getProperty("file.encoding");
         }
-        String enc = encoding.toLowerCase(Locale.ENGLISH);
-        return UTF8_LC.equals(enc) || UTF_DASH_8_LC.equals(enc);
+        return UTF8.equalsIgnoreCase(encoding)
+            || UTF_DASH_8.equalsIgnoreCase(encoding);
     }
 }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java?rev=911369&r1=911368&r2=911369&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
Thu Feb 18 12:34:02 2010
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Locale;
 
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
@@ -56,9 +55,8 @@
  */
 public class CompressorStreamFactory {
 
-    // constants used for case- and locale-insensitive comparisons.
-    private static final String BZ_LC = "bzip2";
-    private static final String GZ_LC = "gz";
+    private static final String BZ = "bzip2";
+    private static final String GZ = "gz";
 
     /**
      * Create an compressor input stream from an input stream, autodetecting
@@ -117,15 +115,13 @@
                     "Compressor name and stream must not be null.");
         }
 
-        String nameToCompare = name.toLowerCase(Locale.ENGLISH);
-
         try {
             
-            if (GZ_LC.equals(nameToCompare)) {
+            if (GZ.equalsIgnoreCase(name)) {
                 return new GzipCompressorInputStream(in);
             }
             
-            if (BZ_LC.equals(nameToCompare)) {
+            if (BZ.equalsIgnoreCase(name)) {
                 return new BZip2CompressorInputStream(in);
             }
             
@@ -153,15 +149,13 @@
                     "Compressor name and stream must not be null.");
         }
 
-        String nameToCompare = name.toLowerCase(Locale.ENGLISH);
-
         try {
 
-            if (GZ_LC.equals(nameToCompare)) {
+            if (GZ.equalsIgnoreCase(name)) {
                 return new GzipCompressorOutputStream(out);
             }
             
-            if (BZ_LC.equals(nameToCompare)) {
+            if (BZ.equalsIgnoreCase(name)) {
                 return new BZip2CompressorOutputStream(out);
             }
         



Mime
View raw message