You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/10/19 17:20:50 UTC

[commons-compress] branch master updated (e79aa983 -> 8b437408)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


    from e79aa983 Camel-case internal names
     new 6c20f8b1 Add FileNameUtil.getCompressedFileName(String) and deprecate getCompressedFilename(String)
     new f59a6821 Add BZip2Util.getCompressedFileName(String) and deprecate getCompressedFilename(String)
     new b1caa7ce Add LZMAUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String)
     new d29c0856 Add XYUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String)
     new f2cec930 LZMA is an acronym
     new c4085d77 Uppercase XZ in documentation
     new 6d4e0afa Javadoc
     new 90417eec Add GzipUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String)
     new 8b437408 Remove duplicate entry

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README.md                                          |  2 +-
 RELEASE-NOTES.txt                                  |  6 +-
 pom.xml                                            |  2 +-
 src/changes/changes.xml                            | 20 ++++++-
 src/changes/release-notes.vm                       |  2 +-
 .../archivers/sevenz/SevenZFileOptions.java        |  8 +--
 .../compressors/CompressorStreamFactory.java       |  6 +-
 .../compressors/CompressorStreamProvider.java      |  2 +-
 .../commons/compress/compressors/FileNameUtil.java | 52 +++++++++++++++++
 .../compress/compressors/bzip2/BZip2Utils.java     | 57 ++++++++++++++++++-
 .../compress/compressors/gzip/GzipParameters.java  |  2 +-
 .../compress/compressors/gzip/GzipUtils.java       | 58 ++++++++++++++++++-
 .../lzma/LZMACompressorInputStream.java            |  4 +-
 .../compress/compressors/lzma/LZMAUtils.java       | 65 ++++++++++++++++++----
 .../commons/compress/compressors/xz/XZUtils.java   | 61 ++++++++++++++++++--
 src/site/xdoc/examples.xml                         | 10 ++--
 src/site/xdoc/index.xml                            |  6 +-
 .../compress/compressors/BZip2UtilsTestCase.java   | 35 ++++++++++++
 .../compress/compressors/GzipUtilsTestCase.java    | 57 +++++++++++++++++++
 .../compressors/lzma/LZMAUtilsTestCase.java        | 25 +++++++++
 .../compress/compressors/xz/XZUtilsTestCase.java   | 27 +++++++++
 21 files changed, 459 insertions(+), 48 deletions(-)


[commons-compress] 03/09: Add LZMAUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String)

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit b1caa7cef3733b24a4d682b8d8f1d7094200bb30
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 12:41:55 2023 -0400

    Add LZMAUtils.getCompressedFileName(String) and deprecate
    getCompressedFilename(String)
    
    - Add LZMAUtils.getUncompressedFileName(String) and deprecate
    getUncompressedFilename(String)
    - Add LZMAUtils.isCompressedFileName(String) and deprecate
    isCompressedFilename(String)
---
 src/changes/changes.xml                            |  3 ++
 .../compress/compressors/lzma/LZMAUtils.java       | 59 +++++++++++++++++++---
 .../commons/compress/compressors/xz/XZUtils.java   | 18 +++++++
 .../compressors/lzma/LZMAUtilsTestCase.java        | 25 +++++++++
 4 files changed, 98 insertions(+), 7 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ff10b3ed..9b362e22 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add BZip2Utils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add BZip2Utils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add BZip2Utils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add LZMAUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add LZMAUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add LZMAUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
       <!-- FIX -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
diff --git a/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java b/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java
index 7e5ebd41..c10d8a68 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java
@@ -25,7 +25,8 @@ import org.apache.commons.compress.compressors.FileNameUtil;
 import org.apache.commons.compress.utils.OsgiUtils;
 
 /**
- * Utility code for the lzma compression format.
+ * Utility code for the LZMA compression format.
+ *
  * @ThreadSafe
  * @since 1.10
  */
