- All Implemented Interfaces:
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.
- Since:
- 9
- See Also:
-
Constructor Summary
ConstructorDescriptionTIFFDirectory
(TIFFTagSet[] tagSets, TIFFTag parentTag) Constructs aTIFFDirectory
which is aware of a given group ofTIFFTagSet
s. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTagSet
(TIFFTagSet tagSet) Adds an element to the group ofTIFFTagSet
s of which this directory is aware.void
Adds a TIFF field to the directory.clone()
Clones the directory and all the fields contained therein.boolean
containsTIFFField
(int tagNumber) Determines whether a TIFF field with the given tag number is contained in this directory.static TIFFDirectory
createFromMetadata
(IIOMetadata tiffImageMetadata) Creates aTIFFDirectory
instance from the contents of an image metadata object.Converts the directory to a metadata object.int
Returns the number ofTIFFField
s in this directory.Returns the parentTIFFTag
of this directory if one has been defined ornull
otherwise.getTag
(int tagNumber) Returns theTIFFTag
which has tag number equal totagNumber
ornull
if no such tag exists in theTIFFTagSet
s associated with this directory.Returns theTIFFTagSet
s of which this directory is aware.getTIFFField
(int tagNumber) Retrieves a TIFF field from the directory.Retrieves all TIFF fields from the directory.void
removeTagSet
(TIFFTagSet tagSet) Removes an element from the group ofTIFFTagSet
s of which this directory is aware.void
removeTIFFField
(int tagNumber) Removes a TIFF field from the directory.void
Removes all TIFF fields from the directory.
-
Constructor Details
-
TIFFDirectory
Constructs aTIFFDirectory
which is aware of a given group ofTIFFTagSet
s. An optional parentTIFFTag
may also be specified.- Parameters:
tagSets
- TheTIFFTagSets
associated with this directory.parentTag
- The parentTIFFTag
of this directory; may benull
.- Throws:
NullPointerException
- iftagSets
isnull
.
-
-
Method Details
-
createFromMetadata
public static TIFFDirectory createFromMetadata(IIOMetadata tiffImageMetadata) throws IIOInvalidTreeException Creates aTIFFDirectory
instance from the contents of an image metadata object. The supplied object must support an image metadata format supported by the TIFFImageWriter
plug-in. This will usually be either the TIFF native image metadata formatjavax_imageio_tiff_image_1.0
or the Java Image I/O standard metadata formatjavax_imageio_1.0
.- Parameters:
tiffImageMetadata
- A metadata object which supports a compatible image metadata format.- Returns:
- A
TIFFDirectory
populated from the contents of the supplied metadata object. - Throws:
NullPointerException
- iftiffImageMetadata
isnull
.IllegalArgumentException
- iftiffImageMetadata
does not support a compatible image metadata format.IIOInvalidTreeException
- if the supplied metadata object cannot be parsed.
-
getTagSets
Returns theTIFFTagSet
s of which this directory is aware.- Returns:
- The
TIFFTagSet
s associated with thisTIFFDirectory
.
-
addTagSet
Adds an element to the group ofTIFFTagSet
s of which this directory is aware.- Parameters:
tagSet
- TheTIFFTagSet
to add.- Throws:
NullPointerException
- iftagSet
isnull
.
-
removeTagSet
Removes an element from the group ofTIFFTagSet
s of which this directory is aware.- Parameters:
tagSet
- TheTIFFTagSet
to remove.- Throws:
NullPointerException
- iftagSet
isnull
.
-
getParentTag
-
getTag
Returns theTIFFTag
which has tag number equal totagNumber
ornull
if no such tag exists in theTIFFTagSet
s associated with this directory.- Parameters:
tagNumber
- The tag number of interest.- Returns:
- The corresponding
TIFFTag
ornull
.
-
getNumTIFFFields
public int getNumTIFFFields()Returns the number ofTIFFField
s in this directory.- Returns:
- The number of
TIFFField
s in thisTIFFDirectory
.
-
containsTIFFField
public boolean containsTIFFField(int tagNumber) Determines whether a TIFF field with the given tag number is contained in this directory.- Parameters:
tagNumber
- The tag number.- Returns:
- Whether a
TIFFTag
with tag number equal totagNumber
is present in thisTIFFDirectory
.
-
addTIFFField
Adds a TIFF field to the directory.- Parameters:
f
- The field to add.- Throws:
NullPointerException
- iff
isnull
.
-
getTIFFField
Retrieves a TIFF field from the directory.- Parameters:
tagNumber
- The tag number of the tag associated with the field.- Returns:
- A
TIFFField
with the requested tag number ofnull
if no such field is present.
-
removeTIFFField
public void removeTIFFField(int tagNumber) Removes a TIFF field from the directory.- Parameters:
tagNumber
- The tag number of the tag associated with the field.
-
getTIFFFields
Retrieves all TIFF fields from the directory.- Returns:
- An array of all TIFF fields in order of numerically increasing tag number.
-
removeTIFFFields
public void removeTIFFFields()Removes all TIFF fields from the directory. -
getAsMetadata
Converts the directory to a metadata object.- Returns:
- A metadata instance initialized from the contents of this
TIFFDirectory
.
-
clone
Clones the directory and all the fields contained therein.- Overrides:
clone
in classObject
- Returns:
- A clone of this
TIFFDirectory
. - Throws:
CloneNotSupportedException
- if the instance cannot be cloned.- See Also:
-