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-codec.git

commit 732eb9173e9be8a8244f62bf443ec208946ed3f2
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Apr 12 07:44:08 2026 -0400

    Sort members
---
 .../apache/commons/codec/binary/BaseNCodec.java    |  22 +--
 .../commons/codec/digest/GitIdentifiers.java       | 155 +++++++++++----------
 2 files changed, 90 insertions(+), 87 deletions(-)

diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java 
b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
index cc47f0e7..fa634058 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
@@ -414,6 +414,17 @@ public abstract class BaseNCodec implements BinaryEncoder, 
BinaryDecoder {
         return array == null ? 0 : array.length;
     }
 
+    /**
+     * Tests whether or not the {@code value} is in the given {@code table}.
+     *
+     * @param value The value to test.
+     * @param table The table to test against.
+     * @return {@code true} if the value is in the table, {@code false} 
otherwise.
+     */
+    static boolean isInAlphabet(final byte value, final byte[] table) {
+        return value >= 0 && value < table.length && table[value] != -1;
+    }
+
     /**
      * Checks if a byte value is whitespace or not.
      *
@@ -450,17 +461,6 @@ public abstract class BaseNCodec implements BinaryEncoder, 
BinaryDecoder {
         return b;
     }
 
-    /**
-     * Tests whether or not the {@code value} is in the given {@code table}.
-     *
-     * @param value The value to test.
-     * @param table The table to test against.
-     * @return {@code true} if the value is in the table, {@code false} 
otherwise.
-     */
-    static boolean isInAlphabet(final byte value, final byte[] table) {
-        return value >= 0 && value < table.length && table[value] != -1;
-    }
-
     /**
      * Deprecated: Will be removed in 2.0.
      * <p>
diff --git a/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java 
b/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
index 6b4c0ccf..94f0f0c6 100644
--- a/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
+++ b/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
@@ -46,59 +46,6 @@ import java.util.TreeSet;
  */
 public class GitIdentifiers {
 
-    /**
-     * The type of a Git tree entry, which maps to a Unix file-mode string.
-     *
-     * <p>Git encodes the file type and permission bits as an ASCII octal 
string that precedes the entry name in the binary tree format. The values 
defined here
-     * cover the four entry types that Git itself produces.</p>
-     */
-    public enum FileMode {
-
-        /**
-         * A sub-directory (Git sub-tree).
-         */
-        DIRECTORY("40000"),
-
-        /**
-         * An executable file.
-         */
-        EXECUTABLE("100755"),
-
-        /**
-         * A regular (non-executable) file.
-         */
-        REGULAR("100644"),
-
-        /**
-         * A symbolic link.
-         */
-        SYMBOLIC_LINK("120000");
-
-        /**
-         * The octal mode as used by Git.
-         */
-        private final String mode;
-
-        /**
-         * Serialized {@code mode}: since this is mutable, it must remain 
private.
-         */
-        private final byte[] modeBytes;
-
-        FileMode(final String mode) {
-            this.mode = mode;
-            this.modeBytes = mode.getBytes(StandardCharsets.US_ASCII);
-        }
-
-        /**
-         * Gets the octal mode as used by Git.
-         *
-         * @return The octal mode
-         */
-        public String getMode() {
-            return mode;
-        }
-    }
-
     /**
      * Represents a single entry in a Git tree object.
      *
@@ -121,16 +68,19 @@ public class GitIdentifiers {
          * The entry name (file or directory name, no path separator).
          */
         private final String name;
+
         /**
          * The raw object id of the referenced blob or sub-tree.
          */
         private final byte[] rawObjectId;
+
         /**
          * The key used for ordering entries within a tree object.
          *
          * <p>>Git appends {@code '/'} to directory names before comparing.</p>
          */
         private final String sortKey;
+
         /**
          * The Git object type, which determines the Unix file-mode prefix.
          */
@@ -177,6 +127,59 @@ public class GitIdentifiers {
 
     }
 
+    /**
+     * The type of a Git tree entry, which maps to a Unix file-mode string.
+     *
+     * <p>Git encodes the file type and permission bits as an ASCII octal 
string that precedes the entry name in the binary tree format. The values 
defined here
+     * cover the four entry types that Git itself produces.</p>
+     */
+    public enum FileMode {
+
+        /**
+         * A sub-directory (Git sub-tree).
+         */
+        DIRECTORY("40000"),
+
+        /**
+         * An executable file.
+         */
+        EXECUTABLE("100755"),
+
+        /**
+         * A regular (non-executable) file.
+         */
+        REGULAR("100644"),
+
+        /**
+         * A symbolic link.
+         */
+        SYMBOLIC_LINK("120000");
+
+        /**
+         * The octal mode as used by Git.
+         */
+        private final String mode;
+
+        /**
+         * Serialized {@code mode}: since this is mutable, it must remain 
private.
+         */
+        private final byte[] modeBytes;
+
+        FileMode(final String mode) {
+            this.mode = mode;
+            this.modeBytes = mode.getBytes(StandardCharsets.US_ASCII);
+        }
+
+        /**
+         * Gets the octal mode as used by Git.
+         *
+         * @return The octal mode
+         */
+        public String getMode() {
+            return mode;
+        }
+    }
+
     /**
      * Builds a Git tree identifier for a virtual directory structure, such as 
the contents of
      * an archive.
@@ -191,7 +194,7 @@ public class GitIdentifiers {
             byte[] get() throws IOException;
         }
 
-        private static String requireNoParentTraversal(String name) {
+        private static String requireNoParentTraversal(final String name) {
             if ("..".equals(name)) {
                 throw new IllegalArgumentException("Path component not 
allowed: " + name);
             }
@@ -225,24 +228,6 @@ public class GitIdentifiers {
             return current;
         }
 
-        /**
-         * Adds a file entry at the given path within this tree, streaming 
content without buffering.
-         *
-         * <p>If {@code name} contains {@code '/'}, intermediate 
subdirectories are created automatically.</p>
-         *
-         * <p>The stream is eagerly drained.</p>
-         *
-         * @param mode     The file mode (e.g. {@link FileMode#REGULAR}).
-         * @param name The relative path of the entry in normalized form(may 
contain {@code '/'}).
-         * @param dataSize The exact number of bytes in {@code data}.
-         * @param data     The file content.
-         * @throws IOException If the stream cannot be read.
-         * @throws IllegalArgumentException If any path component is {@code 
".."}.
-         */
-        public void addFile(final FileMode mode, final String name, final long 
dataSize, final InputStream data) throws IOException {
-            addFile(mode, name, () -> blobId(messageDigest, dataSize, data));
-        }
-
         private void addFile(final FileMode mode, final String name, final 
BlobIdSupplier blobId) throws IOException {
             final int slash = name.lastIndexOf('/');
             if (slash < 0) {
@@ -267,6 +252,24 @@ public class GitIdentifiers {
             addFile(mode, name, () -> blobId(messageDigest, data));
         }
 
+        /**
+         * Adds a file entry at the given path within this tree, streaming 
content without buffering.
+         *
+         * <p>If {@code name} contains {@code '/'}, intermediate 
subdirectories are created automatically.</p>
+         *
+         * <p>The stream is eagerly drained.</p>
+         *
+         * @param mode     The file mode (e.g. {@link FileMode#REGULAR}).
+         * @param name The relative path of the entry in normalized form(may 
contain {@code '/'}).
+         * @param dataSize The exact number of bytes in {@code data}.
+         * @param data     The file content.
+         * @throws IOException If the stream cannot be read.
+         * @throws IllegalArgumentException If any path component is {@code 
".."}.
+         */
+        public void addFile(final FileMode mode, final String name, final long 
dataSize, final InputStream data) throws IOException {
+            addFile(mode, name, () -> blobId(messageDigest, dataSize, data));
+        }
+
         /**
          * Adds a symbolic link entry at the give path within this tree.
          *
@@ -369,6 +372,10 @@ public class GitIdentifiers {
         return DigestUtils.updateDigest(messageDigest, data).digest();
     }
 
+    private static byte[] getGitBlobPrefix(final long dataSize) {
+        return getGitPrefix("blob", dataSize);
+    }
+
     private static FileMode getGitDirectoryEntryType(final Path path) {
         // Symbolic links first
         if (Files.isSymbolicLink(path)) {
@@ -383,10 +390,6 @@ public class GitIdentifiers {
         return FileMode.REGULAR;
     }
 
-    private static byte[] getGitBlobPrefix(final long dataSize) {
-        return getGitPrefix("blob", dataSize);
-    }
-
     private static byte[] getGitPrefix(final String type, final long dataSize) 
{
         return (type + " " + dataSize + "\0").getBytes(StandardCharsets.UTF_8);
     }

Reply via email to