Module java.desktop

Class TIFFDirectory

java.lang.Object
javax.imageio.plugins.tiff.TIFFDirectory
All Implemented Interfaces:
Cloneable

public class TIFFDirectory extends Object implements Cloneable
A convenience class for simplifying interaction with TIFF native image metadata. A TIFF image metadata tree represents an Image File Directory (IFD) from a TIFF 6.0 stream. An IFD consists of a number of IFD Entries each of which associates an identifying tag number with a compatible value. A TIFFDirectory instance corresponds to an IFD and contains a set of TIFFFields each of which corresponds to an IFD Entry in the IFD.

When reading, a TIFFDirectory may be created by passing the value returned by ImageReader.getImageMetadata() to createFromMetadata(). The TIFFFields in the directory may then be obtained using the accessor methods provided in this class.

When writing, an IIOMetadata object for use by one of the write() methods of ImageWriter may be created from a TIFFDirectory by getAsMetadata(). The TIFFDirectory itself may be created by construction or from the IIOMetadata object returned by ImageWriter.getDefaultImageMetadata(). The TIFFFields in the directory may be set using the mutator methods provided in this class.

A TIFFDirectory is aware of the tag numbers in the group of TIFFTagSets associated with it. When a TIFFDirectory is created from a native image metadata object, these tag sets are derived from the tagSets attribute of the TIFFIFD node.

A TIFFDirectory might also have a parent TIFFTag. This will occur if the directory represents an IFD other than the root IFD of the image. The parent tag is the tag of the IFD Entry which is a pointer to the IFD represented by this TIFFDirectory. The TIFFTag.isIFDPointer() method of this parent TIFFTag must return true. When a TIFFDirectory is created from a native image metadata object, the parent tag set is set from the parentTagName attribute of the corresponding TIFFIFD node. Note that a TIFFDirectory instance which has a non-null parent tag will be contained in the data field of a TIFFField instance which has a tag field equal to the contained directory's parent tag.

As an example consider an Exif image. The TIFFDirectory instance corresponding to the Exif IFD in the Exif stream would have parent tag TAG_EXIF_IFD_POINTER and would include ExifTIFFTagSet in its group of known tag sets. The TIFFDirectory corresponding to this Exif IFD will be contained in the data field of a TIFFField which will in turn be contained in the TIFFDirectory corresponding to the primary IFD of the Exif image which will itself have a null-valued parent tag.

Note that this implementation is not synchronized. If multiple threads use a TIFFDirectory instance concurrently, and at least one of the threads modifies the directory, for example, by adding or removing TIFFFields or TIFFTagSets, it must be synchronized externally.

Since:
9
See Also: