You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/01 18:45:00 UTC

[commons-imaging] 02/04: Replace custom method with toString()

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 6f5adba6e180c9a2c90ed2873260334d3f4937d7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 1 14:39:12 2023 -0400

    Replace custom method with toString()
---
 .../java/org/apache/commons/imaging/bytesource/ByteSource.java   | 9 +++++----
 .../org/apache/commons/imaging/formats/bmp/BmpImageParser.java   | 2 +-
 .../org/apache/commons/imaging/formats/gif/GifImageParser.java   | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
index e60045f1..24763af5 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
@@ -52,10 +52,6 @@ public abstract class ByteSource {
 
     public abstract byte[] getBlock(long from, int length) throws IOException;
 
-    public String getDescription() {
-        return getClass().getSimpleName() + "[" + getFileName() + "]";
-    }
-
     public final String getFileName() {
         return fileName;
     }
@@ -90,4 +86,9 @@ public abstract class ByteSource {
         return false;
     }
 
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + "[" + getFileName() + "]";
+    }
+
 }
diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
index 2694fb0e..2a5fb4cf 100644
--- a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
@@ -159,7 +159,7 @@ public class BmpImageParser extends ImageParser<BmpImagingParameters> {
 
     @Override
     public FormatCompliance getFormatCompliance(final ByteSource byteSource) throws ImagingException, IOException {
-        final FormatCompliance result = new FormatCompliance(byteSource.getDescription());
+        final FormatCompliance result = new FormatCompliance(byteSource.toString());
 
         try (InputStream is = byteSource.getInputStream()) {
             readImageContents(is, result);
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 9754c918..ce971f82 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
@@ -391,7 +391,7 @@ public class GifImageParser extends ImageParser<GifImagingParameters> implements
     public FormatCompliance getFormatCompliance(final ByteSource byteSource)
             throws ImagingException, IOException {
         final FormatCompliance result = new FormatCompliance(
-                byteSource.getDescription());
+                byteSource.toString());
 
         readFile(byteSource, false, result);