Repository: commons-compress Updated Branches: refs/heads/master 7a8f3c379 -> 69f38e818
Deprecate charset constants superseded by Java 7 Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/69f38e81 Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/69f38e81 Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/69f38e81 Branch: refs/heads/master Commit: 69f38e81872d70705fd7919df3d771f28c22dadc Parents: 7a8f3c3 Author: Matt Sicker <boa...@gmail.com> Authored: Sat Apr 21 13:50:42 2018 -0500 Committer: Matt Sicker <boa...@gmail.com> Committed: Sat Apr 21 13:50:42 2018 -0500 ---------------------------------------------------------------------- .../archivers/zip/ZipEncodingHelper.java | 6 ++-- .../apache/commons/compress/utils/Charsets.java | 21 +++++++++----- .../commons/compress/utils/CharsetsTest.java | 30 -------------------- 3 files changed, 17 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/69f38e81/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java index 8cfe606..8aeb789 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java @@ -20,8 +20,8 @@ package org.apache.commons.compress.archivers.zip; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.charset.UnsupportedCharsetException; -import org.apache.commons.compress.utils.Charsets; /** * Static helper functions for robustly encoding filenames in zip files. @@ -73,10 +73,10 @@ public abstract class ZipEncodingHelper { // check platform's default encoding charsetName = Charset.defaultCharset().name(); } - if (Charsets.UTF_8.name().equalsIgnoreCase(charsetName)) { + if (StandardCharsets.UTF_8.name().equalsIgnoreCase(charsetName)) { return true; } - for (final String alias : Charsets.UTF_8.aliases()) { + for (final String alias : StandardCharsets.UTF_8.aliases()) { if (alias.equalsIgnoreCase(charsetName)) { return true; } http://git-wip-us.apache.org/repos/asf/commons-compress/blob/69f38e81/src/main/java/org/apache/commons/compress/utils/Charsets.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/utils/Charsets.java b/src/main/java/org/apache/commons/compress/utils/Charsets.java index fa9fa9a..9f5240a 100644 --- a/src/main/java/org/apache/commons/compress/utils/Charsets.java +++ b/src/main/java/org/apache/commons/compress/utils/Charsets.java @@ -19,6 +19,7 @@ package org.apache.commons.compress.utils; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * Charsets required of every implementation of the Java platform. @@ -51,8 +52,8 @@ import java.nio.charset.Charset; * component, it is not foreseen that Commons Compress would be made to depend on another Commons component.</p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @see StandardCharsets * @since 1.4 - * @version $Id$ */ public class Charsets { @@ -94,8 +95,9 @@ public class Charsets { * </p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @deprecated replaced by {@link StandardCharsets} in Java 7 */ - public static final Charset ISO_8859_1 = Charset.forName(CharsetNames.ISO_8859_1); + public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1; /** * <p> @@ -106,8 +108,9 @@ public class Charsets { * </p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @deprecated replaced by {@link StandardCharsets} in Java 7 */ - public static final Charset US_ASCII = Charset.forName(CharsetNames.US_ASCII); + public static final Charset US_ASCII = StandardCharsets.US_ASCII; /** * <p> @@ -119,8 +122,9 @@ public class Charsets { * </p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @deprecated replaced by {@link StandardCharsets} in Java 7 */ - public static final Charset UTF_16 = Charset.forName(CharsetNames.UTF_16); + public static final Charset UTF_16 = StandardCharsets.UTF_16; /** * <p> @@ -131,8 +135,9 @@ public class Charsets { * </p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @deprecated replaced by {@link StandardCharsets} in Java 7 */ - public static final Charset UTF_16BE = Charset.forName(CharsetNames.UTF_16BE); + public static final Charset UTF_16BE = StandardCharsets.UTF_16BE; /** * <p> @@ -143,8 +148,9 @@ public class Charsets { * </p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @deprecated replaced by {@link StandardCharsets} in Java 7 */ - public static final Charset UTF_16LE = Charset.forName(CharsetNames.UTF_16LE); + public static final Charset UTF_16LE = StandardCharsets.UTF_16LE; /** * <p> @@ -155,6 +161,7 @@ public class Charsets { * </p> * * @see <a href="https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a> + * @deprecated replaced by {@link StandardCharsets} in Java 7 */ - public static final Charset UTF_8 = Charset.forName(CharsetNames.UTF_8); + public static final Charset UTF_8 = StandardCharsets.UTF_8; } http://git-wip-us.apache.org/repos/asf/commons-compress/blob/69f38e81/src/test/java/org/apache/commons/compress/utils/CharsetsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/utils/CharsetsTest.java b/src/test/java/org/apache/commons/compress/utils/CharsetsTest.java index 5823edc..822b413 100644 --- a/src/test/java/org/apache/commons/compress/utils/CharsetsTest.java +++ b/src/test/java/org/apache/commons/compress/utils/CharsetsTest.java @@ -38,34 +38,4 @@ public class CharsetsTest { Assert.assertEquals(Charset.forName("UTF-8"), Charsets.toCharset(Charset.forName("UTF-8"))); } - @Test - public void testIso8859_1() { - Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name()); - } - - @Test - public void testUsAscii() { - Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name()); - } - - @Test - public void testUtf16() { - Assert.assertEquals("UTF-16", Charsets.UTF_16.name()); - } - - @Test - public void testUtf16Be() { - Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name()); - } - - @Test - public void testUtf16Le() { - Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name()); - } - - @Test - public void testUtf8() { - Assert.assertEquals("UTF-8", Charsets.UTF_8.name()); - } - }