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

commit f2d0798e8e1f5aba99796d141cb2cba2d9822e50
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Wed May 31 18:20:02 2023 -0400

    Only use static imports for JUnit
    
    - Rename logging method
    - Rename parameters
---
 .../commons/imaging/common/BinaryFunctions.java    | 30 +++++++++++-----------
 .../imaging/formats/gif/GifImageParser.java        | 12 ++++-----
 .../imaging/formats/png/PngImageParser.java        | 23 +++++++----------
 .../commons/imaging/icc/IccProfileParser.java      | 28 ++++++++++----------
 4 files changed, 44 insertions(+), 49 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java 
b/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
index 0d3c7764..ba9a2806 100644
--- a/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
+++ b/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
@@ -98,19 +98,19 @@ public final class BinaryFunctions {
         return slice(bytes, 0, count);
     }
 
-    public static void printByteBits(final String msg, final byte i) {
+    public static void logByteBits(final String msg, final byte i) {
         LOGGER.finest(msg + ": '" + Integer.toBinaryString(0xff & i));
     }
 
-    public static void printCharQuad(final PrintWriter pw, final String msg, 
final int i) {
-        pw.println(msg + ": '" + (char) (0xff & (i >> 24))
+    public static void logCharQuad(final String msg, final int i) {
+        LOGGER.finest(msg + ": '" + (char) (0xff & (i >> 24))
                 + (char) (0xff & (i >> 16)) + (char) (0xff & (i >> 8))
                 + (char) (0xff & (i >> 0)) + "'");
 
     }
 
-    public static void printCharQuad(final String msg, final int i) {
-        LOGGER.finest(msg + ": '" + (char) (0xff & (i >> 24))
+    public static void printCharQuad(final PrintWriter pw, final String msg, 
final int i) {
+        pw.println(msg + ": '" + (char) (0xff & (i >> 24))
                 + (char) (0xff & (i >> 16)) + (char) (0xff & (i >> 8))
                 + (char) (0xff & (i >> 0)) + "'");
 
@@ -299,13 +299,13 @@ public final class BinaryFunctions {
         return result;
     }
 
-    public static boolean startsWith(final byte[] haystack, final 
BinaryConstant needle) {
-        if (haystack == null || haystack.length < needle.size()) {
+    public static boolean startsWith(final byte[] buffer, final BinaryConstant 
search) {
+        if (buffer == null || buffer.length < search.size()) {
             return false;
         }
 
-        for (int i = 0; i < needle.size(); i++) {
-            if (haystack[i] != needle.get(i)) {
+        for (int i = 0; i < search.size(); i++) {
+            if (buffer[i] != search.get(i)) {
                 return false;
             }
         }
@@ -313,19 +313,19 @@ public final class BinaryFunctions {
         return true;
     }
 
-    public static boolean startsWith(final byte[] haystack, final byte[] 
needle) {
-        if (needle == null) {
+    public static boolean startsWith(final byte[] buffer, final byte[] search) 
{
+        if (search == null) {
             return false;
         }
-        if (haystack == null) {
+        if (buffer == null) {
             return false;
         }
-        if (needle.length > haystack.length) {
+        if (search.length > buffer.length) {
             return false;
         }
 
-        for (int i = 0; i < needle.length; i++) {
-            if (needle[i] != haystack[i]) {
+        for (int i = 0; i < search.length; i++) {
+            if (search[i] != buffer[i]) {
                 return false;
             }
         }
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java 
b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
index 4bb221b3..9754c918 100644
--- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
@@ -17,8 +17,8 @@
 package org.apache.commons.imaging.formats.gif;
 
 import static org.apache.commons.imaging.common.BinaryFunctions.compareBytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.printByteBits;
-import static org.apache.commons.imaging.common.BinaryFunctions.printCharQuad;
+import static org.apache.commons.imaging.common.BinaryFunctions.logByteBits;
+import static org.apache.commons.imaging.common.BinaryFunctions.logCharQuad;
 import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;
 import static org.apache.commons.imaging.common.BinaryFunctions.readByte;
 import static org.apache.commons.imaging.common.BinaryFunctions.readBytes;
@@ -763,9 +763,9 @@ public class GifImageParser extends 
ImageParser<GifImagingParameters> implements
         }
 
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("identifier: ", ((identifier1 << 16)
+            logCharQuad("identifier: ", ((identifier1 << 16)
                     | (identifier2 << 8) | (identifier3 << 0)));
-            printCharQuad("version: ",
+            logCharQuad("version: ",
                     ((version1 << 16) | (version2 << 8) | (version3 << 0)));
         }
 
@@ -787,7 +787,7 @@ public class GifImageParser extends 
ImageParser<GifImagingParameters> implements
                 "Not a Valid GIF File");
 
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printByteBits("PackedFields bits", packedFields);
+            logByteBits("PackedFields bits", packedFields);
         }
 
         final boolean globalColorTableFlag = ((packedFields & 128) > 0);
@@ -841,7 +841,7 @@ public class GifImageParser extends 
ImageParser<GifImagingParameters> implements
         }
 
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printByteBits("PackedFields bits", packedFields);
+            logByteBits("PackedFields bits", packedFields);
         }
 
         final boolean localColorTableFlag = (((packedFields >> 7) & 1) > 0);
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java 
b/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
index c006d6ff..5b6fa947 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
@@ -16,12 +16,6 @@
  */
 package org.apache.commons.imaging.formats.png;
 
-import static org.apache.commons.imaging.common.BinaryFunctions.printCharQuad;
-import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
-import static 
org.apache.commons.imaging.common.BinaryFunctions.readAndVerifyBytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.readBytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.skipBytes;
-
 import java.awt.Dimension;
 import java.awt.color.ColorSpace;
 import java.awt.color.ICC_ColorSpace;
@@ -48,6 +42,7 @@ import org.apache.commons.imaging.ImageParser;
 import org.apache.commons.imaging.ImagingException;
 import org.apache.commons.imaging.bytesource.ByteSource;
 import org.apache.commons.imaging.common.Allocator;
+import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.GenericImageMetadata;
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.XmpEmbeddable;
@@ -115,7 +110,7 @@ public class PngImageParser extends 
ImageParser<PngImagingParameters>  implement
 
         for (int i = 0; i < chunks.size(); i++) {
             final PngChunk chunk = chunks.get(i);
-            printCharQuad(pw, "\t" + i + ": ", chunk.getChunkType());
+            BinaryFunctions.printCharQuad(pw, "\t" + i + ": ", 
chunk.getChunkType());
         }
 
         pw.println("");
@@ -656,24 +651,24 @@ public class PngImageParser extends 
ImageParser<PngImagingParameters>  implement
         final List<PngChunk> result = new ArrayList<>();
 
         while (true) {
-            final int length = read4Bytes("Length", is, "Not a Valid PNG 
File", getByteOrder());
+            final int length = BinaryFunctions.read4Bytes("Length", is, "Not a 
Valid PNG File", getByteOrder());
             if (length < 0) {
                 throw new ImagingException("Invalid PNG chunk length: " + 
length);
             }
-            final int chunkType = read4Bytes("ChunkType", is, "Not a Valid PNG 
File", getByteOrder());
+            final int chunkType = BinaryFunctions.read4Bytes("ChunkType", is, 
"Not a Valid PNG File", getByteOrder());
 
             if (LOGGER.isLoggable(Level.FINEST)) {
-                printCharQuad("ChunkType", chunkType);
+                BinaryFunctions.logCharQuad("ChunkType", chunkType);
                 debugNumber("Length", length, 4);
             }
             final boolean keep = keepChunk(chunkType, chunkTypes);
 
             byte[] bytes = null;
             if (keep) {
-                bytes = readBytes("Chunk Data", is, length,
+                bytes = BinaryFunctions.readBytes("Chunk Data", is, length,
                         "Not a Valid PNG File: Couldn't read Chunk Data.");
             } else {
-                skipBytes(is, length, "Not a Valid PNG File");
+                BinaryFunctions.skipBytes(is, length, "Not a Valid PNG File");
             }
 
             if (LOGGER.isLoggable(Level.FINEST)) {
@@ -682,7 +677,7 @@ public class PngImageParser extends 
ImageParser<PngImagingParameters>  implement
                 }
             }
 
-            final int crc = read4Bytes("CRC", is, "Not a Valid PNG File", 
getByteOrder());
+            final int crc = BinaryFunctions.read4Bytes("CRC", is, "Not a Valid 
PNG File", getByteOrder());
 
             if (keep) {
                 if (chunkType == ChunkType.iCCP.value) {
@@ -726,7 +721,7 @@ public class PngImageParser extends 
ImageParser<PngImagingParameters>  implement
 
     public void readSignature(final InputStream is) throws ImagingException,
             IOException {
-        readAndVerifyBytes(is, PngConstants.PNG_SIGNATURE,
+        BinaryFunctions.readAndVerifyBytes(is, PngConstants.PNG_SIGNATURE,
                 "Not a Valid PNG Segment: Incorrect Signature");
 
     }
diff --git a/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java 
b/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
index c78ecdf0..1a1b7a9a 100644
--- a/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
+++ b/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.imaging.icc;
 
-import static org.apache.commons.imaging.common.BinaryFunctions.printCharQuad;
+import static org.apache.commons.imaging.common.BinaryFunctions.logCharQuad;
 import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
 import static org.apache.commons.imaging.common.BinaryFunctions.skipBytes;
 
@@ -118,12 +118,12 @@ public class IccProfileParser extends BinaryFileParser {
 
             final int deviceManufacturer = read4Bytes("ProfileFileSignature", 
is, "Not a Valid ICC Profile", getByteOrder());
             if (LOGGER.isLoggable(Level.FINEST)) {
-                printCharQuad("DeviceManufacturer", deviceManufacturer);
+                logCharQuad("DeviceManufacturer", deviceManufacturer);
             }
 
             final int deviceModel = read4Bytes("DeviceModel", is, "Not a Valid 
ICC Profile", getByteOrder());
             if (LOGGER.isLoggable(Level.FINEST)) {
-                printCharQuad("DeviceModel", deviceModel);
+                logCharQuad("DeviceModel", deviceModel);
             }
 
             return deviceManufacturer == IccConstants.IEC && deviceModel == 
IccConstants.sRGB;
@@ -162,7 +162,7 @@ public class IccProfileParser extends BinaryFileParser {
 
         final int cmmTypeSignature = read4Bytes("Signature", is, "Not a Valid 
ICC Profile", getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("CMMTypeSignature", cmmTypeSignature);
+            logCharQuad("CMMTypeSignature", cmmTypeSignature);
         }
 
         final int profileVersion = read4Bytes("ProfileVersion", is, "Not a 
Valid ICC Profile", getByteOrder());
@@ -170,18 +170,18 @@ public class IccProfileParser extends BinaryFileParser {
         final int profileDeviceClassSignature = 
read4Bytes("ProfileDeviceClassSignature", is, "Not a Valid ICC Profile",
                 getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("ProfileDeviceClassSignature", 
profileDeviceClassSignature);
+            logCharQuad("ProfileDeviceClassSignature", 
profileDeviceClassSignature);
         }
 
         final int colorSpace = read4Bytes("ColorSpace", is, "Not a Valid ICC 
Profile", getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("ColorSpace", colorSpace);
+            logCharQuad("ColorSpace", colorSpace);
         }
 
         final int profileConnectionSpace = 
read4Bytes("ProfileConnectionSpace", is, "Not a Valid ICC Profile",
                 getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("ProfileConnectionSpace", profileConnectionSpace);
+            logCharQuad("ProfileConnectionSpace", profileConnectionSpace);
         }
 
         skipBytes(is, 12, "Not a Valid ICC Profile");
@@ -189,35 +189,35 @@ public class IccProfileParser extends BinaryFileParser {
         final int profileFileSignature = read4Bytes("ProfileFileSignature", 
is, "Not a Valid ICC Profile",
                 getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("ProfileFileSignature", profileFileSignature);
+            logCharQuad("ProfileFileSignature", profileFileSignature);
         }
 
         final int primaryPlatformSignature = 
read4Bytes("PrimaryPlatformSignature", is, "Not a Valid ICC Profile",
                 getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("PrimaryPlatformSignature", 
primaryPlatformSignature);
+            logCharQuad("PrimaryPlatformSignature", primaryPlatformSignature);
         }
 
         final int variousFlags = read4Bytes("VariousFlags", is, "Not a Valid 
ICC Profile", getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("VariousFlags", profileFileSignature);
+            logCharQuad("VariousFlags", profileFileSignature);
         }
 
         final int deviceManufacturer = read4Bytes("DeviceManufacturer", is, 
"Not a Valid ICC Profile", getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("DeviceManufacturer", deviceManufacturer);
+            logCharQuad("DeviceManufacturer", deviceManufacturer);
         }
 
         final int deviceModel = read4Bytes("DeviceModel", is, "Not a Valid ICC 
Profile", getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("DeviceModel", deviceModel);
+            logCharQuad("DeviceModel", deviceModel);
         }
 
         skipBytes(is, 8, "Not a Valid ICC Profile");
 
         final int renderingIntent = read4Bytes("RenderingIntent", is, "Not a 
Valid ICC Profile", getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("RenderingIntent", renderingIntent);
+            logCharQuad("RenderingIntent", renderingIntent);
         }
 
         skipBytes(is, 12, "Not a Valid ICC Profile");
@@ -225,7 +225,7 @@ public class IccProfileParser extends BinaryFileParser {
         final int profileCreatorSignature = 
read4Bytes("ProfileCreatorSignature", is, "Not a Valid ICC Profile",
                 getByteOrder());
         if (LOGGER.isLoggable(Level.FINEST)) {
-            printCharQuad("ProfileCreatorSignature", profileCreatorSignature);
+            logCharQuad("ProfileCreatorSignature", profileCreatorSignature);
         }
 
         skipBytes(is, 16, "Not a Valid ICC Profile");

Reply via email to