Cloneablepublic final class TIFFField extends Object implements Cloneable
 A field in a TIFF Image File Directory (IFD) is defined as a tag number accompanied by a sequence of values of identical data type. TIFF 6.0 defines 12 data types; a 13th type IFD is defined in TIFF Tech Note 1 of TIFF Specification Supplement 1. These TIFF data types are referred to by Java constants and mapped internally onto Java language data types and type names as follows: 
| TIFF Data Type | Java Constant | Java Data Type | Java Type Name | 
|---|---|---|---|
| BYTE | TIFFTag.TIFF_BYTE | byte | "Byte" | 
| ASCII | TIFFTag.TIFF_ASCII | String | "Ascii" | 
| SHORT | TIFFTag.TIFF_SHORT | char | "Short" | 
| LONG | TIFFTag.TIFF_LONG | long | "Long" | 
| RATIONAL | TIFFTag.TIFF_RATIONAL | long[2]{numerator, denominator} | "Rational" | 
| SBYTE | TIFFTag.TIFF_SBYTE | byte | "SByte" | 
| UNDEFINED | TIFFTag.TIFF_UNDEFINED | byte | "Undefined" | 
| SSHORT | TIFFTag.TIFF_SSHORT | short | "SShort" | 
| SLONG | TIFFTag.TIFF_SLONG | int | "SLong" | 
| SRATIONAL | TIFFTag.TIFF_SRATIONAL | int[2]{numerator, denominator} | "SRational" | 
| FLOAT | TIFFTag.TIFF_FLOAT | float | "Float" | 
| DOUBLE | TIFFTag.TIFF_DOUBLE | double | "Double" | 
| IFD | TIFFTag.TIFF_IFD_POINTER | long | "IFDPointer" | 
| Constructor | Description | 
|---|---|
| TIFFField | Constructs a data array using  createArrayForType()and invokesTIFFField(TIFFTag,int,int,Object)with the supplied parameters and the created array. | 
| TIFFField | Constructs a  TIFFFieldwith arbitrary data. | 
| TIFFField | Constructs a  TIFFFieldwith an IFD offset and contents. | 
| TIFFField | Constructs a  TIFFFieldwith a single non-negative integral value. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| TIFFField | clone() | Clones the field and all the information contained therein. | 
| static Object | createArrayForType | Creates an array appropriate for the indicated data type. | 
| static TIFFField | createFromMetadataNode | Creates a  TIFFFieldfrom a TIFF native image metadata node. | 
| byte[] | getAsBytes() | Returns the data as an uninterpreted array of  bytes. | 
| char[] | getAsChars() | Returns  TIFFTag.TIFF_SHORTdata as an array ofchars (unsigned 16-bit integers). | 
| double | getAsDouble | Returns data in any format as a  double. | 
| double[] | getAsDoubles() | Returns  TIFFTag.TIFF_DOUBLEdata as an array ofdoubles (64-bit floating-point values). | 
| float | getAsFloat | Returns data in any format as a  float. | 
| float[] | getAsFloats() | Returns  TIFFTag.TIFF_FLOATdata as an array offloats (32-bit floating-point values). | 
| int | getAsInt | Returns data in any format as an  int. | 
| int[] | getAsInts() | Returns  TIFFTag.TIFF_SLONGdata as an array ofints (signed 32-bit integers). | 
| long | getAsLong | Returns data in any format as a  long. | 
| long[] | getAsLongs() | Returns  TIFFTag.TIFF_LONGorTIFF_IFD_POINTERdata as an array oflongs (signed 64-bit integers). | 
| Node | getAsNativeNode() | Returns the  TIFFFieldas a node named either"TIFFField"or"TIFFIFD"as described in the TIFF native image metadata specification. | 
| long[] | getAsRational | Returns a TIFFTag.TIFF_RATIONAL data item as a two-element array of ints. | 
| long[][] | getAsRationals() | Returns  TIFFTag.TIFF_RATIONALdata as an array of 2-element arrays oflongs. | 
| short[] | getAsShorts() | Returns  TIFFTag.TIFF_SSHORTdata as an array ofshorts (signed 16-bit integers). | 
| int[] | getAsSRational | Returns a  TIFFTag.TIFF_SRATIONALdata item as a two-element array ofints. | 
| int[][] | getAsSRationals() | Returns  TIFFTag.TIFF_SRATIONALdata as an array of 2-element arrays ofints. | 
| String | getAsString | Returns a  TIFFTag.TIFF_ASCIIvalue as aString. | 
| int | getCount() | Returns the number of data items present in the field. | 
| Object | getData() | Returns a reference to the data object associated with the field. | 
| TIFFDirectory | getDirectory() | Returns the associated  TIFFDirectory, if available. | 
| TIFFTag | getTag() | Retrieves the tag associated with this field. | 
| int | getTagNumber() | Retrieves the tag number in the range  [0,65535]. | 
| int | getType() | Returns the type of the data stored in the field. | 
| static int | getTypeByName | Returns the data type constant corresponding to the supplied data type name. | 
| static String | getTypeName | Returns the name of the supplied data type constant. | 
| String | getValueAsString | Returns a  Stringcontaining a human-readable version of the data item. | 
| boolean | hasDirectory() | Returns whether the field has a  TIFFDirectory. | 
| boolean | isIntegral() | Indicates whether the value associated with the field is of integral data type. | 
public TIFFField(TIFFTag tag, int type, int count, Object data)
TIFFField with arbitrary data. The type parameter must be a value for which tag.isDataTypeOK() returns true. The data parameter must be an array of a Java type appropriate for the type of the TIFF field. Note that the value (data) of the TIFFField will always be the actual field value regardless of the number of bytes required for that value. This is the case despite the fact that the TIFF IFD Entry corresponding to the field may actually contain the offset to the value of the field rather than the value itself (the latter occurring if and only if the value fits into 4 bytes). In other words, the value of the field will already have been read from the TIFF stream. (An exception to this case may occur when the field represents the contents of a non-baseline IFD. In that case the data will be a long[] containing the offset to the IFD and the TIFFDirectory returned by getDirectory() will be its contents.)
tag - The tag to associated with this field.type - One of the TIFFTag.TIFF_* constants indicating the data type of the field as written to the TIFF stream.count - The number of data values.data - The actual data content of the field.NullPointerException - if tag == null.IllegalArgumentException - if type is not one of the TIFFTag.TIFF_* data type constants.IllegalArgumentException - if type is an unacceptable data type for the supplied TIFFTag.IllegalArgumentException - if count < 0.IllegalArgumentException - if count < 1 and type is TIFF_RATIONAL or TIFF_SRATIONAL.IllegalArgumentException - if count != 1 and type is TIFF_IFD_POINTER.NullPointerException - if data == null.IllegalArgumentException - if data is an instance of a class incompatible with the specified type.IllegalArgumentException - if the size of the data array is wrong.IllegalArgumentException - if the type of the data array is TIFF_LONG, TIFF_RATIONAL, or TIFF_IFD_POINTER and any of the elements is negative or greater than 0xffffffff.public TIFFField(TIFFTag tag, int type, int count)
createArrayForType() and invokes TIFFField(TIFFTag,int,int,Object) with the supplied parameters and the created array.tag - The tag to associated with this field.type - One of the TIFFTag.TIFF_* constants indicating the data type of the field as written to the TIFF stream.count - The number of data values.NullPointerException - if tag == null.IllegalArgumentException - if type is not one of the TIFFTag.TIFF_* data type constants.IllegalArgumentException - if type is an unacceptable data type for the supplied TIFFTag.IllegalArgumentException - if count < 0.IllegalArgumentException - if count < 1 and type is TIFF_RATIONAL or TIFF_SRATIONAL.IllegalArgumentException - if count != 1 and type is TIFF_IFD_POINTER.public TIFFField(TIFFTag tag, long value)
TIFFField with a single non-negative integral value. The field will have type TIFF_SHORT if value is in [0,0xffff], and type TIFF_LONG if value is in [0x10000,0xffffffff]. The count of the field will be unity.tag - The tag to associate with this field.value - The value to associate with this field.NullPointerException - if tag == null.IllegalArgumentException - if value is not in [0,0xffffffff].IllegalArgumentException - if value is in [0,0xffff] and TIFF_SHORT is an unacceptable type for the TIFFTag, or if value is in [0x10000,0xffffffff] and TIFF_LONG is an unacceptable type for the TIFFTag.public TIFFField(TIFFTag tag, int type, long offset, TIFFDirectory dir)
TIFFField with an IFD offset and contents. The offset will be stored as the data of this field as long[] {offset}. The directory will not be cloned. The count of the field will be unity.tag - The tag to associated with this field.type - One of the constants TIFFTag.TIFF_LONG or TIFFTag.TIFF_IFD_POINTER.offset - The IFD offset.dir - The directory.NullPointerException - if tag == null.IllegalArgumentException - if type is an unacceptable data type for the supplied TIFFTag.IllegalArgumentException - if type is neither TIFFTag.TIFF_LONG nor TIFFTag.TIFF_IFD_POINTER.IllegalArgumentException - if offset <= 0.NullPointerException - if dir == null.public static TIFFField createFromMetadataNode(TIFFTagSet tagSet, Node node)
TIFFField from a TIFF native image metadata node. If the value of the "number" attribute of the node is not found in tagSet then a new TIFFTag with name TIFFTag.UNKNOWN_TAG_NAME will be created and assigned to the field.tagSet - The TIFFTagSet to which the TIFFTag of the field belongs.node - A native TIFF image metadata TIFFField node.TIFFField.IllegalArgumentException - If the Node parameter content does not adhere to the TIFFField element structure defined by the  TIFF native image metadata format specification, or if the combination of node attributes and data is not legal per the TIFFField(TIFFTag,int,int,Object) constructor specification. Note that a cause might be set on such an exception.public TIFFTag getTag()
TIFFTag.public int getTagNumber()
[0,65535].public int getType()
TIFFTag.TIFF_* constants. For future revisions of TIFF, higher values are possible.public static String getTypeName(int dataType)
dataType - One of the TIFFTag.TIFF_* constants indicating the data type of the field as written to the TIFF stream.IllegalArgumentException - if dataType is not one of the TIFFTag.TIFF_* data type constants.public static int getTypeByName(String typeName)
-1 will be returned.typeName - The type name.TIFFTag.TIFF_* constants or -1 if the name is not recognized.public static Object createArrayForType(int dataType, int count)
dataType - One of the TIFFTag.TIFF_* data type constants.count - The number of values in the array.IllegalArgumentException - if dataType is not one of the TIFFTag.TIFF_* data type constants.IllegalArgumentException - if count < 0.IllegalArgumentException - if count < 1 and type is TIFF_RATIONAL or TIFF_SRATIONAL.IllegalArgumentException - if count != 1 and type is TIFF_IFD_POINTER.public Node getAsNativeNode()
TIFFField as a node named either "TIFFField" or "TIFFIFD" as described in the TIFF native image metadata specification. The node will be named "TIFFIFD" if and only if hasDirectory() returns true and the field's type is either TIFFTag.TIFF_LONG or TIFFTag.TIFF_IFD_POINTER.Node named "TIFFField" or "TIFFIFD".public boolean isIntegral()
public int getCount()
TIFFTag.TIFF_ASCII fields, the value returned is the number of Strings, not the total length of the data as in the file representation.public Object getData()
public byte[] getAsBytes()
bytes. The type of the field must be one of TIFFTag.TIFF_BYTE, TIFF_SBYTE, or TIFF_UNDEFINED.  For data in TIFFTag.TIFF_BYTE format, the application must take care when promoting the data to longer integral types to avoid sign extension.
ClassCastException - if the field is not of type TIFF_BYTE, TIFF_SBYTE, or TIFF_UNDEFINED.public char[] getAsChars()
TIFFTag.TIFF_SHORT data as an array of chars (unsigned 16-bit integers).chars.ClassCastException - if the field is not of type TIFF_SHORT.public short[] getAsShorts()
TIFFTag.TIFF_SSHORT data as an array of shorts (signed 16-bit integers).shorts.ClassCastException - if the field is not of type TIFF_SSHORT.public int[] getAsInts()
TIFFTag.TIFF_SLONG data as an array of ints (signed 32-bit integers).ints.ClassCastException - if the field is not of type TIFF_SHORT, TIFF_SSHORT, or TIFF_SLONG.public long[] getAsLongs()
TIFFTag.TIFF_LONG or TIFF_IFD_POINTER data as an array of longs (signed 64-bit integers).longs.ClassCastException - if the field is not of type TIFF_LONG or TIFF_IFD_POINTER.public float[] getAsFloats()
TIFFTag.TIFF_FLOAT data as an array of floats (32-bit floating-point values).floats.ClassCastException - if the field is not of type TIFF_FLOAT.public double[] getAsDoubles()
TIFFTag.TIFF_DOUBLE data as an array of doubles (64-bit floating-point values).doubles.ClassCastException - if the field is not of type TIFF_DOUBLE.public int[][] getAsSRationals()
TIFFTag.TIFF_SRATIONAL data as an array of 2-element arrays of ints.ClassCastException - if the field is not of type TIFF_SRATIONAL.public long[][] getAsRationals()
TIFFTag.TIFF_RATIONAL data as an array of 2-element arrays of longs.ClassCastException - if the field is not of type TIFF_RATIONAL.public int getAsInt(int index)
int.  TIFFTag.TIFF_BYTE values are treated as unsigned; that is, no sign extension will take place and the returned value will be in the range [0, 255]. TIFF_SBYTE data will be returned in the range [-128, 127]. 
 A TIFF_UNDEFINED value is treated as though it were a TIFF_BYTE. 
 Data in TIFF_SLONG, TIFF_LONG, TIFF_FLOAT, TIFF_DOUBLE or TIFF_IFD_POINTER format are simply cast to int and may suffer from truncation. 
 Data in TIFF_SRATIONAL or TIFF_RATIONAL format are evaluated by dividing the numerator into the denominator using double-precision arithmetic and then casting to int. Loss of precision and truncation may occur. 
 Data in TIFF_ASCII format will be parsed as by the Double.parseDouble method, with the result case to int.
index - The index of the data.int.public long getAsLong(int index)
long.  TIFFTag.TIFF_BYTE and TIFF_UNDEFINED data are treated as unsigned; that is, no sign extension will take place and the returned value will be in the range [0, 255]. TIFF_SBYTE data will be returned in the range [-128, 127]. 
 Data in TIFF_FLOAT and TIFF_DOUBLE are simply cast to long and may suffer from truncation. 
 Data in TIFF_SRATIONAL or TIFF_RATIONAL format are evaluated by dividing the numerator into the denominator using double-precision arithmetic and then casting to long. Loss of precision and truncation may occur. 
 Data in TIFF_ASCII format will be parsed as by the Double.parseDouble method, with the result cast to long.
index - The index of the data.long.public float getAsFloat(int index)
float.  TIFFTag.TIFF_BYTE and TIFF_UNDEFINED data are treated as unsigned; that is, no sign extension will take place and the returned value will be in the range [0, 255]. TIFF_SBYTE data will be returned in the range [-128, 127]. 
 Data in TIFF_SLONG, TIFF_LONG, TIFF_DOUBLE, or TIFF_IFD_POINTER format are simply cast to float and may suffer from truncation. 
 Data in TIFF_SRATIONAL or TIFF_RATIONAL format are evaluated by dividing the numerator into the denominator using double-precision arithmetic and then casting to float. 
 Data in TIFF_ASCII format will be parsed as by the Double.parseDouble method, with the result cast to float.