@@ -62,29 +63,60 @@ public class LZMAUtils {
 
     /**
      * Maps the given file name to the name that the file should have after
-     * compression with lzma.
+     * compression with LZMA.
      *
      * @param fileName name of a file
      * @return name of the corresponding compressed file
+     * @deprecated Use {@link #getCompressedFileName(String)}.
      */
+    @Deprecated
     public static String getCompressedFilename(final String fileName) {
         return fileNameUtil.getCompressedFileName(fileName);
     }
 
     /**
-     * Maps the given name of a lzma-compressed file to the name that
+     * Maps the given file name to the name that the file should have after
+     * compression with LZMA.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding compressed file
+     * @since 1.25.0
+     */
+    public static String getCompressedFileName(final String fileName) {
+        return fileNameUtil.getCompressedFileName(fileName);
+    }
+
+    /**
+     * Maps the given name of a LZMA-compressed file to the name that
      * the file should have after uncompression.  Any file names with
-     * the generic ".lzma" suffix (or any other generic lzma suffix)
-     * is mapped to a name without that suffix. If no lzma suffix is
+     * the generic ".lzma" suffix (or any other generic LZMA suffix)
+     * is mapped to a name without that suffix. If no LZMA suffix is
      * detected, then the file name is returned unmapped.
      *
      * @param fileName name of a file
      * @return name of the corresponding uncompressed file
+     * @deprecated Use {@link #getUncompressedFileName(String)}.
      */
+    @Deprecated
     public static String getUncompressedFilename(final String fileName) {
         return fileNameUtil.getUncompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given name of a LZMA-compressed file to the name that
+     * the file should have after uncompression.  Any file names with
+     * the generic ".lzma" suffix (or any other generic LZMA suffix)
+     * is mapped to a name without that suffix. If no LZMA suffix is
+     * detected, then the file name is returned unmapped.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding uncompressed file
+     * @since 1.25.0
+     */
+    public static String getUncompressedFileName(final String fileName) {
+        return fileNameUtil.getUncompressedFileName(fileName);
+    }
+
     private static boolean internalIsLZMACompressionAvailable() {
         try {
             LZMACompressorInputStream.matches(null, 0);
@@ -95,16 +127,29 @@ public class LZMAUtils {
     }
 
     /**
-     * Detects common lzma suffixes in the given file name.
+     * Detects common LZMA suffixes in the given file name.
      *
      * @param fileName name of a file
-     * @return {@code true} if the file name has a common lzma suffix,
+     * @return {@code true} if the file name has a common LZMA suffix,
      *         {@code false} otherwise
+     * @deprecated Use {@link #isCompressedFileName(String)}.
      */
     public static boolean isCompressedFilename(final String fileName) {
         return fileNameUtil.isCompressedFileName(fileName);
     }
 
+    /**
+     * Detects common LZMA suffixes in the given file name.
+     *
+     * @param fileName name of a file
+     * @return {@code true} if the file name has a common LZMA suffix,
+     *         {@code false} otherwise
+     * @since 1.25.0
+     */
+    public static boolean isCompressedFileName(final String fileName) {
+        return fileNameUtil.isCompressedFileName(fileName);
+    }
+
     /**
      * Are the classes required to support LZMA compression available?
      * @return true if the classes required to support LZMA
diff --git a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
index 54bf52f9..2dc89c32 100644
--- a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
@@ -74,11 +74,29 @@ public class XZUtils {
      *
      * @param fileName name of a file
      * @return name of the corresponding compressed file
+     * @deprecated Use {@link #getCompressedFileName(String)}.
      */
+    @Deprecated
     public static String getCompressedFilename(final String fileName) {
         return fileNameUtil.getCompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given file name to the name that the file should have after
+     * compression with xz. Common file types with custom suffixes for
+     * compressed versions are automatically detected and correctly mapped.
+     * For example the name "package.tar" is mapped to "package.txz". If no
+     * custom mapping is applicable, then the default ".xz" suffix is appended
+     * to the file name.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding compressed file
+     * @since 1.25.0
+     */
+    public static String getCompressedFileName(final String fileName) {
+        return fileNameUtil.getCompressedFileName(fileName);
+    }
+
     /**
      * Maps the given name of a xz-compressed file to the name that the
      * file should have after uncompression. Commonly used file type specific
diff --git a/src/test/java/org/apache/commons/compress/compressors/lzma/LZMAUtilsTestCase.java b/src/test/java/org/apache/commons/compress/compressors/lzma/LZMAUtilsTestCase.java
index 48babdf8..d6b02e20 100644
--- a/src/test/java/org/apache/commons/compress/compressors/lzma/LZMAUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/lzma/LZMAUtilsTestCase.java
@@ -43,44 +43,69 @@ public class LZMAUtilsTestCase {
         }
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetCompressedFilename() {
         assertEquals(".lzma", LZMAUtils.getCompressedFilename(""));
+        assertEquals(".lzma", LZMAUtils.getCompressedFileName(""));
         assertEquals("x.lzma", LZMAUtils.getCompressedFilename("x"));
+        assertEquals("x.lzma", LZMAUtils.getCompressedFileName("x"));
 
         assertEquals("x.wmf .lzma", LZMAUtils.getCompressedFilename("x.wmf "));
+        assertEquals("x.wmf .lzma", LZMAUtils.getCompressedFileName("x.wmf "));
         assertEquals("x.wmf\n.lzma", LZMAUtils.getCompressedFilename("x.wmf\n"));
+        assertEquals("x.wmf\n.lzma", LZMAUtils.getCompressedFileName("x.wmf\n"));
         assertEquals("x.wmf.y.lzma", LZMAUtils.getCompressedFilename("x.wmf.y"));
+        assertEquals("x.wmf.y.lzma", LZMAUtils.getCompressedFileName("x.wmf.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetUncompressedFilename() {
         assertEquals("", LZMAUtils.getUncompressedFilename(""));
+        assertEquals("", LZMAUtils.getUncompressedFileName(""));
         assertEquals(".lzma", LZMAUtils.getUncompressedFilename(".lzma"));
+        assertEquals(".lzma", LZMAUtils.getUncompressedFileName(".lzma"));
 
         assertEquals("x", LZMAUtils.getUncompressedFilename("x.lzma"));
+        assertEquals("x", LZMAUtils.getUncompressedFileName("x.lzma"));
         assertEquals("x", LZMAUtils.getUncompressedFilename("x-lzma"));
+        assertEquals("x", LZMAUtils.getUncompressedFileName("x-lzma"));
 
         assertEquals("x.lzma ", LZMAUtils.getUncompressedFilename("x.lzma "));
+        assertEquals("x.lzma ", LZMAUtils.getUncompressedFileName("x.lzma "));
         assertEquals("x.lzma\n", LZMAUtils.getUncompressedFilename("x.lzma\n"));
+        assertEquals("x.lzma\n", LZMAUtils.getUncompressedFileName("x.lzma\n"));
         assertEquals("x.lzma.y", LZMAUtils.getUncompressedFilename("x.lzma.y"));
+        assertEquals("x.lzma.y", LZMAUtils.getUncompressedFileName("x.lzma.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testIsCompressedFilename() {
         assertFalse(LZMAUtils.isCompressedFilename(""));
+        assertFalse(LZMAUtils.isCompressedFileName(""));
         assertFalse(LZMAUtils.isCompressedFilename(".lzma"));
+        assertFalse(LZMAUtils.isCompressedFileName(".lzma"));
 
         assertTrue(LZMAUtils.isCompressedFilename("x.lzma"));
+        assertTrue(LZMAUtils.isCompressedFileName("x.lzma"));
         assertTrue(LZMAUtils.isCompressedFilename("x-lzma"));
+        assertTrue(LZMAUtils.isCompressedFileName("x-lzma"));
 
         assertFalse(LZMAUtils.isCompressedFilename("xxgz"));
+        assertFalse(LZMAUtils.isCompressedFileName("xxgz"));
         assertFalse(LZMAUtils.isCompressedFilename("lzmaz"));
+        assertFalse(LZMAUtils.isCompressedFileName("lzmaz"));
         assertFalse(LZMAUtils.isCompressedFilename("xaz"));
+        assertFalse(LZMAUtils.isCompressedFileName("xaz"));
 
         assertFalse(LZMAUtils.isCompressedFilename("x.lzma "));
+        assertFalse(LZMAUtils.isCompressedFileName("x.lzma "));
         assertFalse(LZMAUtils.isCompressedFilename("x.lzma\n"));
+        assertFalse(LZMAUtils.isCompressedFileName("x.lzma\n"));
         assertFalse(LZMAUtils.isCompressedFilename("x.lzma.y"));
+        assertFalse(LZMAUtils.isCompressedFileName("x.lzma.y"));
     }
 
     @Test


[commons-compress] 06/09: Uppercase XZ in documentation

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit c4085d77d7095536fb66caf53134cb5fb42610a2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 12:57:08 2023 -0400

    Uppercase XZ in documentation
---
 README.md                                                           | 2 +-
 RELEASE-NOTES.txt                                                   | 6 +++---
 pom.xml                                                             | 2 +-
 src/changes/changes.xml                                             | 2 +-
 src/changes/release-notes.vm                                        | 2 +-
 .../commons/compress/compressors/CompressorStreamFactory.java       | 6 +++---
 .../commons/compress/compressors/CompressorStreamProvider.java      | 2 +-
 .../java/org/apache/commons/compress/compressors/xz/XZUtils.java    | 3 ++-
 src/site/xdoc/examples.xml                                          | 4 ++--
 9 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index 5163265a..808fac7e 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ Apache Commons Compress
 
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, XZ, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
 
 Documentation
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 293ba54d..48006a1e 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -2,7 +2,7 @@
 
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, XZ, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
 
 New features:
@@ -36,7 +36,7 @@ Download it from https://commons.apache.org/compress/download_compress.cgi
 
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, XZ, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
 
 New features:
@@ -393,7 +393,7 @@ o Checked the sizes read for archive entries and reject archives
   several formats.
   Issue: COMPRESS-569.
 o OSGi detection was broken and so we always cached whether
-  xz/brotli/zstd/LZMA have been available even in OSGi
+  XZ/brotli/zstd/LZMA have been available even in OSGi
   environments.
   Issue: COMPRESS-552.
 o SevenZFile.getEntries now return a copy of entries.
diff --git a/pom.xml b/pom.xml
index 3e191245..79108093 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
   <description>
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, XZ, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
   </description>
 
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8b19ad66..d3a55211 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -643,7 +643,7 @@ you relied on the recovery attempt.">
       </action>
       <action issue="COMPRESS-552" type="fix" date="2021-03-07">
         OSGi detection was broken and so we always cached whether
-        xz/brotli/zstd/LZMA have been available even in OSGi
+        XZ/brotli/zstd/LZMA have been available even in OSGi
         environments.
       </action>
       <action issue="COMPRESS-571" type="fix" date="2021-03-17">
diff --git a/src/changes/release-notes.vm b/src/changes/release-notes.vm
index f38f9657..9ac3d32e 100644
--- a/src/changes/release-notes.vm
+++ b/src/changes/release-notes.vm
@@ -459,7 +459,7 @@ o Checked the sizes read for archive entries and reject archives
   several formats.
   Issue: COMPRESS-569.
 o OSGi detection was broken and so we always cached whether
-  xz/brotli/zstd/LZMA have been available even in OSGi
+  XZ/brotli/zstd/LZMA have been available even in OSGi
   environments.
   Issue: COMPRESS-552.
 o SevenZFile.getEntries now return a copy of entries.
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
index 302f6fc8..ba8c877f 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
@@ -474,7 +474,7 @@ public class CompressorStreamFactory implements CompressorStreamProvider {
      *            if true, decompress until the end of the input; if false, stop
      *            after the first stream and leave the input position to point
      *            to the next byte after the stream. This setting applies to the
-     *            gzip, bzip2 and xz formats only.
+     *            gzip, bzip2 and XZ formats only.
      * @since 1.10
      */
     public CompressorStreamFactory(final boolean decompressUntilEOF) {
@@ -488,7 +488,7 @@ public class CompressorStreamFactory implements CompressorStreamProvider {
      *            if true, decompress until the end of the input; if false, stop
      *            after the first stream and leave the input position to point
      *            to the next byte after the stream. This setting applies to the
-     *            gzip, bzip2 and xz formats only.
+     *            gzip, bzip2 and XZ formats only.
      *
      * @param memoryLimitInKb
      *            Some streams require allocation of potentially significant
@@ -752,7 +752,7 @@ public class CompressorStreamFactory implements CompressorStreamProvider {
      * supporting multiple concatenated input streams.
      *
      * <p>
-     * This setting applies to the gzip, bzip2 and xz formats only.
+     * This setting applies to the gzip, bzip2 and XZ formats only.
      * </p>
      *
      * @param decompressConcatenated
diff --git a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamProvider.java b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamProvider.java
index 8555d53c..1c27745e 100644
--- a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamProvider.java
+++ b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamProvider.java
@@ -53,7 +53,7 @@ public interface CompressorStreamProvider {
      *            if true, decompress until the end of the input; if false, stop
      *            after the first stream and leave the input position to point
      *            to the next byte after the stream. This setting applies to the
-     *            gzip, bzip2 and xz formats only.
+     *            gzip, bzip2 and XZ formats only.
      * @return compressor input stream
      * @throws CompressorException
      *             if the compressor name is not known
diff --git a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
index 5803586c..83b57bdd 100644
--- a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
@@ -25,7 +25,8 @@ import org.apache.commons.compress.compressors.FileNameUtil;
 import org.apache.commons.compress.utils.OsgiUtils;
 
 /**
- * Utility code for the xz compression format.
+ * Utility code for the XZ compression format.
+ *
  * @ThreadSafe
  * @since 1.4
  */
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index 47a423ae..830f8bbe 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -31,7 +31,7 @@
         collect multiple entries inside a single (potentially
         compressed) archive are archiver formats.</p>
 
-        <p>The compressor formats supported are gzip, bzip2, xz, LZMA,
+        <p>The compressor formats supported are gzip, bzip2, XZ, LZMA,
         Pack200, DEFLATE, Brotli, DEFLATE64, ZStandard and Z, the archiver formats are 7z, ar, arj,
         cpio, dump, tar and zip.  Pack200 is a special case as it can
         only compress JAR files.</p>
@@ -757,7 +757,7 @@ public class ScatterSample {
     <section name="Compressors">
 
       <subsection name="Concatenated Streams">
-        <p>For the bzip2, gzip and xz formats as well as the framed
+        <p>For the bzip2, gzip and XZ formats as well as the framed
         lz4 format a single compressed file
         may actually consist of several streams that will be
         concatenated by the command line utilities when decompressing


[commons-compress] 08/09: Add GzipUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String)

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 90417eec10b90722c3a8a5fb05de465c44930c75
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 13:20:14 2023 -0400

    Add GzipUtils.getCompressedFileName(String) and deprecate
    getCompressedFilename(String)
    
    - Add GzipUtils.getUncompressedFileName(String) and deprecate
    getUncompressedFilename(String)
    - Add GzipUtils.isCompressedFileName(String) and deprecate
    isCompressedFilename(String)
---
 src/changes/changes.xml                            |  3 ++
 .../compress/compressors/gzip/GzipUtils.java       | 52 ++++++++++++++++++++
 .../compress/compressors/GzipUtilsTestCase.java    | 57 ++++++++++++++++++++++
 3 files changed, 112 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d3a55211..7e4ace91 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,6 +60,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add XYUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add XYUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add XYUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
       <!-- FIX -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
index a73b8a4a..59f647ee 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
@@ -68,11 +68,29 @@ public class GzipUtils {
      *
      * @param fileName name of a file
      * @return name of the corresponding compressed file
+     * @deprecated Use {@link #getCompressedFileName(String)}.
      */
+    @Deprecated
     public static String getCompressedFilename(final String fileName) {
         return fileNameUtil.getCompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given file name to the name that the file should have after
+     * compression with gzip. Common file types with custom suffixes for
+     * compressed versions are automatically detected and correctly mapped.
+     * For example the name "package.tar" is mapped to "package.tgz". If no
+     * custom mapping is applicable, then the default ".gz" suffix is appended
+     * to the file name.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding compressed file
+     * @since 1.25.0
+     */
+    public static String getCompressedFileName(final String fileName) {
+        return fileNameUtil.getCompressedFileName(fileName);
+    }
+
     /**
      * Maps the given name of a gzip-compressed file to the name that the
      * file should have after uncompression. Commonly used file type specific
@@ -85,22 +103,56 @@ public class GzipUtils {
      *
      * @param fileName name of a file
      * @return name of the corresponding uncompressed file
+     * @deprecated Use {@link #getUncompressedFileName(String)}.
      */
+    @Deprecated
     public static String getUncompressedFilename(final String fileName) {
         return fileNameUtil.getUncompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given name of a gzip-compressed file to the name that the
+     * file should have after uncompression. Commonly used file type specific
+     * suffixes like ".tgz" or ".svgz" are automatically detected and
+     * correctly mapped. For example the name "package.tgz" is mapped to
+     * "package.tar". And any file names with the generic ".gz" suffix
+     * (or any other generic gzip suffix) is mapped to a name without that
+     * suffix. If no gzip suffix is detected, then the file name is returned
+     * unmapped.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding uncompressed file
+     * @since 1.25.0
+     */
+    public static String getUncompressedFileName(final String fileName) {
+        return fileNameUtil.getUncompressedFileName(fileName);
+    }
+
     /**
      * Detects common gzip suffixes in the given file name.
      *
      * @param fileName name of a file
      * @return {@code true} if the file name has a common gzip suffix,
      *         {@code false} otherwise
+     * @deprecated Use {@link #isCompressedFileName(String)}.
      */
+    @Deprecated
     public static boolean isCompressedFilename(final String fileName) {
         return fileNameUtil.isCompressedFileName(fileName);
     }
 
+    /**
+     * Detects common gzip suffixes in the given file name.
+     *
+     * @param fileName name of a file
+     * @return {@code true} if the file name has a common gzip suffix,
+     *         {@code false} otherwise
+     * @since 1.25.0
+     */
+    public static boolean isCompressedFileName(final String fileName) {
+        return fileNameUtil.isCompressedFileName(fileName);
+    }
+
     /** Private constructor to prevent instantiation of this utility class. */
     private GzipUtils() {
     }
diff --git a/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java b/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java
index cea4373c..cb873caf 100644
--- a/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java
@@ -27,80 +27,137 @@ import org.junit.jupiter.api.Test;
 
 public class GzipUtilsTestCase {
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetCompressedFilename() {
         assertEquals(".gz", GzipUtils.getCompressedFilename(""));
+        assertEquals(".gz", GzipUtils.getCompressedFileName(""));
         assertEquals("x.gz", GzipUtils.getCompressedFilename("x"));
+        assertEquals("x.gz", GzipUtils.getCompressedFileName("x"));
 
         assertEquals("x.tgz", GzipUtils.getCompressedFilename("x.tar"));
+        assertEquals("x.tgz", GzipUtils.getCompressedFileName("x.tar"));
         assertEquals("x.svgz", GzipUtils.getCompressedFilename("x.svg"));
+        assertEquals("x.svgz", GzipUtils.getCompressedFileName("x.svg"));
         assertEquals("x.cpgz", GzipUtils.getCompressedFilename("x.cpio"));
+        assertEquals("x.cpgz", GzipUtils.getCompressedFileName("x.cpio"));
         assertEquals("x.wmz", GzipUtils.getCompressedFilename("x.wmf"));
+        assertEquals("x.wmz", GzipUtils.getCompressedFileName("x.wmf"));
         assertEquals("x.emz", GzipUtils.getCompressedFilename("x.emf"));
+        assertEquals("x.emz", GzipUtils.getCompressedFileName("x.emf"));
 
         assertEquals("x.svgz", GzipUtils.getCompressedFilename("x.SVG"));
+        assertEquals("x.svgz", GzipUtils.getCompressedFileName("x.SVG"));
         assertEquals("X.svgz", GzipUtils.getCompressedFilename("X.SVG"));
+        assertEquals("X.svgz", GzipUtils.getCompressedFileName("X.SVG"));
         assertEquals("X.svgz", GzipUtils.getCompressedFilename("X.svG"));
+        assertEquals("X.svgz", GzipUtils.getCompressedFileName("X.svG"));
 
         assertEquals("x.wmf .gz", GzipUtils.getCompressedFilename("x.wmf "));
+        assertEquals("x.wmf .gz", GzipUtils.getCompressedFileName("x.wmf "));
         assertEquals("x.wmf\n.gz", GzipUtils.getCompressedFilename("x.wmf\n"));
+        assertEquals("x.wmf\n.gz", GzipUtils.getCompressedFileName("x.wmf\n"));
         assertEquals("x.wmf.y.gz", GzipUtils.getCompressedFilename("x.wmf.y"));
+        assertEquals("x.wmf.y.gz", GzipUtils.getCompressedFileName("x.wmf.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetUncompressedFilename() {
         assertEquals("", GzipUtils.getUncompressedFilename(""));
+        assertEquals("", GzipUtils.getUncompressedFileName(""));
         assertEquals(".gz", GzipUtils.getUncompressedFilename(".gz"));
+        assertEquals(".gz", GzipUtils.getUncompressedFileName(".gz"));
 
         assertEquals("x.tar", GzipUtils.getUncompressedFilename("x.tgz"));
+        assertEquals("x.tar", GzipUtils.getUncompressedFileName("x.tgz"));
         assertEquals("x.tar", GzipUtils.getUncompressedFilename("x.taz"));
+        assertEquals("x.tar", GzipUtils.getUncompressedFileName("x.taz"));
         assertEquals("x.svg", GzipUtils.getUncompressedFilename("x.svgz"));
+        assertEquals("x.svg", GzipUtils.getUncompressedFileName("x.svgz"));
         assertEquals("x.cpio", GzipUtils.getUncompressedFilename("x.cpgz"));
+        assertEquals("x.cpio", GzipUtils.getUncompressedFileName("x.cpgz"));
         assertEquals("x.wmf", GzipUtils.getUncompressedFilename("x.wmz"));
+        assertEquals("x.wmf", GzipUtils.getUncompressedFileName("x.wmz"));
         assertEquals("x.emf", GzipUtils.getUncompressedFilename("x.emz"));
+        assertEquals("x.emf", GzipUtils.getUncompressedFileName("x.emz"));
         assertEquals("x", GzipUtils.getUncompressedFilename("x.gz"));
+        assertEquals("x", GzipUtils.getUncompressedFileName("x.gz"));
         assertEquals("x", GzipUtils.getUncompressedFilename("x.z"));
+        assertEquals("x", GzipUtils.getUncompressedFileName("x.z"));
         assertEquals("x", GzipUtils.getUncompressedFilename("x-gz"));
+        assertEquals("x", GzipUtils.getUncompressedFileName("x-gz"));
         assertEquals("x", GzipUtils.getUncompressedFilename("x-z"));
+        assertEquals("x", GzipUtils.getUncompressedFileName("x-z"));
         assertEquals("x", GzipUtils.getUncompressedFilename("x_z"));
+        assertEquals("x", GzipUtils.getUncompressedFileName("x_z"));
 
         assertEquals("x.svg", GzipUtils.getUncompressedFilename("x.SVGZ"));
+        assertEquals("x.svg", GzipUtils.getUncompressedFileName("x.SVGZ"));
         assertEquals("X.svg", GzipUtils.getUncompressedFilename("X.SVGZ"));
+        assertEquals("X.svg", GzipUtils.getUncompressedFileName("X.SVGZ"));
         assertEquals("X.svg", GzipUtils.getUncompressedFilename("X.svGZ"));
+        assertEquals("X.svg", GzipUtils.getUncompressedFileName("X.svGZ"));
 
         assertEquals("x.wmz ", GzipUtils.getUncompressedFilename("x.wmz "));
+        assertEquals("x.wmz ", GzipUtils.getUncompressedFileName("x.wmz "));
         assertEquals("x.wmz\n", GzipUtils.getUncompressedFilename("x.wmz\n"));
+        assertEquals("x.wmz\n", GzipUtils.getUncompressedFileName("x.wmz\n"));
         assertEquals("x.wmz.y", GzipUtils.getUncompressedFilename("x.wmz.y"));
+        assertEquals("x.wmz.y", GzipUtils.getUncompressedFileName("x.wmz.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testIsCompressedFilename() {
         assertFalse(GzipUtils.isCompressedFilename(""));
+        assertFalse(GzipUtils.isCompressedFileName(""));
         assertFalse(GzipUtils.isCompressedFilename(".gz"));
+        assertFalse(GzipUtils.isCompressedFileName(".gz"));
 
         assertTrue(GzipUtils.isCompressedFilename("x.tgz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.tgz"));
         assertTrue(GzipUtils.isCompressedFilename("x.taz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.taz"));
         assertTrue(GzipUtils.isCompressedFilename("x.svgz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.svgz"));
         assertTrue(GzipUtils.isCompressedFilename("x.cpgz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.cpgz"));
         assertTrue(GzipUtils.isCompressedFilename("x.wmz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.wmz"));
         assertTrue(GzipUtils.isCompressedFilename("x.emz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.emz"));
         assertTrue(GzipUtils.isCompressedFilename("x.gz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.gz"));
         assertTrue(GzipUtils.isCompressedFilename("x.z"));
+        assertTrue(GzipUtils.isCompressedFileName("x.z"));
         assertTrue(GzipUtils.isCompressedFilename("x-gz"));
+        assertTrue(GzipUtils.isCompressedFileName("x-gz"));
         assertTrue(GzipUtils.isCompressedFilename("x-z"));
+        assertTrue(GzipUtils.isCompressedFileName("x-z"));
         assertTrue(GzipUtils.isCompressedFilename("x_z"));
+        assertTrue(GzipUtils.isCompressedFileName("x_z"));
 
         assertFalse(GzipUtils.isCompressedFilename("xxgz"));
+        assertFalse(GzipUtils.isCompressedFileName("xxgz"));
         assertFalse(GzipUtils.isCompressedFilename("xzz"));
+        assertFalse(GzipUtils.isCompressedFileName("xzz"));
         assertFalse(GzipUtils.isCompressedFilename("xaz"));
+        assertFalse(GzipUtils.isCompressedFileName("xaz"));
 
         assertTrue(GzipUtils.isCompressedFilename("x.SVGZ"));
+        assertTrue(GzipUtils.isCompressedFileName("x.SVGZ"));
         assertTrue(GzipUtils.isCompressedFilename("x.Svgz"));
+        assertTrue(GzipUtils.isCompressedFileName("x.Svgz"));
         assertTrue(GzipUtils.isCompressedFilename("x.svGZ"));
+        assertTrue(GzipUtils.isCompressedFileName("x.svGZ"));
 
         assertFalse(GzipUtils.isCompressedFilename("x.wmz "));
+        assertFalse(GzipUtils.isCompressedFileName("x.wmz "));
         assertFalse(GzipUtils.isCompressedFilename("x.wmz\n"));
+        assertFalse(GzipUtils.isCompressedFileName("x.wmz\n"));
         assertFalse(GzipUtils.isCompressedFilename("x.wmz.y"));
+        assertFalse(GzipUtils.isCompressedFileName("x.wmz.y"));
     }
 
 }


[commons-compress] 05/09: LZMA is an acronym

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit f2cec930f65125c140032c59835f7a5c3a992ad1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 12:51:26 2023 -0400

    LZMA is an acronym
---
 README.md                                                         | 2 +-
 RELEASE-NOTES.txt                                                 | 6 +++---
 pom.xml                                                           | 2 +-
 src/changes/release-notes.vm                                      | 2 +-
 .../commons/compress/archivers/sevenz/SevenZFileOptions.java      | 8 ++++----
 .../compress/compressors/lzma/LZMACompressorInputStream.java      | 4 ++--
 src/site/xdoc/examples.xml                                        | 8 ++++----
 src/site/xdoc/index.xml                                           | 6 +++---
 8 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/README.md b/README.md
index b19e1709..5163265a 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ Apache Commons Compress
 
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-lzma, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
 
 Documentation
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index ee23a8b6..293ba54d 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -2,7 +2,7 @@
 
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-lzma, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
 
 New features:
@@ -36,7 +36,7 @@ Download it from https://commons.apache.org/compress/download_compress.cgi
 
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-lzma, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
 
 New features:
@@ -393,7 +393,7 @@ o Checked the sizes read for archive entries and reject archives
   several formats.
   Issue: COMPRESS-569.
 o OSGi detection was broken and so we always cached whether
-  xz/brotli/zstd/lzma have been available even in OSGi
+  xz/brotli/zstd/LZMA have been available even in OSGi
   environments.
   Issue: COMPRESS-552.
 o SevenZFile.getEntries now return a copy of entries.
diff --git a/pom.xml b/pom.xml
index cf378c19..3e191245 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
   <description>
 Apache Commons Compress defines an API for working with
 compression and archive formats.  These include: bzip2, gzip, pack200,
-lzma, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
+LZMA, xz, Snappy, traditional Unix Compress, DEFLATE, DEFLATE64, LZ4,
 Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
   </description>
 
diff --git a/src/changes/release-notes.vm b/src/changes/release-notes.vm
index e7b4fae7..f38f9657 100644
--- a/src/changes/release-notes.vm
+++ b/src/changes/release-notes.vm
@@ -459,7 +459,7 @@ o Checked the sizes read for archive entries and reject archives
   several formats.
   Issue: COMPRESS-569.
 o OSGi detection was broken and so we always cached whether
-  xz/brotli/zstd/lzma have been available even in OSGi
+  xz/brotli/zstd/LZMA have been available even in OSGi
   environments.
   Issue: COMPRESS-552.
 o SevenZFile.getEntries now return a copy of entries.
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFileOptions.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFileOptions.java
index 67f0e294..642669db 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFileOptions.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFileOptions.java
@@ -47,8 +47,8 @@ public class SevenZFileOptions {
          * Sets the maximum amount of memory to use for parsing the
          * archive and during extraction.
          *
-         * <p>Not all codecs will honor this setting. Currently only lzma
-         * and lzma2 are supported.</p>
+         * <p>Not all codecs will honor this setting. Currently only LZMA
+         * and LZMA2 are supported.</p>
          *
          * @param maxMemoryLimitInKb limit of the maximum amount of memory to use
          * @return the reconfigured builder
@@ -131,8 +131,8 @@ public class SevenZFileOptions {
      * Gets the maximum amount of memory to use for parsing the
      * archive and during extraction.
      *
-     * <p>Not all codecs will honor this setting. Currently only lzma
-     * and lzma2 are supported.</p>
+     * <p>Not all codecs will honor this setting. Currently only LZMA
+     * and LZMA2 are supported.</p>
      *
      * @return the maximum amount of memory to use for extraction
      */
diff --git a/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
index d68a6dfb..96814a95 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
@@ -36,13 +36,13 @@ public class LZMACompressorInputStream extends CompressorInputStream
     implements InputStreamStatistics {
 
     /**
-     * Checks if the signature matches what is expected for an lzma file.
+     * Checks if the signature matches what is expected for an LZMA file.
      *
      * @param signature
      *            the bytes to check
      * @param length
      *            the number of bytes to check
-     * @return true, if this stream is an lzma  compressed stream, false otherwise
+     * @return true, if this stream is an LZMA compressed stream, false otherwise
      *
      * @since 1.10
      */
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index 187036be..47a423ae 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -31,7 +31,7 @@
         collect multiple entries inside a single (potentially
         compressed) archive are archiver formats.</p>
 
-        <p>The compressor formats supported are gzip, bzip2, xz, lzma,
+        <p>The compressor formats supported are gzip, bzip2, xz, LZMA,
         Pack200, DEFLATE, Brotli, DEFLATE64, ZStandard and Z, the archiver formats are 7z, ar, arj,
         cpio, dump, tar and zip.  Pack200 is a special case as it can
         only compress JAR files.</p>
@@ -82,7 +82,7 @@ CompressorInputStream input = new CompressorStreamFactory()
     .createCompressorInputStream(originalInput);
 ]]></source>
 
-        <p>Note that there is no way to detect the lzma or Brotli formats so only
+        <p>Note that there is no way to detect the LZMA or Brotli formats so only
         the two-arg version of
         <code>createCompressorInputStream</code> can be used.  Prior
         to Compress 1.9 the .Z format hasn't been auto-detected
@@ -991,7 +991,7 @@ in.close();
           public domain <a href="https://tukaani.org/xz/java.html">XZ
           for Java</a> library.</p>
 
-        <p>Uncompressing a given lzma compressed file (you would
+        <p>Uncompressing a given LZMA compressed file (you would
           certainly add exception handling and make sure all streams
           get closed properly):</p>
 <source><![CDATA[
@@ -1008,7 +1008,7 @@ out.close();
 lzmaIn.close();
 ]]></source>
 
-        <p>Compressing a given file using lzma (you would
+        <p>Compressing a given file using LZMA (you would
           certainly add exception handling and make sure all streams
           get closed properly):</p>
 <source><![CDATA[
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 3fef4576..613f53a0 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -27,7 +27,7 @@
             <p>
                 The Apache Commons Compress library defines an API for
                 working with ar, cpio, Unix dump, tar, zip, gzip, XZ,
-                Pack200, bzip2, 7z, arj, lzma, snappy, DEFLATE, lz4,
+                Pack200, bzip2, 7z, arj, LZMA, snappy, DEFLATE, lz4,
                 Brotli, Zstandard, DEFLATE64 and Z files.
             </p>
             <p>
@@ -70,11 +70,11 @@
             by <code>ArchiveEntry</code> instances which in turn
             usually correspond to single files or directories.</p>
 
-          <p>Currently the bzip2, Pack200, XZ, gzip, lzma, brotli,
+          <p>Currently the bzip2, Pack200, XZ, gzip, LZMA, brotli,
             Zstandard and Z formats are
             supported as compressors where gzip support is mostly provided by
             the <code>java.util.zip</code> package of the Java
-            class library.  XZ and lzma support is provided by the public
+            class library.  XZ and LZMA support is provided by the public
             domain <a href="https://tukaani.org/xz/java.html">XZ for
             Java</a> library.  Brotli support is provided by the MIT
             licensed <a href="https://github.com/google/brotli">Google


[commons-compress] 07/09: Javadoc

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 6d4e0afab260b471d58931e2fe32e96a094204ba
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 12:57:25 2023 -0400

    Javadoc
---
 .../org/apache/commons/compress/compressors/gzip/GzipParameters.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java
index 51d25684..d753d772 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java
@@ -73,7 +73,7 @@ public class GzipParameters {
      * Gets the file name.
      *
      * @return the file name.
-     * @deprecated
+     * @deprecated Use {@link #getFileName()}.
      */
     @Deprecated
     public String getFilename() {


[commons-compress] 01/09: Add FileNameUtil.getCompressedFileName(String) and deprecate getCompressedFilename(String)

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 6c20f8b1226cc7dd55bae98b224bb87795390b75
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 11:14:36 2023 -0400

    Add FileNameUtil.getCompressedFileName(String) and deprecate
    getCompressedFilename(String)
    
    - Add FileNameUtil.getUncompressedFileName(String) and deprecate
    getUncompressedFilename(String)
    - Add FileNameUtil.isCompressedFileName(String) and deprecate
    isCompressedFilename(String)
---
 src/changes/changes.xml                            |  3 ++
 .../commons/compress/compressors/FileNameUtil.java | 52 ++++++++++++++++++++++
 .../compress/compressors/bzip2/BZip2Utils.java     |  6 +--
 .../compress/compressors/gzip/GzipUtils.java       |  6 +--
 .../compress/compressors/lzma/LZMAUtils.java       |  6 +--
 .../commons/compress/compressors/xz/XZUtils.java   |  6 +--
 6 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ada37ee8..a71ea082 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@ The <action> type attribute can be add,update,fix,remove.
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipParameters.getFileName() and deprecate getFilename().</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipParameters.setFileName(String) and deprecate setFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add FileNameUtil.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add FileNameUtil.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add FileNameUtil.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
       <!-- FIX -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
diff --git a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java b/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
index 1dfd9fee..66b4eb0a 100644
--- a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
+++ b/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
@@ -131,8 +131,26 @@ public class FileNameUtil {
      *
      * @param fileName name of a file
      * @return name of the corresponding compressed file
+     * @deprecated Use {@link #getCompressedFileName(String)}.
      */
+    @Deprecated
     public String getCompressedFilename(final String fileName) {
+        return getCompressedFileName(fileName);
+    }
+
+    /**
+     * Maps the given file name to the name that the file should have after
+     * compression. Common file types with custom suffixes for
+     * compressed versions are automatically detected and correctly mapped.
+     * For example the name "package.tar" is mapped to "package.tgz". If no
+     * custom mapping is applicable, then the default ".gz" suffix is appended
+     * to the file name.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding compressed file
+     * @since 1.25.0
+     */
+    public String getCompressedFileName(final String fileName) {
         final String lower = fileName.toLowerCase(Locale.ENGLISH);
         final int n = lower.length();
         for (int i = shortestUncompressedSuffix;
@@ -158,8 +176,28 @@ public class FileNameUtil {
      *
      * @param fileName name of a file
      * @return name of the corresponding uncompressed file
+     * @deprecated Use {@link #getUncompressedFileName(String)}.
      */
+    @Deprecated
     public String getUncompressedFilename(final String fileName) {
+        return getUncompressedFileName(fileName);
+    }
+
+    /**
+     * Maps the given name of a compressed file to the name that the
+     * file should have after uncompression. Commonly used file type specific
+     * suffixes like ".tgz" or ".svgz" are automatically detected and
+     * correctly mapped. For example the name "package.tgz" is mapped to
+     * "package.tar". And any file names with the generic ".gz" suffix
+     * (or any other generic gzip suffix) is mapped to a name without that
+     * suffix. If no format suffix is detected, then the file name is returned
+     * unmapped.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding uncompressed file
+     * @since 1.25.0
+     */
+    public String getUncompressedFileName(final String fileName) {
         final String lower = fileName.toLowerCase(Locale.ENGLISH);
         final int n = lower.length();
         for (int i = shortestCompressedSuffix;
@@ -178,8 +216,22 @@ public class FileNameUtil {
      * @param fileName name of a file
      * @return {@code true} if the file name has a common format suffix,
      *         {@code false} otherwise
+     * @deprecated Use {@link #isCompressedFileName(String)}.
      */
+    @Deprecated
     public boolean isCompressedFilename(final String fileName) {
+        return isCompressedFileName(fileName);
+    }
+
+    /**
+     * Detects common format suffixes in the given file name.
+     *
+     * @param fileName name of a file
+     * @return {@code true} if the file name has a common format suffix,
+     *         {@code false} otherwise
+     * @since 1.25.0
+     */
+    public boolean isCompressedFileName(final String fileName) {
         final String lower = fileName.toLowerCase(Locale.ENGLISH);
         final int n = lower.length();
         for (int i = shortestCompressedSuffix;
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
index 7235961f..2884d229 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
@@ -56,7 +56,7 @@ public abstract class BZip2Utils {
      * @return name of the corresponding compressed file
      */
     public static String getCompressedFilename(final String fileName) {
-        return fileNameUtil.getCompressedFilename(fileName);
+        return fileNameUtil.getCompressedFileName(fileName);
     }
 
     /**
@@ -73,7 +73,7 @@ public abstract class BZip2Utils {
      * @return name of the corresponding uncompressed file
      */
     public static String getUncompressedFilename(final String fileName) {
-        return fileNameUtil.getUncompressedFilename(fileName);
+        return fileNameUtil.getUncompressedFileName(fileName);
     }
 
     /**
@@ -84,7 +84,7 @@ public abstract class BZip2Utils {
      *         {@code false} otherwise
      */
     public static boolean isCompressedFilename(final String fileName) {
-        return fileNameUtil.isCompressedFilename(fileName);
+        return fileNameUtil.isCompressedFileName(fileName);
     }
 
     /** Private constructor to prevent instantiation of this utility class. */
diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
index 013adae2..a73b8a4a 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
@@ -70,7 +70,7 @@ public class GzipUtils {
      * @return name of the corresponding compressed file
      */
     public static String getCompressedFilename(final String fileName) {
-        return fileNameUtil.getCompressedFilename(fileName);
+        return fileNameUtil.getCompressedFileName(fileName);
     }
 
     /**
@@ -87,7 +87,7 @@ public class GzipUtils {
      * @return name of the corresponding uncompressed file
      */
     public static String getUncompressedFilename(final String fileName) {
-        return fileNameUtil.getUncompressedFilename(fileName);
+        return fileNameUtil.getUncompressedFileName(fileName);
     }
 
     /**
@@ -98,7 +98,7 @@ public class GzipUtils {
      *         {@code false} otherwise
      */
     public static boolean isCompressedFilename(final String fileName) {
-        return fileNameUtil.isCompressedFilename(fileName);
+        return fileNameUtil.isCompressedFileName(fileName);
     }
 
     /** Private constructor to prevent instantiation of this utility class. */
diff --git a/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java b/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java
index bedefa54..7e5ebd41 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lzma/LZMAUtils.java
@@ -68,7 +68,7 @@ public class LZMAUtils {
      * @return name of the corresponding compressed file
      */
     public static String getCompressedFilename(final String fileName) {
-        return fileNameUtil.getCompressedFilename(fileName);
+        return fileNameUtil.getCompressedFileName(fileName);
     }
 
     /**
@@ -82,7 +82,7 @@ public class LZMAUtils {
      * @return name of the corresponding uncompressed file
      */
     public static String getUncompressedFilename(final String fileName) {
-        return fileNameUtil.getUncompressedFilename(fileName);
+        return fileNameUtil.getUncompressedFileName(fileName);
     }
 
     private static boolean internalIsLZMACompressionAvailable() {
@@ -102,7 +102,7 @@ public class LZMAUtils {
      *         {@code false} otherwise
      */
     public static boolean isCompressedFilename(final String fileName) {
-        return fileNameUtil.isCompressedFilename(fileName);
+        return fileNameUtil.isCompressedFileName(fileName);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
index 3429c0e2..54bf52f9 100644
--- a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
@@ -76,7 +76,7 @@ public class XZUtils {
      * @return name of the corresponding compressed file
      */
     public static String getCompressedFilename(final String fileName) {
-        return fileNameUtil.getCompressedFilename(fileName);
+        return fileNameUtil.getCompressedFileName(fileName);
     }
 
     /**
@@ -93,7 +93,7 @@ public class XZUtils {
      * @return name of the corresponding uncompressed file
      */
     public static String getUncompressedFilename(final String fileName) {
-        return fileNameUtil.getUncompressedFilename(fileName);
+        return fileNameUtil.getUncompressedFileName(fileName);
     }
 
     private static boolean internalIsXZCompressionAvailable() {
@@ -113,7 +113,7 @@ public class XZUtils {
      *         {@code false} otherwise
      */
     public static boolean isCompressedFilename(final String fileName) {
-        return fileNameUtil.isCompressedFilename(fileName);
+        return fileNameUtil.isCompressedFileName(fileName);
     }
 
     /**


[commons-compress] 09/09: Remove duplicate entry

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 8b4374089a9eca100a331c5a3b827d967c4b5f5c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 13:20:42 2023 -0400

    Remove duplicate entry
---
 src/changes/changes.xml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7e4ace91..ea3f0976 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,11 +66,10 @@ The <action> type attribute can be add,update,fix,remove.
       <!-- FIX -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
-      <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 61 to 64.</action>
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.13.0 to 2.14.0.</action>
       <action type="update" dev="ggregory" due-to="Dependabot">Bump com.github.luben:zstd-jni from 1.5.5-5 to 1.5.5-6 #422.</action>
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.ow2.asm:asm from 9.5 to 9.6 #421.</action>
-      <action type="update" dev="ggregory" due-to="Dependabot">Bump org.apache.commons:commons-parent from 62 to 64 #421.</action>
+      <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 62 to 64 #421.</action>
     </release>
     <release version="1.24.0" date="2023-09-04" description="Minor feature and maintenance release.">
       <!-- ADD -->


[commons-compress] 02/09: Add BZip2Util.getCompressedFileName(String) and deprecate getCompressedFilename(String)

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit f59a682158941b4003bdd88f83b72e1a10e7231f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 11:30:24 2023 -0400

    Add BZip2Util.getCompressedFileName(String) and deprecate
    getCompressedFilename(String)
    
    - Add BZip2Util.getUncompressedFileName(String) and deprecate
    getUncompressedFilename(String)
    - Add BZip2Util.isCompressedFileName(String) and deprecate
    isCompressedFilename(String)
---
 src/changes/changes.xml                            |  3 ++
 .../compress/compressors/bzip2/BZip2Utils.java     | 51 ++++++++++++++++++++++
 .../compress/compressors/BZip2UtilsTestCase.java   | 35 +++++++++++++++
 3 files changed, 89 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a71ea082..ff10b3ed 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -51,6 +51,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add FileNameUtil.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add FileNameUtil.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add FileNameUtil.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add BZip2Utils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add BZip2Utils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add BZip2Utils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
       <!-- FIX -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
index 2884d229..bf20d074 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java
@@ -54,11 +54,28 @@ public abstract class BZip2Utils {
      *
      * @param fileName name of a file
      * @return name of the corresponding compressed file
+     * @deprecated Use {@link #getCompressedFileName(String)}.
      */
+    @Deprecated
     public static String getCompressedFilename(final String fileName) {
         return fileNameUtil.getCompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given file name to the name that the file should have after
+     * compression with bzip2. Currently this method simply appends the suffix
+     * ".bz2" to the file name based on the standard behavior of the "bzip2"
+     * program, but a future version may implement a more complex mapping if
+     * a new widely used naming pattern emerges.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding compressed file
+     * @since 1.25.0
+     */
+    public static String getCompressedFileName(final String fileName) {
+        return fileNameUtil.getCompressedFileName(fileName);
+    }
+
     /**
      * Maps the given name of a bzip2-compressed file to the name that the
      * file should have after uncompression. Commonly used file type specific
@@ -71,22 +88,56 @@ public abstract class BZip2Utils {
      *
      * @param fileName name of a file
      * @return name of the corresponding uncompressed file
+     * @deprecated Use {@link #getUncompressedFileName(String)}.
      */
+    @Deprecated
     public static String getUncompressedFilename(final String fileName) {
         return fileNameUtil.getUncompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given name of a bzip2-compressed file to the name that the
+     * file should have after uncompression. Commonly used file type specific
+     * suffixes like ".tbz" or ".tbz2" are automatically detected and
+     * correctly mapped. For example the name "package.tbz2" is mapped to
+     * "package.tar". And any file names with the generic ".bz2" suffix
+     * (or any other generic bzip2 suffix) is mapped to a name without that
+     * suffix. If no bzip2 suffix is detected, then the file name is returned
+     * unmapped.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding uncompressed file
+     * @since 1.25.0
+     */
+    public static String getUncompressedFileName(final String fileName) {
+        return fileNameUtil.getUncompressedFileName(fileName);
+    }
+
     /**
      * Detects common bzip2 suffixes in the given file name.
      *
      * @param fileName name of a file
      * @return {@code true} if the file name has a common bzip2 suffix,
      *         {@code false} otherwise
+     * @deprecated Use {@link #isCompressedFileName(String)}.
      */
+    @Deprecated
     public static boolean isCompressedFilename(final String fileName) {
         return fileNameUtil.isCompressedFileName(fileName);
     }
 
+    /**
+     * Detects common bzip2 suffixes in the given file name.
+     *
+     * @param fileName name of a file
+     * @return {@code true} if the file name has a common bzip2 suffix,
+     *         {@code false} otherwise
+     * @since 1.25.0
+     */
+    public static boolean isCompressedFileName(final String fileName) {
+        return fileNameUtil.isCompressedFileName(fileName);
+    }
+
     /** Private constructor to prevent instantiation of this utility class. */
     private BZip2Utils() {
     }
diff --git a/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java b/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java
index 8203bcb6..1e41c4ab 100644
--- a/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java
@@ -27,55 +27,90 @@ import org.junit.jupiter.api.Test;
 
 public class BZip2UtilsTestCase {
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetCompressedFilename() {
         assertEquals(".bz2", BZip2Utils.getCompressedFilename(""));
+        assertEquals(".bz2", BZip2Utils.getCompressedFileName(""));
         assertEquals(" .bz2", BZip2Utils.getCompressedFilename(" "));
+        assertEquals(" .bz2", BZip2Utils.getCompressedFileName(" "));
         assertEquals("x.bz2", BZip2Utils.getCompressedFilename("x"));
+        assertEquals("x.bz2", BZip2Utils.getCompressedFileName("x"));
         assertEquals("X.bz2", BZip2Utils.getCompressedFilename("X"));
+        assertEquals("X.bz2", BZip2Utils.getCompressedFileName("X"));
         assertEquals("x.tar.bz2", BZip2Utils.getCompressedFilename("x.tar"));
+        assertEquals("x.tar.bz2", BZip2Utils.getCompressedFileName("x.tar"));
         assertEquals("x.tar.bz2", BZip2Utils.getCompressedFilename("x.TAR"));
+        assertEquals("x.tar.bz2", BZip2Utils.getCompressedFileName("x.TAR"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetUncompressedFilename() {
         assertEquals("", BZip2Utils.getUncompressedFilename(""));
+        assertEquals("", BZip2Utils.getUncompressedFileName(""));
         assertEquals(".bz2", BZip2Utils.getUncompressedFilename(".bz2"));
+        assertEquals(".bz2", BZip2Utils.getUncompressedFileName(".bz2"));
 
         assertEquals("x.tar", BZip2Utils.getUncompressedFilename("x.tbz2"));
+        assertEquals("x.tar", BZip2Utils.getUncompressedFileName("x.tbz2"));
         assertEquals("x.tar", BZip2Utils.getUncompressedFilename("x.tbz"));
+        assertEquals("x.tar", BZip2Utils.getUncompressedFileName("x.tbz"));
         assertEquals("x", BZip2Utils.getUncompressedFilename("x.bz2"));
+        assertEquals("x", BZip2Utils.getUncompressedFileName("x.bz2"));
         assertEquals("x", BZip2Utils.getUncompressedFilename("x.bz"));
+        assertEquals("x", BZip2Utils.getUncompressedFileName("x.bz"));
 
         assertEquals("x.tar", BZip2Utils.getUncompressedFilename("x.TBZ2"));
+        assertEquals("x.tar", BZip2Utils.getUncompressedFileName("x.TBZ2"));
         assertEquals("X.tar", BZip2Utils.getUncompressedFilename("X.Tbz2"));
+        assertEquals("X.tar", BZip2Utils.getUncompressedFileName("X.Tbz2"));
         assertEquals("X.tar", BZip2Utils.getUncompressedFilename("X.tbZ2"));
+        assertEquals("X.tar", BZip2Utils.getUncompressedFileName("X.tbZ2"));
 
         assertEquals("x.bz ", BZip2Utils.getUncompressedFilename("x.bz "));
+        assertEquals("x.bz ", BZip2Utils.getUncompressedFileName("x.bz "));
         assertEquals("x.tbz\n", BZip2Utils.getUncompressedFilename("x.tbz\n"));
+        assertEquals("x.tbz\n", BZip2Utils.getUncompressedFileName("x.tbz\n"));
         assertEquals("x.tbz2.y", BZip2Utils.getUncompressedFilename("x.tbz2.y"));
+        assertEquals("x.tbz2.y", BZip2Utils.getUncompressedFileName("x.tbz2.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testIsCompressedFilename() {
         assertFalse(BZip2Utils.isCompressedFilename(""));
+        assertFalse(BZip2Utils.isCompressedFileName(""));
         assertFalse(BZip2Utils.isCompressedFilename(".gz"));
+        assertFalse(BZip2Utils.isCompressedFileName(".gz"));
 
         assertTrue(BZip2Utils.isCompressedFilename("x.tbz2"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.tbz2"));
         assertTrue(BZip2Utils.isCompressedFilename("x.tbz"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.tbz"));
         assertTrue(BZip2Utils.isCompressedFilename("x.bz2"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.bz2"));
         assertTrue(BZip2Utils.isCompressedFilename("x.bz"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.bz"));
 
+        assertFalse(BZip2Utils.isCompressedFilename("xbz2"));
         assertFalse(BZip2Utils.isCompressedFilename("xbz2"));
         assertFalse(BZip2Utils.isCompressedFilename("xbz"));
+        assertFalse(BZip2Utils.isCompressedFileName("xbz"));
 
         assertTrue(BZip2Utils.isCompressedFilename("x.TBZ2"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.TBZ2"));
         assertTrue(BZip2Utils.isCompressedFilename("x.Tbz2"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.Tbz2"));
         assertTrue(BZip2Utils.isCompressedFilename("x.tbZ2"));
+        assertTrue(BZip2Utils.isCompressedFileName("x.tbZ2"));
 
         assertFalse(BZip2Utils.isCompressedFilename("x.bz "));
+        assertFalse(BZip2Utils.isCompressedFileName("x.bz "));
         assertFalse(BZip2Utils.isCompressedFilename("x.tbz\n"));
+        assertFalse(BZip2Utils.isCompressedFileName("x.tbz\n"));
         assertFalse(BZip2Utils.isCompressedFilename("x.tbz2.y"));
+        assertFalse(BZip2Utils.isCompressedFileName("x.tbz2.y"));
     }
 
 }


[commons-compress] 04/09: Add XYUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String)

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit d29c085640f579231c9afe39e2ba97ab5e94c59b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 19 12:51:04 2023 -0400

    Add XYUtils.getCompressedFileName(String) and deprecate
    getCompressedFilename(String)
    
    - Add XYUtils.getUncompressedFileName(String) and deprecate
    getUncompressedFilename(String)
    - Add XYUtils.isCompressedFileName(String) and deprecate
    isCompressedFilename(String)
---
 src/changes/changes.xml                            |  5 +++-
 .../commons/compress/compressors/xz/XZUtils.java   | 34 ++++++++++++++++++++++
 .../compress/compressors/xz/XZUtilsTestCase.java   | 27 +++++++++++++++++
 3 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9b362e22..8b19ad66 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -57,6 +57,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add LZMAUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add LZMAUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add LZMAUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add XYUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add XYUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add XYUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action>
       <!-- FIX -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.8 to 2.0.9 #413.</action>
@@ -640,7 +643,7 @@ you relied on the recovery attempt.">
       </action>
       <action issue="COMPRESS-552" type="fix" date="2021-03-07">
         OSGi detection was broken and so we always cached whether
-        xz/brotli/zstd/lzma have been available even in OSGi
+        xz/brotli/zstd/LZMA have been available even in OSGi
         environments.
       </action>
       <action issue="COMPRESS-571" type="fix" date="2021-03-17">
diff --git a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
index 2dc89c32..5803586c 100644
--- a/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
+++ b/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
@@ -109,11 +109,31 @@ public class XZUtils {
      *
      * @param fileName name of a file
      * @return name of the corresponding uncompressed file
+     * @deprecated Use {@link #getUncompressedFileName(String)}.
      */
+    @Deprecated
     public static String getUncompressedFilename(final String fileName) {
         return fileNameUtil.getUncompressedFileName(fileName);
     }
 
+    /**
+     * Maps the given name of a xz-compressed file to the name that the
+     * file should have after uncompression. Commonly used file type specific
+     * suffixes like ".txz" are automatically detected and
+     * correctly mapped. For example the name "package.txz" is mapped to
+     * "package.tar". And any file names with the generic ".xz" suffix
+     * (or any other generic xz suffix) is mapped to a name without that
+     * suffix. If no xz suffix is detected, then the file name is returned
+     * unmapped.
+     *
+     * @param fileName name of a file
+     * @return name of the corresponding uncompressed file
+     * @since 1.25.0
+     */
+    public static String getUncompressedFileName(final String fileName) {
+        return fileNameUtil.getUncompressedFileName(fileName);
+    }
+
     private static boolean internalIsXZCompressionAvailable() {
         try {
             XZCompressorInputStream.matches(null, 0);
@@ -129,11 +149,25 @@ public class XZUtils {
      * @param fileName name of a file
      * @return {@code true} if the file name has a common xz suffix,
      *         {@code false} otherwise
+     * @deprecated Use {@link #isCompressedFileName(String)}.
      */
+    @Deprecated
     public static boolean isCompressedFilename(final String fileName) {
         return fileNameUtil.isCompressedFileName(fileName);
     }
 
+    /**
+     * Detects common xz suffixes in the given file name.
+     *
+     * @param fileName name of a file
+     * @return {@code true} if the file name has a common xz suffix,
+     *         {@code false} otherwise
+     * @since 1.25.0
+     */
+    public static boolean isCompressedFileName(final String fileName) {
+        return fileNameUtil.isCompressedFileName(fileName);
+    }
+
     /**
      * Are the classes required to support XZ compression available?
      * @since 1.5
diff --git a/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java b/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
index f600699c..8dada436 100644
--- a/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
@@ -43,48 +43,75 @@ public class XZUtilsTestCase {
         }
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetCompressedFilename() {
         assertEquals(".xz", XZUtils.getCompressedFilename(""));
+        assertEquals(".xz", XZUtils.getCompressedFileName(""));
         assertEquals("x.xz", XZUtils.getCompressedFilename("x"));
+        assertEquals("x.xz", XZUtils.getCompressedFileName("x"));
 
         assertEquals("x.txz", XZUtils.getCompressedFilename("x.tar"));
+        assertEquals("x.txz", XZUtils.getCompressedFileName("x.tar"));
 
         assertEquals("x.wmf .xz", XZUtils.getCompressedFilename("x.wmf "));
+        assertEquals("x.wmf .xz", XZUtils.getCompressedFileName("x.wmf "));
         assertEquals("x.wmf\n.xz", XZUtils.getCompressedFilename("x.wmf\n"));
+        assertEquals("x.wmf\n.xz", XZUtils.getCompressedFileName("x.wmf\n"));
         assertEquals("x.wmf.y.xz", XZUtils.getCompressedFilename("x.wmf.y"));
+        assertEquals("x.wmf.y.xz", XZUtils.getCompressedFileName("x.wmf.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testGetUncompressedFilename() {
         assertEquals("", XZUtils.getUncompressedFilename(""));
+        assertEquals("", XZUtils.getUncompressedFileName(""));
         assertEquals(".xz", XZUtils.getUncompressedFilename(".xz"));
 
         assertEquals("x.tar", XZUtils.getUncompressedFilename("x.txz"));
+        assertEquals("x.tar", XZUtils.getUncompressedFileName("x.txz"));
         assertEquals("x", XZUtils.getUncompressedFilename("x.xz"));
+        assertEquals("x", XZUtils.getUncompressedFileName("x.xz"));
         assertEquals("x", XZUtils.getUncompressedFilename("x-xz"));
+        assertEquals("x", XZUtils.getUncompressedFileName("x-xz"));
 
         assertEquals("x.txz ", XZUtils.getUncompressedFilename("x.txz "));
+        assertEquals("x.txz ", XZUtils.getUncompressedFileName("x.txz "));
         assertEquals("x.txz\n", XZUtils.getUncompressedFilename("x.txz\n"));
+        assertEquals("x.txz\n", XZUtils.getUncompressedFileName("x.txz\n"));
         assertEquals("x.txz.y", XZUtils.getUncompressedFilename("x.txz.y"));
+        assertEquals("x.txz.y", XZUtils.getUncompressedFileName("x.txz.y"));
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testIsCompressedFilename() {
         assertFalse(XZUtils.isCompressedFilename(""));
+        assertFalse(XZUtils.isCompressedFileName(""));
         assertFalse(XZUtils.isCompressedFilename(".xz"));
+        assertFalse(XZUtils.isCompressedFileName(".xz"));
 
         assertTrue(XZUtils.isCompressedFilename("x.txz"));
+        assertTrue(XZUtils.isCompressedFileName("x.txz"));
         assertTrue(XZUtils.isCompressedFilename("x.xz"));
+        assertTrue(XZUtils.isCompressedFileName("x.xz"));
         assertTrue(XZUtils.isCompressedFilename("x-xz"));
+        assertTrue(XZUtils.isCompressedFileName("x-xz"));
 
         assertFalse(XZUtils.isCompressedFilename("xxgz"));
+        assertFalse(XZUtils.isCompressedFileName("xxgz"));
         assertFalse(XZUtils.isCompressedFilename("xzz"));
+        assertFalse(XZUtils.isCompressedFileName("xzz"));
         assertFalse(XZUtils.isCompressedFilename("xaz"));
+        assertFalse(XZUtils.isCompressedFileName("xaz"));
 
         assertFalse(XZUtils.isCompressedFilename("x.txz "));
+        assertFalse(XZUtils.isCompressedFileName("x.txz "));
         assertFalse(XZUtils.isCompressedFilename("x.txz\n"));
+        assertFalse(XZUtils.isCompressedFileName("x.txz\n"));
         assertFalse(XZUtils.isCompressedFilename("x.txz.y"));
+        assertFalse(XZUtils.isCompressedFileName("x.txz.y"));
     }
 
     @Test