Cloneable
public class TIFFDirectory extends Object implements Cloneable
TIFFDirectory
instance corresponds to an IFD and contains a set of TIFFField
s 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 TIFFField
s 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 TIFFField
s 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 TIFFTagSet
s 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 TIFFField
s or TIFFTagSet
s, it must be synchronized externally.
Constructor | Description |
---|---|
TIFFDirectory |
Constructs a TIFFDirectory which is aware of a given group of TIFFTagSet s. |
Modifier and Type | Method | Description |
---|---|---|
void |
addTagSet |
Adds an element to the group of TIFFTagSet s of which this directory is aware. |
void |
addTIFFField |
Adds a TIFF field to the directory. |
TIFFDirectory |
clone() |
Clones the directory and all the fields contained therein. |
boolean |
containsTIFFField |
Determines whether a TIFF field with the given tag number is contained in this directory. |
static TIFFDirectory |
createFromMetadata |
Creates a TIFFDirectory instance from the contents of an image metadata object. |
IIOMetadata |
getAsMetadata() |
Converts the directory to a metadata object. |
int |
getNumTIFFFields() |
Returns the number of TIFFField s in this directory. |
TIFFTag |
getParentTag() |
Returns the parent TIFFTag of this directory if one has been defined or null otherwise. |
TIFFTag |
getTag |
Returns the TIFFTag which has tag number equal to tagNumber or null if no such tag exists in the TIFFTagSet s associated with this directory. |
TIFFTagSet[] |
getTagSets() |
Returns the TIFFTagSet s of which this directory is aware. |
TIFFField |
getTIFFField |
Retrieves a TIFF field from the directory. |
TIFFField[] |
getTIFFFields() |
Retrieves all TIFF fields from the directory. |
void |
removeTagSet |
Removes an element from the group of TIFFTagSet s of which this directory is aware. |
void |
removeTIFFField |
Removes a TIFF field from the directory. |
void |
removeTIFFFields() |
Removes all TIFF fields from the directory. |
public TIFFDirectory(TIFFTagSet[] tagSets, TIFFTag parentTag)
TIFFDirectory
which is aware of a given group of TIFFTagSet
s. An optional parent TIFFTag
may also be specified.tagSets
- The TIFFTagSets
associated with this directory.parentTag
- The parent TIFFTag
of this directory; may be null
.NullPointerException
- if tagSets
is null
.public static TIFFDirectory createFromMetadata(IIOMetadata tiffImageMetadata) throws IIOInvalidTreeException
TIFFDirectory
instance from the contents of an image metadata object. The supplied object must support an image metadata format supported by the TIFF ImageWriter
plug-in. This will usually be either the TIFF native image metadata format javax_imageio_tiff_image_1.0
or the Java Image I/O standard metadata format javax_imageio_1.0
.tiffImageMetadata
- A metadata object which supports a compatible image metadata format.TIFFDirectory
populated from the contents of the supplied metadata object.NullPointerException
- if tiffImageMetadata
is null
.IllegalArgumentException
- if tiffImageMetadata
does not support a compatible image metadata format.IIOInvalidTreeException
- if the supplied metadata object cannot be parsed.public TIFFTagSet[] getTagSets()
TIFFTagSet
s of which this directory is aware.TIFFTagSet
s associated with this TIFFDirectory
.public void addTagSet(TIFFTagSet tagSet)
TIFFTagSet
s of which this directory is aware.tagSet
- The TIFFTagSet
to add.NullPointerException
- if tagSet
is null
.public void removeTagSet(TIFFTagSet tagSet)
TIFFTagSet
s of which this directory is aware.tagSet
- The TIFFTagSet
to remove.NullPointerException
- if tagSet
is null
.public TIFFTag getParentTag()
TIFFTag
of this directory if one has been defined or null
otherwise.TIFFTag
of this TIFFDiectory
or null
.public TIFFTag getTag(int tagNumber)
TIFFTag
which has tag number equal to tagNumber
or null
if no such tag exists in the TIFFTagSet
s associated with this directory.tagNumber
- The tag number of interest.TIFFTag
or null
.public int getNumTIFFFields()
TIFFField
s in this directory.TIFFField
s in this TIFFDirectory
.public boolean containsTIFFField(int tagNumber)
tagNumber
- The tag number.TIFFTag
with tag number equal to tagNumber
is present in this TIFFDirectory
.public void addTIFFField(TIFFField f)
f
- The field to add.NullPointerException
- if f
is null
.public TIFFField getTIFFField(int tagNumber)
tagNumber
- The tag number of the tag associated with the field.TIFFField
with the requested tag number of null
if no such field is present.public void removeTIFFField(int tagNumber)
tagNumber
- The tag number of the tag associated with the field.public TIFFField[] getTIFFFields()
public void removeTIFFFields()
public IIOMetadata getAsMetadata()
TIFFDirectory
.public TIFFDirectory clone() throws CloneNotSupportedException
clone
in class Object
TIFFDirectory
.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/TIFFDirectory.html