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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8df502d23 Wrap calculations to show how they are constructed
8df502d23 is described below

commit 8df502d23606a66e7553c3cf30e21b97b7dd4b31
Author: Sebb <[email protected]>
AuthorDate: Sun Feb 8 15:03:44 2026 +0000

    Wrap calculations to show how they are constructed
---
 .../java/org/apache/commons/io/EndianUtils.java    | 39 ++++++++++++++++------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/EndianUtils.java 
b/src/main/java/org/apache/commons/io/EndianUtils.java
index cae06b834..b6cb2ebd8 100644
--- a/src/main/java/org/apache/commons/io/EndianUtils.java
+++ b/src/main/java/org/apache/commons/io/EndianUtils.java
@@ -119,7 +119,8 @@ public static float readSwappedFloat(final InputStream 
input) throws IOException
      */
     public static int readSwappedInteger(final byte[] data, final int offset) {
         validateByteArrayOffset(data, offset, Integer.SIZE / Byte.SIZE);
-        return ((data[offset + 0] & 0xff) << 0) +
+        return
+            ((data[offset + 0] & 0xff) << 0) +
             ((data[offset + 1] & 0xff) << 8) +
             ((data[offset + 2] & 0xff) << 16) +
             ((data[offset + 3] & 0xff) << 24);
@@ -137,7 +138,11 @@ public static int readSwappedInteger(final InputStream 
input) throws IOException
         final int value2 = read(input);
         final int value3 = read(input);
         final int value4 = read(input);
-        return ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 
0xff) << 16) + ((value4 & 0xff) << 24);
+        return
+            ((value1 & 0xff) << 0) +
+            ((value2 & 0xff) << 8) +
+            ((value3 & 0xff) << 16) +
+            ((value4 & 0xff) << 24);
     }
 
     /**
@@ -180,7 +185,10 @@ public static long readSwappedLong(final InputStream 
input) throws IOException {
      */
     public static short readSwappedShort(final byte[] data, final int offset) {
         validateByteArrayOffset(data, offset, Short.SIZE / Byte.SIZE);
-        return (short) (((data[offset + 0] & 0xff) << 0) + ((data[offset + 1] 
& 0xff) << 8));
+        return (short) (
+            ((data[offset + 0] & 0xff) << 0) +
+            ((data[offset + 1] & 0xff) << 8)
+        );
     }
 
     /**
@@ -191,7 +199,10 @@ public static short readSwappedShort(final byte[] data, 
final int offset) {
      * @throws IOException in case of an I/O problem.
      */
     public static short readSwappedShort(final InputStream input) throws 
IOException {
-        return (short) (((read(input) & 0xff) << 0) + ((read(input) & 0xff) << 
8));
+        return (short) (
+            ((read(input) & 0xff) << 0) +
+            ((read(input) & 0xff) << 8)
+        );
     }
 
     /**
@@ -206,8 +217,8 @@ public static short readSwappedShort(final InputStream 
input) throws IOException
     public static long readSwappedUnsignedInteger(final byte[] data, final int 
offset) {
         validateByteArrayOffset(data, offset, Integer.SIZE / Byte.SIZE);
         final long low = ((data[offset + 0] & 0xff) << 0) +
-                     ((data[offset + 1] & 0xff) << 8) +
-                     ((data[offset + 2] & 0xff) << 16);
+                         ((data[offset + 1] & 0xff) << 8) +
+                         ((data[offset + 2] & 0xff) << 16);
         final long high = data[offset + 3] & 0xff;
         return (high << 24) + (0xffffffffL & low);
     }
@@ -224,7 +235,9 @@ public static long readSwappedUnsignedInteger(final 
InputStream input) throws IO
         final int value2 = read(input);
         final int value3 = read(input);
         final int value4 = read(input);
-        final long low = ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + 
((value3 & 0xff) << 16);
+        final long low = ((value1 & 0xff) << 0) +
+                         ((value2 & 0xff) << 8) +
+                         ((value3 & 0xff) << 16);
         final long high = value4 & 0xff;
         return (high << 24) + (0xffffffffL & low);
     }
@@ -240,7 +253,8 @@ public static long readSwappedUnsignedInteger(final 
InputStream input) throws IO
      */
     public static int readSwappedUnsignedShort(final byte[] data, final int 
offset) {
         validateByteArrayOffset(data, offset, Short.SIZE / Byte.SIZE);
-        return ((data[offset + 0] & 0xff) << 0) + ((data[offset + 1] & 0xff) 
<< 8);
+        return ((data[offset + 0] & 0xff) << 0) +
+               ((data[offset + 1] & 0xff) << 8);
     }
 
     /**
@@ -254,7 +268,8 @@ public static int readSwappedUnsignedShort(final 
InputStream input) throws IOExc
         final int value1 = read(input);
         final int value2 = read(input);
 
-        return ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8);
+        return ((value1 & 0xff) << 0) +
+               ((value2 & 0xff) << 8);
     }
 
     /**
@@ -320,8 +335,10 @@ public static long swapLong(final long value) {
      * @return the converted value.
      */
     public static short swapShort(final short value) {
-        return (short) (((value >> 0 & 0xff) << 8) +
-            ((value >> 8 & 0xff) << 0));
+        return (short) (
+            ((value >> 0 & 0xff) << 8) +
+            ((value >> 8 & 0xff) << 0)
+        );
     }
 
     /**

Reply via email to