commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [11/12] commons-compress git commit: move methods around
Date Wed, 05 Jul 2017 15:34:30 GMT
move methods around


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/0065a044
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/0065a044
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/0065a044

Branch: refs/heads/master
Commit: 0065a044e998559df5127a7494953fe863016dca
Parents: fde6670
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Wed Jul 5 17:31:53 2017 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Wed Jul 5 17:31:53 2017 +0200

----------------------------------------------------------------------
 .../compress/archivers/zip/NioZipEncoding.java  | 73 ++++++++++----------
 1 file changed, 36 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/0065a044/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java b/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
index 4b0069f..75787cc 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java
@@ -67,33 +67,6 @@ class NioZipEncoding implements ZipEncoding, HasCharset {
         return enc.canEncode(name);
     }
 
-    private CharsetEncoder newEncoder() {
-        if (useReplacement) {
-            return charset.newEncoder()
-                .onMalformedInput(CodingErrorAction.REPLACE)
-                .onUnmappableCharacter(CodingErrorAction.REPLACE)
-                .replaceWith(REPLACEMENT_BYTES);
-        } else {
-            return charset.newEncoder()
-                .onMalformedInput(CodingErrorAction.REPORT)
-                .onUnmappableCharacter(CodingErrorAction.REPORT);
-        }
-    }
-
-    private CharsetDecoder newDecoder() {
-        if (!useReplacement) {
-            return this.charset.newDecoder()
-                .onMalformedInput(CodingErrorAction.REPORT)
-                .onUnmappableCharacter(CodingErrorAction.REPORT);
-        } else {
-            return  charset.newDecoder()
-                .onMalformedInput(CodingErrorAction.REPLACE)
-                .onUnmappableCharacter(CodingErrorAction.REPLACE)
-                .replaceWith(REPLACEMENT_STRING);
-        }
-    }
-
-
     /**
      * @see ZipEncoding#encode(java.lang.String)
      */
@@ -150,6 +123,16 @@ class NioZipEncoding implements ZipEncoding, HasCharset {
         return out;
     }
 
+    /**
+     * @see
+     * ZipEncoding#decode(byte[])
+     */
+    @Override
+    public String decode(final byte[] data) throws IOException {
+        return newDecoder()
+            .decode(ByteBuffer.wrap(data)).toString();
+    }
+
     private static ByteBuffer encodeFully(CharsetEncoder enc, CharBuffer cb, ByteBuffer out)
{
         while (cb.hasRemaining()) {
             CoderResult result = enc.encode(cb, out, false);
@@ -178,6 +161,32 @@ class NioZipEncoding implements ZipEncoding, HasCharset {
         return cb;
     }
 
+    private CharsetEncoder newEncoder() {
+        if (useReplacement) {
+            return charset.newEncoder()
+                .onMalformedInput(CodingErrorAction.REPLACE)
+                .onUnmappableCharacter(CodingErrorAction.REPLACE)
+                .replaceWith(REPLACEMENT_BYTES);
+        } else {
+            return charset.newEncoder()
+                .onMalformedInput(CodingErrorAction.REPORT)
+                .onUnmappableCharacter(CodingErrorAction.REPORT);
+        }
+    }
+
+    private CharsetDecoder newDecoder() {
+        if (!useReplacement) {
+            return this.charset.newDecoder()
+                .onMalformedInput(CodingErrorAction.REPORT)
+                .onUnmappableCharacter(CodingErrorAction.REPORT);
+        } else {
+            return  charset.newDecoder()
+                .onMalformedInput(CodingErrorAction.REPLACE)
+                .onUnmappableCharacter(CodingErrorAction.REPLACE)
+                .replaceWith(REPLACEMENT_STRING);
+        }
+    }
+
     /**
      * Estimate the initial encoded size (in bytes) for a character buffer.
      * <p>
@@ -207,14 +216,4 @@ class NioZipEncoding implements ZipEncoding, HasCharset {
         return (int) Math.ceil(charCount * enc.averageBytesPerChar());
     }
 
-    /**
-     * @see
-     * ZipEncoding#decode(byte[])
-     */
-    @Override
-    public String decode(final byte[] data) throws IOException {
-        return newDecoder()
-            .decode(ByteBuffer.wrap(data)).toString();
-    }
-
 }


Mime
View raw message