diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java index 6a693b9c3..2a2b88705 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java @@ -26,7 +26,7 @@ import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.common.ImageBuilder; import org.apache.commons.imaging.common.PackBits; -import org.apache.commons.imaging.common.itu_t4.T4AndT6Compression; +import org.apache.commons.imaging.formats.tiff.itu_t4.T4AndT6Compression; import org.apache.commons.imaging.common.mylzw.MyLzwDecompressor; import org.apache.commons.imaging.formats.tiff.TiffDirectory; import org.apache.commons.imaging.formats.tiff.TiffField; diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/BitArrayOutputStream.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/BitArrayOutputStream.java similarity index 87% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/BitArrayOutputStream.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/BitArrayOutputStream.java index 1f71ea6a8..caa515ec5 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/BitArrayOutputStream.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/BitArrayOutputStream.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; import java.io.OutputStream; @@ -22,25 +22,25 @@ * Output stream writing to a byte array, and capable * of writing 1 bit at a time, starting from the most significant bit. */ -class BitArrayOutputStream extends OutputStream { +final class BitArrayOutputStream extends OutputStream { private byte[] buffer; private int bytesWritten; private int cache; private int cacheMask = 0x80; - public BitArrayOutputStream() { + BitArrayOutputStream() { buffer = new byte[16]; } - public BitArrayOutputStream(final int size) { + BitArrayOutputStream(final int size) { buffer = new byte[size]; } - public int size() { + int size() { return bytesWritten; } - public byte[] toByteArray() { + byte[] toByteArray() { flush(); if (bytesWritten == buffer.length) { return buffer; @@ -70,7 +70,7 @@ public void write(final int b) { writeByte(b); } - public void writeBit(final int bit) { + void writeBit(final int bit) { if (bit != 0) { cache |= cacheMask; } @@ -80,7 +80,7 @@ public void writeBit(final int bit) { } } - public int getBitsAvailableInCurrentByte() { + int getBitsAvailableInCurrentByte() { int count = 0; for (int mask = cacheMask; mask != 0; mask >>>= 1) { ++count; diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/BitInputStreamFlexible.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/BitInputStreamFlexible.java similarity index 92% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/BitInputStreamFlexible.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/BitInputStreamFlexible.java index a321ac284..e36a13e06 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/BitInputStreamFlexible.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/BitInputStreamFlexible.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; import java.io.IOException; import java.io.InputStream; @@ -24,7 +24,7 @@ * across byte boundaries in most significant * bit first order. */ -class BitInputStreamFlexible extends InputStream { +final class BitInputStreamFlexible extends InputStream { // TODO should be byte order conscious, ie TIFF for reading // samples size<8 - shuoldn't that effect their order within byte? private final InputStream is; @@ -32,7 +32,7 @@ class BitInputStreamFlexible extends InputStream { private int cacheBitsRemaining; private long bytesRead; - public BitInputStreamFlexible(final InputStream is) { + BitInputStreamFlexible(final InputStream is) { this.is = is; // super(is); } @@ -45,7 +45,7 @@ public int read() throws IOException { return is.read(); } - public final int readBits(int count) throws IOException { + final int readBits(int count) throws IOException { if (count <= 32) { // catch-all @@ -98,11 +98,11 @@ public final int readBits(int count) throws IOException { } - public void flushCache() { + void flushCache() { cacheBitsRemaining = 0; } - public long getBytesRead() { + long getBytesRead() { return bytesRead; } } diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/HuffmanTree.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java similarity index 91% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/HuffmanTree.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java index fac9e4337..b57e60f1d 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/HuffmanTree.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; import java.io.IOException; import java.util.ArrayList; @@ -23,7 +23,7 @@ /** * A Huffman tree implemented as 1 array for high locality of reference. */ -class HuffmanTree { +final class HuffmanTree { private final List> nodes = new ArrayList>(); private static final class Node { @@ -31,7 +31,7 @@ private static final class Node { T value; } - public final void insert(final String pattern, final T value) throws HuffmanTreeException { + final void insert(final String pattern, final T value) throws HuffmanTreeException { int position = 0; Node node = growAndGetNode(position); if (node.value != null) { @@ -61,7 +61,7 @@ private Node growAndGetNode(final int position) { return node; } - public final T decode(final BitInputStreamFlexible bitStream) throws HuffmanTreeException { + final T decode(final BitInputStreamFlexible bitStream) throws HuffmanTreeException { int position = 0; Node node = nodes.get(0); while (node.value == null) { diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeException.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTreeException.java similarity index 80% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeException.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTreeException.java index ded4a5be0..ef836cc27 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/HuffmanTreeException.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTreeException.java @@ -14,16 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; -class HuffmanTreeException extends Exception { +final class HuffmanTreeException extends Exception { private static final long serialVersionUID = 1L; - public HuffmanTreeException(final String message) { + HuffmanTreeException(final String message) { super(message); } - public HuffmanTreeException(final String message, final Throwable cause) { + HuffmanTreeException(final String message, final Throwable cause) { super(message, cause); } } diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java similarity index 99% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java index 864b3cfaf..0f44b0bff 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; import java.io.ByteArrayInputStream; import java.io.IOException; import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.ImageWriteException; -import org.apache.commons.imaging.common.itu_t4.T4_T6_Tables.Entry; +import org.apache.commons.imaging.formats.tiff.itu_t4.T4_T6_Tables.Entry; import org.apache.commons.imaging.util.IoUtils; public final class T4AndT6Compression { diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java similarity index 84% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java index f396c3d68..29ce07fb1 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/T4_T6_Tables.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; -class T4_T6_Tables { - public static final Entry[] WHITE_TERMINATING_CODES = { +final class T4_T6_Tables { + static final Entry[] WHITE_TERMINATING_CODES = { new Entry("00110101", 0), new Entry("000111", 1), new Entry("0111", 2), @@ -83,7 +83,7 @@ class T4_T6_Tables { new Entry("00110011", 62), new Entry("00110100", 63), }; - public static final Entry[] BLACK_TERMINATING_CODES = { + static final Entry[] BLACK_TERMINATING_CODES = { new Entry("0000110111", 0), new Entry("010", 1), new Entry("11", 2), @@ -149,7 +149,7 @@ class T4_T6_Tables { new Entry("000001100110", 62), new Entry("000001100111", 63), }; - public static final Entry[] WHITE_MAKE_UP_CODES = { + static final Entry[] WHITE_MAKE_UP_CODES = { new Entry("11011", 64), new Entry("10010", 128), new Entry("010111", 192), @@ -178,7 +178,7 @@ class T4_T6_Tables { new Entry("011000", 1664), new Entry("010011011", 1728), }; - public static final Entry[] BLACK_MAKE_UP_CODES = { + static final Entry[] BLACK_MAKE_UP_CODES = { new Entry("0000001111", 64), new Entry("000011001000", 128), new Entry("000011001001", 192), @@ -207,7 +207,7 @@ class T4_T6_Tables { new Entry("0000001100100", 1664), new Entry("0000001100101", 1728), }; - public static final Entry[] ADDITIONAL_MAKE_UP_CODES = { + static final Entry[] ADDITIONAL_MAKE_UP_CODES = { new Entry("00000001000", 1792), new Entry("00000001100", 1856), new Entry("00000001101", 1920), @@ -222,34 +222,34 @@ class T4_T6_Tables { new Entry("000000011110", 2496), new Entry("000000011111", 2560), }; - public static final Entry EOL = new Entry("000000000001", 0); - public static final Entry EOL13 = new Entry("0000000000001", 0); - public static final Entry EOL14 = new Entry("00000000000001", 0); - public static final Entry EOL15 = new Entry("000000000000001", 0); - public static final Entry EOL16 = new Entry("0000000000000001", 0); - public static final Entry EOL17 = new Entry("00000000000000001", 0); - public static final Entry EOL18 = new Entry("000000000000000001", 0); - public static final Entry EOL19 = new Entry("0000000000000000001", 0); - public static final Entry P = new Entry("0001", 0); - public static final Entry H = new Entry("001", 0); - public static final Entry V0 = new Entry("1", 0); - public static final Entry VR1 = new Entry("011", 0); - public static final Entry VR2 = new Entry("000011", 0); - public static final Entry VR3 = new Entry("0000011", 0); - public static final Entry VL1 = new Entry("010", 0); - public static final Entry VL2 = new Entry("000010", 0); - public static final Entry VL3 = new Entry("0000010", 0); + static final Entry EOL = new Entry("000000000001", 0); + static final Entry EOL13 = new Entry("0000000000001", 0); + static final Entry EOL14 = new Entry("00000000000001", 0); + static final Entry EOL15 = new Entry("000000000000001", 0); + static final Entry EOL16 = new Entry("0000000000000001", 0); + static final Entry EOL17 = new Entry("00000000000000001", 0); + static final Entry EOL18 = new Entry("000000000000000001", 0); + static final Entry EOL19 = new Entry("0000000000000000001", 0); + static final Entry P = new Entry("0001", 0); + static final Entry H = new Entry("001", 0); + static final Entry V0 = new Entry("1", 0); + static final Entry VR1 = new Entry("011", 0); + static final Entry VR2 = new Entry("000011", 0); + static final Entry VR3 = new Entry("0000011", 0); + static final Entry VL1 = new Entry("010", 0); + static final Entry VL2 = new Entry("000010", 0); + static final Entry VL3 = new Entry("0000010", 0); - public static class Entry { + static class Entry { String bitString; Integer value; - public Entry(final String bitString, final int value) { + Entry(final String bitString, final int value) { this.bitString = bitString; this.value = value; } - public void writeBits(final BitArrayOutputStream outputStream) { + void writeBits(final BitArrayOutputStream outputStream) { for (int i = 0; i < bitString.length(); i++) { if (bitString.charAt(i) == '0') { outputStream.writeBit(0); diff --git a/src/main/java/org/apache/commons/imaging/common/itu_t4/package-info.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/package-info.java similarity index 93% rename from src/main/java/org/apache/commons/imaging/common/itu_t4/package-info.java rename to src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/package-info.java index 9c1510fa1..30a03ae00 100644 --- a/src/main/java/org/apache/commons/imaging/common/itu_t4/package-info.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/package-info.java @@ -18,5 +18,5 @@ /** * Provides ITU-T T.4 and T.6 compression classes. */ -package org.apache.commons.imaging.common.itu_t4; +package org.apache.commons.imaging.formats.tiff.itu_t4; diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java index b1a4c6a04..7d2b213b6 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java @@ -33,7 +33,7 @@ import org.apache.commons.imaging.common.BinaryOutputStream; import org.apache.commons.imaging.common.PackBits; import org.apache.commons.imaging.common.RationalNumber; -import org.apache.commons.imaging.common.itu_t4.T4AndT6Compression; +import org.apache.commons.imaging.formats.tiff.itu_t4.T4AndT6Compression; import org.apache.commons.imaging.common.mylzw.MyLzwCompressor; import org.apache.commons.imaging.formats.tiff.TiffElement; import org.apache.commons.imaging.formats.tiff.TiffImageData; diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffCcittTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffCcittTest.java index 7eaa3bcbf..2712acd00 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffCcittTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffCcittTest.java @@ -29,7 +29,7 @@ import org.apache.commons.imaging.ImageWriteException; import org.apache.commons.imaging.Imaging; import org.apache.commons.imaging.ImagingConstants; -import org.apache.commons.imaging.common.itu_t4.T4AndT6Compression; +import org.apache.commons.imaging.formats.tiff.itu_t4.T4AndT6Compression; import org.apache.commons.imaging.formats.tiff.constants.TiffConstants; import org.apache.commons.imaging.util.Debug; import org.junit.Test;