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 ea500fbfa6e7603dec8493e5888fd18899fb8453 Author: Gary Gregory <[email protected]> AuthorDate: Sun Jan 4 10:25:12 2026 -0500 Javadoc --- .../imaging/formats/jpeg/segments/SofnSegment.java | 12 +++ .../imaging/formats/jpeg/segments/SosSegment.java | 11 +++ .../formats/tiff/itu_t4/T4AndT6Compression.java | 37 ++++++++ .../imaging/formats/tiff/taginfos/TagInfo.java | 100 ++++++++++++++++++++- .../imaging/formats/tiff/taginfos/TagInfoAny.java | 12 +++ .../formats/tiff/taginfos/TagInfoAscii.java | 27 ++++++ .../formats/tiff/taginfos/TagInfoAsciiOrByte.java | 12 +++ .../tiff/taginfos/TagInfoAsciiOrRational.java | 12 +++ .../imaging/formats/tiff/taginfos/TagInfoByte.java | 34 +++++++ .../formats/tiff/taginfos/TagInfoByteOrShort.java | 26 ++++++ .../formats/tiff/taginfos/TagInfoBytes.java | 37 ++++++++ .../formats/tiff/taginfos/TagInfoDirectory.java | 7 ++ .../formats/tiff/taginfos/TagInfoDouble.java | 25 ++++++ .../formats/tiff/taginfos/TagInfoDoubles.java | 26 ++++++ .../formats/tiff/taginfos/TagInfoFloat.java | 25 ++++++ .../formats/tiff/taginfos/TagInfoFloats.java | 26 ++++++ .../formats/tiff/taginfos/TagInfoGpsText.java | 7 ++ .../imaging/formats/tiff/taginfos/TagInfoLong.java | 43 +++++++++ .../formats/tiff/taginfos/TagInfoLongOrIfd.java | 28 ++++++ .../formats/tiff/taginfos/TagInfoLongs.java | 35 ++++++++ .../formats/tiff/taginfos/TagInfoRational.java | 25 ++++++ .../formats/tiff/taginfos/TagInfoRationals.java | 26 ++++++ .../formats/tiff/taginfos/TagInfoSByte.java | 18 ++++ .../formats/tiff/taginfos/TagInfoSBytes.java | 19 ++++ .../formats/tiff/taginfos/TagInfoSLong.java | 25 ++++++ .../formats/tiff/taginfos/TagInfoSLongs.java | 26 ++++++ .../formats/tiff/taginfos/TagInfoSRational.java | 25 ++++++ .../formats/tiff/taginfos/TagInfoShort.java | 25 ++++++ .../formats/tiff/taginfos/TagInfoShortOrLong.java | 35 ++++++++ .../taginfos/TagInfoShortOrLongOrRational.java | 33 +++++++ .../tiff/taginfos/TagInfoShortOrRational.java | 26 ++++++ .../formats/tiff/taginfos/TagInfoShorts.java | 26 ++++++ 32 files changed, 848 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java index 552ca9e0..a668b455 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SofnSegment.java @@ -29,6 +29,9 @@ import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.Allocator; import org.apache.commons.imaging.formats.jpeg.JpegConstants; +/** + * JPEG SOFn (Start of Frame) segment. + */ public final class SofnSegment extends AbstractSegment { /** @@ -95,6 +98,15 @@ public final class SofnSegment extends AbstractSegment { this(marker, segmentData.length, new ByteArrayInputStream(segmentData)); } + /** + * Constructs a SOFn segment. + * + * @param marker the marker. + * @param markerLength the marker length. + * @param is the input stream. + * @throws IOException if an I/O error occurs. + * @throws ImagingException if an imaging error occurs. + */ public SofnSegment(final int marker, final int markerLength, final InputStream is) throws IOException, ImagingException { super(marker, markerLength); diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java index ba1fb9c5..7bcc7efa 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/SosSegment.java @@ -26,6 +26,9 @@ import java.util.logging.Logger; import org.apache.commons.imaging.common.Allocator; +/** + * JPEG SOS (Start of Scan) segment. + */ public final class SosSegment extends AbstractSegment { /** @@ -89,6 +92,14 @@ public final class SosSegment extends AbstractSegment { this(marker, segmentData.length, new ByteArrayInputStream(segmentData)); } + /** + * Constructs a SOS segment. + * + * @param marker the marker. + * @param markerLength the marker length. + * @param is the input stream. + * @throws IOException if an I/O error occurs. + */ public SosSegment(final int marker, final int markerLength, final InputStream is) throws IOException { super(marker, markerLength); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java index e74ef5ef..362b820a 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java @@ -23,12 +23,19 @@ import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.Allocator; import org.apache.commons.imaging.formats.tiff.itu_t4.T4_T6_Tables.Entry; +/** + * T4 and T6 compression implementation for TIFF. + */ public final class T4AndT6Compression { + private static final HuffmanTree<Integer> WHITE_RUN_LENGTHS = new HuffmanTree<>(); private static final HuffmanTree<Integer> BLACK_RUN_LENGTHS = new HuffmanTree<>(); private static final HuffmanTree<Entry> CONTROL_CODES = new HuffmanTree<>(); + /** White color constant. */ public static final int WHITE = 0; + + /** Black color constant. */ public static final int BLACK = 1; static { @@ -165,6 +172,16 @@ public final class T4AndT6Compression { return a2; } + /** + * Compresses data using T4 1D compression. + * + * @param uncompressed the uncompressed data. + * @param width the image width. + * @param height the image height. + * @param hasFill whether to use fill bits. + * @return the compressed data. + * @throws ImagingException if an imaging error occurs. + */ public static byte[] compressT4_1D(final byte[] uncompressed, final int width, final int height, final boolean hasFill) throws ImagingException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(uncompressed)); try (BitArrayOutputStream outputStream = new BitArrayOutputStream()) { @@ -194,6 +211,17 @@ public final class T4AndT6Compression { } } + /** + * Compresses data using T4 2D compression. + * + * @param uncompressed the uncompressed data. + * @param width the image width. + * @param height the image height. + * @param hasFill whether to use fill bits. + * @param parameterK the K parameter. + * @return the compressed data. + * @throws ImagingException if an imaging error occurs. + */ public static byte[] compressT4_2D(final byte[] uncompressed, final int width, final int height, final boolean hasFill, final int parameterK) throws ImagingException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(uncompressed)); @@ -272,6 +300,15 @@ public final class T4AndT6Compression { return outputStream.toByteArray(); } + /** + * Compresses data using T6 compression. + * + * @param uncompressed the uncompressed data. + * @param width the image width. + * @param height the image height. + * @return the compressed data. + * @throws ImagingException if an imaging error occurs. + */ public static byte[] compressT6(final byte[] uncompressed, final int width, final int height) throws ImagingException { try (ByteArrayInputStream bais = new ByteArrayInputStream(uncompressed); BitInputStreamFlexible inputStream = new BitInputStreamFlexible(bais)) { diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java index 34220984..b83aa6c0 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java @@ -28,36 +28,105 @@ import org.apache.commons.imaging.formats.tiff.TiffField; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Base class for TIFF tag information. + */ public class TagInfo { + + /** Constant for unknown length. */ public static final int LENGTH_UNKNOWN = -1; + + /** Tag name. */ public final String name; + + /** Tag number. */ public final int tag; + + /** Data types supported by this tag. */ public final List<AbstractFieldType> dataTypes; + + /** Expected length of tag data. */ public final int length; + + /** Directory type where this tag is expected. */ public final TiffDirectoryType directoryType; + private final boolean isOffset; + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataType the data type. + */ public TagInfo(final String name, final int tag, final AbstractFieldType dataType) { this(name, tag, dataType, LENGTH_UNKNOWN, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataType the data type. + * @param length the length. + */ public TagInfo(final String name, final int tag, final AbstractFieldType dataType, final int length) { this(name, tag, Arrays.asList(dataType), length, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataType the data type. + * @param length the length. + * @param exifDirectory the EXIF directory. + */ public TagInfo(final String name, final int tag, final AbstractFieldType dataType, final int length, final TiffDirectoryType exifDirectory) { this(name, tag, Arrays.asList(dataType), length, exifDirectory); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataType the data type. + * @param length the length. + * @param exifDirectory the EXIF directory. + * @param isOffset whether this is an offset tag. + */ public TagInfo(final String name, final int tag, final AbstractFieldType dataType, final int length, final TiffDirectoryType exifDirectory, final boolean isOffset) { this(name, tag, Arrays.asList(dataType), length, exifDirectory, isOffset); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataTypes the data types. + * @param length the length. + * @param exifDirectory the EXIF directory. + */ public TagInfo(final String name, final int tag, final List<AbstractFieldType> dataTypes, final int length, final TiffDirectoryType exifDirectory) { this(name, tag, dataTypes, length, exifDirectory, false); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataTypes the data types. + * @param length the length. + * @param exifDirectory the EXIF directory. + * @param isOffset whether this is an offset tag. + */ public TagInfo(final String name, final int tag, final List<AbstractFieldType> dataTypes, final int length, final TiffDirectoryType exifDirectory, final boolean isOffset) { this.name = name; @@ -68,28 +137,53 @@ public class TagInfo { this.isOffset = isOffset; } + /** + * Encodes a value. + * + * @param abstractFieldType the field type. + * @param value the value. + * @param byteOrder the byte order. + * @return the encoded bytes. + * @throws ImagingException if an imaging error occurs. + */ public byte[] encodeValue(final AbstractFieldType abstractFieldType, final Object value, final ByteOrder byteOrder) throws ImagingException { return abstractFieldType.writeData(value, byteOrder); } + /** + * Gets the description. + * + * @return the description. + */ public String getDescription() { return tag + " (0x" + Integer.toHexString(tag) + ": " + name + "): "; } /** + * Gets the value from a TIFF field. * - * @param entry the TIFF field whose value to return - * @return the value of the TIFF field - * @throws ImagingException thrown by subclasses + * @param entry the TIFF field whose value to return. + * @return the value of the TIFF field. + * @throws ImagingException thrown by subclasses. */ public Object getValue(final TiffField entry) throws ImagingException { return entry.getFieldType().getValue(entry); } + /** + * Checks if this is an offset tag. + * + * @return true if this is an offset tag, false otherwise. + */ public boolean isOffset() { return isOffset; } + /** + * Checks if this is a text tag. + * + * @return true if this is a text tag, false otherwise. + */ public boolean isText() { return false; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java index a65ec5df..8e9192ec 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java @@ -19,7 +19,19 @@ package org.apache.commons.imaging.formats.tiff.taginfos; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for any field type. + */ public class TagInfoAny extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoAny(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.ANY, length, directoryType); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java index e30f6789..0fde3e2e 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java @@ -24,15 +24,42 @@ import org.apache.commons.imaging.common.Allocator; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for ASCII field type. + */ public class TagInfoAscii extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoAscii(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.ASCII, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + * @throws ImagingException if an imaging error occurs. + */ public byte[] encodeValue(final ByteOrder byteOrder, final String... values) throws ImagingException { return AbstractFieldType.ASCII.writeData(values, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the string array value. + */ public String[] getValue(final ByteOrder byteOrder, final byte[] bytes) { int nullCount = 0; for (int i = 0; i < bytes.length - 1; i++) { diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java index f70d16ca..99aab56b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java @@ -19,7 +19,19 @@ package org.apache.commons.imaging.formats.tiff.taginfos; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for ASCII or byte field type. + */ public class TagInfoAsciiOrByte extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoAsciiOrByte(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.ASCII_OR_BYTE, length, directoryType, false); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java index 2a07fba2..fc892dfe 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java @@ -19,7 +19,19 @@ package org.apache.commons.imaging.formats.tiff.taginfos; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for ASCII or rational field type. + */ public class TagInfoAsciiOrRational extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoAsciiOrRational(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.ASCII_OR_RATIONAL, length, directoryType, false); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java index 4f622530..e0a41cc5 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java @@ -22,19 +22,53 @@ import java.util.List; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for byte field type. + */ public class TagInfoByte extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param abstractFieldType the field type. + * @param directoryType the directory type. + */ public TagInfoByte(final String name, final int tag, final AbstractFieldType abstractFieldType, final TiffDirectoryType directoryType) { super(name, tag, abstractFieldType, 1, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param abstractFieldTypes the field types. + * @param directoryType the directory type. + */ public TagInfoByte(final String name, final int tag, final List<AbstractFieldType> abstractFieldTypes, final TiffDirectoryType directoryType) { super(name, tag, abstractFieldTypes, 1, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoByte(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.BYTE, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final byte value) { return new byte[] { value }; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java index bd50e4a8..52474242 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java @@ -22,15 +22,41 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for byte or short field type. + */ public class TagInfoByteOrShort extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoByteOrShort(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.BYTE_OR_SHORT, length, directoryType); } + /** + * Encodes byte values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final byte... values) { return values; } + /** + * Encodes short values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final short... values) { return ByteConversions.toBytes(values, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoBytes.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoBytes.java index 98cf32ad..6e01198d 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoBytes.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoBytes.java @@ -22,20 +22,57 @@ import java.util.List; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for bytes field type. + */ public class TagInfoBytes extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param abstractFieldType the field type. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoBytes(final String name, final int tag, final AbstractFieldType abstractFieldType, final int length, final TiffDirectoryType directoryType) { super(name, tag, abstractFieldType, length, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoBytes(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.BYTE, length, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param abstractFieldTypes the field types. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoBytes(final String name, final int tag, final List<AbstractFieldType> abstractFieldTypes, final int length, final TiffDirectoryType directoryType) { super(name, tag, abstractFieldTypes, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final byte... values) { return values; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDirectory.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDirectory.java index 6c00181c..0e40d090 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDirectory.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDirectory.java @@ -30,6 +30,13 @@ public class TagInfoDirectory extends TagInfoLong { private static final List<AbstractFieldType> fieldList = Collections.unmodifiableList(Arrays.asList(AbstractFieldType.LONG, AbstractFieldType.IFD)); + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoDirectory(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, fieldList, 1, directoryType, true); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java index e23b2b7c..14be4bae 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java @@ -22,15 +22,40 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for double field type. + */ public class TagInfoDouble extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoDouble(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.DOUBLE, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final double value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the double value. + */ public double getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toDouble(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDoubles.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDoubles.java index c1b46bfe..b1b499fb 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDoubles.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDoubles.java @@ -22,15 +22,41 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for doubles (array) field type. + */ public class TagInfoDoubles extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoDoubles(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.DOUBLE, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final double... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Gets the values. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the double array values. + */ public double[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toDoubles(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java index 451c1b1e..1b92cda8 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java @@ -22,15 +22,40 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for float field type. + */ public class TagInfoFloat extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoFloat(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.FLOAT, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final float value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the float value. + */ public float getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toFloat(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloats.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloats.java index 4bb5fdcf..78db17e1 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloats.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloats.java @@ -22,15 +22,41 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for floats (array) field type. + */ public class TagInfoFloats extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoFloats(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.FLOAT, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final float... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Gets the values. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the float array values. + */ public float[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toFloats(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java index f418b6fb..47b507db 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java @@ -63,6 +63,13 @@ public final class TagInfoGpsText extends TagInfo { TEXT_ENCODING_UNDEFINED, // }; + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param exifDirectory the EXIF directory. + */ public TagInfoGpsText(final String name, final int tag, final TiffDirectoryType exifDirectory) { super(name, tag, AbstractFieldType.UNDEFINED, LENGTH_UNKNOWN, exifDirectory); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java index 682fc7f0..1d1c3720 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java @@ -23,24 +23,67 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for long field type. + */ public class TagInfoLong extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param dataTypes the data types. + * @param length the length. + * @param exifDirectory the EXIF directory. + * @param isOffset whether this is an offset tag. + */ public TagInfoLong(final String name, final int tag, final List<AbstractFieldType> dataTypes, final int length, final TiffDirectoryType exifDirectory, final boolean isOffset) { super(name, tag, dataTypes, length, exifDirectory, isOffset); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoLong(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.LONG, 1, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + * @param isOffset whether this is an offset tag. + */ public TagInfoLong(final String name, final int tag, final TiffDirectoryType directoryType, final boolean isOffset) { super(name, tag, AbstractFieldType.LONG, 1, directoryType, isOffset); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the integer value. + */ public int getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toInt(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongOrIfd.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongOrIfd.java index 574d38e9..6557f79b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongOrIfd.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongOrIfd.java @@ -22,15 +22,43 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for long or IFD field type. + */ public class TagInfoLongOrIfd extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoLongOrIfd(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.LONG_OR_IFD, length, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + * @param isOffset whether this is an offset tag. + */ public TagInfoLongOrIfd(final String name, final int tag, final int length, final TiffDirectoryType directoryType, final boolean isOffset) { super(name, tag, AbstractFieldType.LONG_OR_IFD, length, directoryType, isOffset); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int... values) { return ByteConversions.toBytes(values, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongs.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongs.java index b77e6d5c..6a456d1e 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongs.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLongs.java @@ -22,19 +22,54 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for longs (array) field type. + */ public class TagInfoLongs extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoLongs(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.LONG, length, directoryType); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + * @param isOffset whether this is an offset tag. + */ public TagInfoLongs(final String name, final int tag, final int length, final TiffDirectoryType directoryType, final boolean isOffset) { super(name, tag, AbstractFieldType.LONG, length, directoryType, isOffset); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Gets the values. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the integer array values. + */ public int[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toInts(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java index 95be96db..58bd6716 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java @@ -23,15 +23,40 @@ import org.apache.commons.imaging.common.RationalNumber; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for rational field type. + */ public class TagInfoRational extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoRational(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.RATIONAL, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the rational number value. + */ public RationalNumber getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toRational(bytes, byteOrder, true); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRationals.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRationals.java index 1192d35b..85ea84a8 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRationals.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRationals.java @@ -23,15 +23,41 @@ import org.apache.commons.imaging.common.RationalNumber; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for rationals (array) field type. + */ public class TagInfoRationals extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoRationals(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.RATIONAL, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Gets the values. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the rational number array values. + */ public RationalNumber[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toRationals(bytes, byteOrder, true); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java index e0193008..1f2fbd27 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java @@ -21,11 +21,29 @@ import java.nio.ByteOrder; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for signed byte field type. + */ public class TagInfoSByte extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoSByte(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SBYTE, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final byte value) { return new byte[] { value }; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytes.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytes.java index be50a023..814b0e27 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytes.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSBytes.java @@ -21,11 +21,30 @@ import java.nio.ByteOrder; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for signed bytes (array) field type. + */ public class TagInfoSBytes extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoSBytes(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SBYTE, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final byte... values) { return values; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java index 968990d2..9e4a0b5e 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java @@ -22,15 +22,40 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for signed long field type. + */ public class TagInfoSLong extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoSLong(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SLONG, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the integer value. + */ public int getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toInt(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongs.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongs.java index 898458ab..1ff4f3c6 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongs.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLongs.java @@ -22,15 +22,41 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for signed longs (array) field type. + */ public class TagInfoSLongs extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoSLongs(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SLONG, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Gets the values. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the integer array values. + */ public int[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toInts(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSRational.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSRational.java index be159e2a..9f2fdf8f 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSRational.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSRational.java @@ -23,15 +23,40 @@ import org.apache.commons.imaging.common.RationalNumber; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for signed rational field type. + */ public class TagInfoSRational extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoSRational(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SRATIONAL, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the rational number value. + */ public RationalNumber getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toRational(bytes, byteOrder, false); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShort.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShort.java index 00a12732..9a7a8da7 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShort.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShort.java @@ -22,15 +22,40 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for short field type. + */ public class TagInfoShort extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param directoryType the directory type. + */ public TagInfoShort(final String name, final int tag, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SHORT, 1, directoryType); } + /** + * Encodes a value. + * + * @param byteOrder the byte order. + * @param value the value. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final short value) { return ByteConversions.toBytes(value, byteOrder); } + /** + * Gets the value. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the short value. + */ public short getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toShort(bytes, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLong.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLong.java index 29425c4e..4749aee7 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLong.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLong.java @@ -22,19 +22,54 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for short or long field type. + */ public class TagInfoShortOrLong extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoShortOrLong(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SHORT_OR_LONG, length, directoryType, false); } + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + * @param isOffset whether this is an offset tag. + */ public TagInfoShortOrLong(final String name, final int tag, final int length, final TiffDirectoryType directoryType, final boolean isOffset) { super(name, tag, AbstractFieldType.SHORT_OR_LONG, length, directoryType, isOffset); } + /** + * Encodes int values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Encodes short values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final short... values) { return ByteConversions.toBytes(values, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLongOrRational.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLongOrRational.java index 3f991972..5ff14632 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLongOrRational.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrLongOrRational.java @@ -23,19 +23,52 @@ import org.apache.commons.imaging.common.RationalNumber; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for short or long or rational field type. + */ public class TagInfoShortOrLongOrRational extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoShortOrLongOrRational(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SHORT_OR_LONG_OR_RATIONAL, length, directoryType); } + /** + * Encodes int values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final int... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Encodes rational values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Encodes short values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final short... values) { return ByteConversions.toBytes(values, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrRational.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrRational.java index d92a2cd7..d7350b5f 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrRational.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShortOrRational.java @@ -23,15 +23,41 @@ import org.apache.commons.imaging.common.RationalNumber; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for short or rational field type. + */ public class TagInfoShortOrRational extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoShortOrRational(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SHORT_OR_RATIONAL, length, directoryType, false); } + /** + * Encodes rational values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Encodes short values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final short... values) { return ByteConversions.toBytes(values, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShorts.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShorts.java index 21d629ec..c248d55b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShorts.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoShorts.java @@ -22,15 +22,41 @@ import org.apache.commons.imaging.common.ByteConversions; import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType; +/** + * Tag info for shorts (array) field type. + */ public class TagInfoShorts extends TagInfo { + + /** + * Constructs a new instance. + * + * @param name the tag name. + * @param tag the tag number. + * @param length the length. + * @param directoryType the directory type. + */ public TagInfoShorts(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, AbstractFieldType.SHORT, length, directoryType); } + /** + * Encodes values. + * + * @param byteOrder the byte order. + * @param values the values. + * @return the encoded bytes. + */ public byte[] encodeValue(final ByteOrder byteOrder, final short... values) { return ByteConversions.toBytes(values, byteOrder); } + /** + * Gets the values. + * + * @param byteOrder the byte order. + * @param bytes the bytes. + * @return the short array values. + */ public short[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return ByteConversions.toShorts(bytes, byteOrder); }