index - The index of the data.float.public double getAsDouble(int index)
double.  TIFFTag.TIFF_BYTE and TIFF_UNDEFINED data are treated as unsigned; that is, no sign extension will take place and the returned value will be in the range [0, 255]. TIFF_SBYTE data will be returned in the range [-128, 127]. 
 Data in TIFF_SRATIONAL or TIFF_RATIONAL format are evaluated by dividing the numerator into the denominator using double-precision arithmetic. 
 Data in TIFF_ASCII format will be parsed as by the Double.parseDouble method.
index - The index of the data.double.public String getAsString(int index)
TIFFTag.TIFF_ASCII value as a String.index - The index of the data.String.ClassCastException - if the field is not of type TIFF_ASCII.public int[] getAsSRational(int index)
TIFFTag.TIFF_SRATIONAL data item as a two-element array of ints.index - The index of the data.ClassCastException - if the field is not of type TIFF_SRATIONAL.public long[] getAsRational(int index)
index - The index of the data.ClassCastException - if the field is not of type TIFF_RATIONAL.public String getValueAsString(int index)
String containing a human-readable version of the data item. Data of type TIFFTag.TIFF_RATIONAL or TIFF_SRATIONAL are represented as a pair of integers separated by a '/' character. If the numerator of a TIFFTag.TIFF_RATIONAL or TIFF_SRATIONAL is an integral multiple of the denominator, then the value is represented as "q/1" where q is the quotient of the numerator and denominator.index - The index of the data.String.ClassCastException - if the field is not of one of the legal field types.public boolean hasDirectory()
TIFFDirectory.public TIFFDirectory getDirectory()
TIFFDirectory, if available. If no directory is set, then null will be returned.public TIFFField clone() throws CloneNotSupportedException
clone in class Object
TIFFField.CloneNotSupportedException - if the instance cannot be cloned.
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/imageio/plugins/tiff/TIFFField.html