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:44:58 UTC

[commons-imaging] branch master updated (3e0e5b11 -> d27591b4)

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

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git


    from 3e0e5b11 Unify input processing
     new fe37e0fd Simplify internals
     new 6f5adba6 Replace custom method with toString()
     new dfa1c9a6 Remove unused method
     new d27591b4 Rename method

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/imaging/bytesource/ByteSource.java   | 13 +++++--------
 .../apache/commons/imaging/bytesource/ByteSourceArray.java  |  6 +-----
 .../apache/commons/imaging/bytesource/ByteSourceFile.java   |  7 +------
 .../commons/imaging/bytesource/ByteSourceInputStream.java   |  2 +-
 .../apache/commons/imaging/formats/bmp/BmpImageParser.java  |  2 +-
 .../apache/commons/imaging/formats/gif/GifImageParser.java  |  2 +-
 .../apache/commons/imaging/formats/ico/IcoImageParser.java  |  2 +-
 .../commons/imaging/formats/tiff/TiffImageParser.java       |  2 +-
 .../org/apache/commons/imaging/formats/tiff/TiffReader.java |  6 +++---
 .../org/apache/commons/imaging/icc/IccProfileParser.java    |  2 +-
 10 files changed, 16 insertions(+), 28 deletions(-)


[commons-imaging] 04/04: Rename method

Posted by gg...@apache.org.
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 d27591b4be6b96a8cc67c286df46c75e7f0833e5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 1 14:44:54 2023 -0400

    Rename method
---
 src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java | 2 +-
 .../java/org/apache/commons/imaging/bytesource/ByteSourceArray.java | 2 +-
 .../java/org/apache/commons/imaging/bytesource/ByteSourceFile.java  | 2 +-
 .../apache/commons/imaging/bytesource/ByteSourceInputStream.java    | 2 +-
 .../java/org/apache/commons/imaging/formats/ico/IcoImageParser.java | 2 +-
 .../org/apache/commons/imaging/formats/tiff/TiffImageParser.java    | 2 +-
 .../java/org/apache/commons/imaging/formats/tiff/TiffReader.java    | 6 +++---
 src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java  | 2 +-
 8 files changed, 10 insertions(+), 10 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 5583935e..0e83a67c 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
@@ -50,7 +50,7 @@ public abstract class ByteSource {
         this.fileName = fileName;
     }
 
-    public abstract byte[] getBlock(long from, int length) throws IOException;
+    public abstract byte[] getByteArray(long from, int length) throws IOException;
 
     public final String getFileName() {
         return fileName;
diff --git a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java
index b0516863..11693643 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java
@@ -32,7 +32,7 @@ class ByteSourceArray extends ByteSource {
     }
 
     @Override
-    public byte[] getBlock(final long from, final int length) throws ImagingException {
+    public byte[] getByteArray(final long from, final int length) throws ImagingException {
         int start;
         try {
             start = Math.toIntExact(from);
diff --git a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java
index 0af10f50..1accc3a9 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java
@@ -36,7 +36,7 @@ class ByteSourceFile extends ByteSource {
     }
 
     @Override
-    public byte[] getBlock(final long from, final int length) throws IOException {
+    public byte[] getByteArray(final long from, final int length) throws IOException {
         try (RandomAccessFile raf = RandomAccessFileMode.READ_ONLY.create(file)) {
             // We include a separate check for int overflow.
             if ((from < 0) || (length < 0) || (from + length < 0) || (from + length > raf.length())) {
diff --git a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceInputStream.java b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceInputStream.java
index e53217ae..18ee478b 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceInputStream.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceInputStream.java
@@ -180,7 +180,7 @@ class ByteSourceInputStream extends ByteSource {
     }
 
     @Override
-    public byte[] getBlock(final long from, final int length) throws IOException {
+    public byte[] getByteArray(final long from, final int length) throws IOException {
         // We include a separate check for int overflow.
         if ((from < 0) || (length < 0)
                 || (from + length < 0)
diff --git a/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java b/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
index c2a9b90e..520bd045 100644
--- a/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
@@ -589,7 +589,7 @@ public class IcoImageParser extends ImageParser<IcoImagingParameters> {
 
             final IconData[] fIconDatas = Allocator.array(fileHeader.iconCount, IconData[]::new, IconData.SHALLOW_SIZE);
             for (int i = 0; i < fileHeader.iconCount; i++) {
-                final byte[] iconData = byteSource.getBlock(
+                final byte[] iconData = byteSource.getByteArray(
                         fIconInfos[i].imageOffset, fIconInfos[i].imageSize);
                 fIconDatas[i] = readIconData(iconData, fIconInfos[i]);
             }
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
index 961392b5..a89ffb05 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
@@ -96,7 +96,7 @@ public class TiffImageParser extends ImageParser<TiffImagingParameters> implemen
             final TiffDirectory directory = contents.directories.get(i);
             final List<ImageDataElement> dataElements = directory.getTiffRawImageDataElements();
             for (final ImageDataElement element : dataElements) {
-                final byte[] bytes = byteSource.getBlock(element.offset,
+                final byte[] bytes = byteSource.getByteArray(element.offset,
                         element.length);
                 result.add(bytes);
             }
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
index d8d3bb5c..bec96508 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
@@ -137,7 +137,7 @@ public class TiffReader extends BinaryFileParser {
         if (offset + length > byteSource.getLength()) {
             length = (int) (byteSource.getLength() - offset);
         }
-        final byte[] data = byteSource.getBlock(offset, length);
+        final byte[] data = byteSource.getByteArray(offset, length);
         // check if the last read byte is actually the end of the image data
         if (strict &&
                 (length < 2 ||
@@ -165,7 +165,7 @@ public class TiffReader extends BinaryFileParser {
 
         for (int i = 0; i < elements.size(); i++) {
             final TiffDirectory.ImageDataElement element = elements.get(i);
-            final byte[] bytes = byteSource.getBlock(element.offset, element.length);
+            final byte[] bytes = byteSource.getByteArray(element.offset, element.length);
             data[i] = new TiffImageData.Data(element.offset, element.length, bytes);
         }
 
@@ -339,7 +339,7 @@ public class TiffReader extends BinaryFileParser {
                         // corrupt field, ignore it
                         continue;
                     }
-                    value = byteSource.getBlock(offset, (int) valueLength);
+                    value = byteSource.getByteArray(offset, (int) valueLength);
                 } else {
                     value = offsetBytes;
                 }
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 1a1b7a9a..3479b6ce 100644
--- a/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
+++ b/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
@@ -57,7 +57,7 @@ public class IccProfileParser extends BinaryFileParser {
         }
         //
         for (final IccTag tag : result.getTags()) {
-            final byte[] bytes = byteSource.getBlock(tag.offset, tag.length);
+            final byte[] bytes = byteSource.getByteArray(tag.offset, tag.length);
             // Debug.debug("bytes: " + bytes.length);
             tag.setData(bytes);
             // tag.dump("\t" + i + ": ");


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

Posted by gg...@apache.org.
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);
 


[commons-imaging] 01/04: Simplify internals

Posted by gg...@apache.org.
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 fe37e0fd02354a4a587b2a04d22bf8086f0ce120
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 1 14:26:59 2023 -0400

    Simplify internals
---
 src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java   | 2 +-
 .../java/org/apache/commons/imaging/bytesource/ByteSourceArray.java   | 4 ----
 2 files changed, 1 insertion(+), 5 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 6e6f6115..e60045f1 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
@@ -25,7 +25,7 @@ import org.apache.commons.imaging.common.BinaryFunctions;
 public abstract class ByteSource {
 
     public static ByteSource array(final byte[] array) {
-        return new ByteSourceArray(array);
+        return new ByteSourceArray(array, null);
     }
 
     public static ByteSource array(final byte[] array, final String name) {
diff --git a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java
index 326fc3d7..b0516863 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceArray.java
@@ -26,10 +26,6 @@ class ByteSourceArray extends ByteSource {
 
     private final byte[] bytes;
 
-    ByteSourceArray(final byte[] bytes) {
-        this(bytes, null);
-    }
-
     ByteSourceArray(final byte[] bytes, final String fileName) {
         super(fileName);
         this.bytes = bytes;


[commons-imaging] 03/04: Remove unused method

Posted by gg...@apache.org.
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 dfa1c9a6996b8bca9a0a3fdfe733e829d8de46e4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 1 14:39:26 2023 -0400

    Remove unused method
---
 src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java  | 4 ----
 .../java/org/apache/commons/imaging/bytesource/ByteSourceFile.java   | 5 -----
 2 files changed, 9 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 24763af5..5583935e 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
@@ -82,10 +82,6 @@ public abstract class ByteSource {
      */
     public abstract long getLength() throws IOException;
 
-    public boolean isFile() {
-        return false;
-    }
-
     @Override
     public String toString() {
         return getClass().getSimpleName() + "[" + getFileName() + "]";
diff --git a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java
index 4e8fd60e..0af10f50 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSourceFile.java
@@ -58,9 +58,4 @@ class ByteSourceFile extends ByteSource {
         return file.length();
     }
 
-    @Override
-    public boolean isFile() {
-        return true;
-    }
-
 }