IIOMetadataNode
objects that
support the XML DOM interfaces as well as additional interfaces for
storing non-textual data and retrieving information about legal
data values. The format of such trees is plug-in dependent, but
plug-ins may choose to support a plug-in neutral format described
below. A single plug-in may support multiple metadata formats,
whose names maybe determined by calling
getMetadataFormatNames
. The plug-in may also support
a single special format, referred to as the "native" format, which
is designed to encode its metadata losslessly. This format will
typically be designed specifically to work with a specific file
format, so that images may be loaded and saved in the same format
with no loss of metadata, but may be less useful for transferring
metadata between an ImageReader
and an
ImageWriter
for different image formats. To convert
between two native formats as losslessly as the image file formats
will allow, an ImageTranscoder
object must be used.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected IIOMetadataController
TheIIOMetadataController
that will be used to provide settings for thisIIOMetadata
object when theactivateController
method is called.protected IIOMetadataController
AnIIOMetadataController
that is suggested for use as the controller for thisIIOMetadata
object.protected String[]
An array of names of classes implementingIIOMetadataFormat
and representing the metadata formats, other than the standard and native formats, that are supported by this plug-in, initialized tonull
and set via the constructor.protected String[]
An array of names of formats, other than the standard and native formats, that are supported by this plug-in, initialized tonull
and set via the constructor.protected String
The name of the class implementingIIOMetadataFormat
and representing the native metadata format, initialized tonull
and set via the constructor.protected String
The name of the native metadata format for this object, initialized tonull
and set via the constructor.protected boolean
A boolean indicating whether the concrete subclass supports the standard metadata format, set via the constructor. -
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs an emptyIIOMetadata
object.protected
IIOMetadata
(boolean standardMetadataFormatSupported, String nativeMetadataFormatName, String nativeMetadataFormatClassName, String[] extraMetadataFormatNames, String[] extraMetadataFormatClassNames) Constructs anIIOMetadata
object with the given format names and format class names, as well as a boolean indicating whether the standard format is supported. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Activates the installedIIOMetadataController
for thisIIOMetadata
object and returns the resulting value.abstract Node
Returns an XML DOMNode
object that represents the root of a tree of metadata contained within this object according to the conventions defined by a given metadata format.Returns whateverIIOMetadataController
is currently installed.Returns the defaultIIOMetadataController
, if there is one, regardless of the currently installed controller.String[]
Returns an array ofString
s containing the names of additional metadata formats, other than the native and standard formats, recognized by this plug-in'sgetAsTree
,setFromTree
, andmergeTree
methods.getMetadataFormat
(String formatName) Returns anIIOMetadataFormat
object describing the given metadata format, ornull
if no description is available.String[]
Returns an array ofString
s containing the names of all metadata formats, including the native and standard formats, recognized by this plug-in'sgetAsTree
,setFromTree
, andmergeTree
methods.Returns the name of the "native" metadata format for this plug-in, which typically allows for lossless encoding and transmission of the metadata stored in the format handled by this plug-in.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the chroma information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the compression information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the data format information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the dimension information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the document information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the textual information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the tiling information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected IIOMetadataNode
Returns anIIOMetadataNode
representing the transparency information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available.protected final IIOMetadataNode
A utility method to return a tree ofIIOMetadataNode
s representing the metadata contained within this object according to the conventions of the standardjavax_imageio_1.0
metadata format.boolean
Returnstrue
if there is a controller installed for thisIIOMetadata
object.abstract boolean
Returnstrue
if this object does not support themergeTree
,setFromTree
, andreset
methods.boolean
Returnstrue
if the standard metadata format is supported bygetMetadataFormat
,getAsTree
,setFromTree
, andmergeTree
.abstract void
Alters the internal state of thisIIOMetadata
object from a tree of XML DOMNode
s whose syntax is defined by the given metadata format.abstract void
reset()
Resets all the data stored in this object to default values, usually to the state this object was in immediately after construction, though the precise semantics are plug-in specific.void
setController
(IIOMetadataController controller) Sets theIIOMetadataController
to be used to provide settings for thisIIOMetadata
object when theactivateController
method is called, overriding any default controller.void
setFromTree
(String formatName, Node root) Sets the internal state of thisIIOMetadata
object from a tree of XML DOMNode
s whose syntax is defined by the given metadata format.
-
Field Details
-
standardFormatSupported
protected boolean standardFormatSupportedA boolean indicating whether the concrete subclass supports the standard metadata format, set via the constructor. -
nativeMetadataFormatName
The name of the native metadata format for this object, initialized tonull
and set via the constructor. -
nativeMetadataFormatClassName
The name of the class implementingIIOMetadataFormat
and representing the native metadata format, initialized tonull
and set via the constructor. -
extraMetadataFormatNames
An array of names of formats, other than the standard and native formats, that are supported by this plug-in, initialized tonull
and set via the constructor. -
extraMetadataFormatClassNames
An array of names of classes implementingIIOMetadataFormat
and representing the metadata formats, other than the standard and native formats, that are supported by this plug-in, initialized tonull
and set via the constructor. -
defaultController
AnIIOMetadataController
that is suggested for use as the controller for thisIIOMetadata
object. It may be retrieved viagetDefaultController
. To install the default controller, callsetController(getDefaultController())
. This instance variable should be set by subclasses that choose to provide their own default controller, usually a GUI, for setting parameters.- See Also:
-
controller
TheIIOMetadataController
that will be used to provide settings for thisIIOMetadata
object when theactivateController
method is called. This value overrides any default controller, even whennull
.- See Also:
-
-
Constructor Details
-
IIOMetadata
protected IIOMetadata()Constructs an emptyIIOMetadata
object. The subclass is responsible for supplying values for all protected instance variables that will allow any non-overridden default implementations of methods to satisfy their contracts. For example,extraMetadataFormatNames
should not have length 0. -
IIOMetadata
protected IIOMetadata(boolean standardMetadataFormatSupported, String nativeMetadataFormatName, String nativeMetadataFormatClassName, String[] extraMetadataFormatNames, String[] extraMetadataFormatClassNames) Constructs anIIOMetadata
object with the given format names and format class names, as well as a boolean indicating whether the standard format is supported.This constructor does not attempt to check the class names for validity. Invalid class names may cause exceptions in subsequent calls to
getMetadataFormat
.- Parameters:
standardMetadataFormatSupported
-true
if this object can return or accept a DOM tree using the standard metadata format.nativeMetadataFormatName
- the name of the native metadata format, as aString
, ornull
if there is no native format.nativeMetadataFormatClassName
- the name of the class of the native metadata format, ornull
if there is no native format.extraMetadataFormatNames
- an array ofString
s indicating additional formats supported by this object, ornull
if there are none.extraMetadataFormatClassNames
- an array ofString
s indicating the class names of any additional formats supported by this object, ornull
if there are none.- Throws:
IllegalArgumentException
- ifextraMetadataFormatNames
has length 0.IllegalArgumentException
- ifextraMetadataFormatNames
andextraMetadataFormatClassNames
are neither bothnull
, nor of the same length.
-
-
Method Details
-
isStandardMetadataFormatSupported
public boolean isStandardMetadataFormatSupported()Returnstrue
if the standard metadata format is supported bygetMetadataFormat
,getAsTree
,setFromTree
, andmergeTree
.The default implementation returns the value of the
standardFormatSupported
instance variable.- Returns:
true
if the standard metadata format is supported.- See Also:
-
isReadOnly
public abstract boolean isReadOnly()Returnstrue
if this object does not support themergeTree
,setFromTree
, andreset
methods.- Returns:
- true if this
IIOMetadata
object cannot be modified.
-
getNativeMetadataFormatName
Returns the name of the "native" metadata format for this plug-in, which typically allows for lossless encoding and transmission of the metadata stored in the format handled by this plug-in. If no such format is supported,null
will be returned.The structure and contents of the "native" metadata format are defined by the plug-in that created this
IIOMetadata
object. Plug-ins for simple formats will usually create a dummy node for the root, and then a series of child nodes representing individual tags, chunks, or keyword/value pairs. A plug-in may choose whether or not to document its native format.The default implementation returns the value of the
nativeMetadataFormatName
instance variable.- Returns:
- the name of the native format, or
null
. - See Also:
-
getExtraMetadataFormatNames
Returns an array ofString
s containing the names of additional metadata formats, other than the native and standard formats, recognized by this plug-in'sgetAsTree
,setFromTree
, andmergeTree
methods. If there are no such additional formats,null
is returned.The default implementation returns a clone of the
extraMetadataFormatNames
instance variable.- Returns:
- an array of
String
s with length at least 1, ornull
. - See Also:
-
getMetadataFormatNames
Returns an array ofString
s containing the names of all metadata formats, including the native and standard formats, recognized by this plug-in'sgetAsTree
,setFromTree
, andmergeTree
methods. If there are no such formats,null
is returned.The default implementation calls
getNativeMetadataFormatName
,isStandardMetadataFormatSupported
, andgetExtraMetadataFormatNames
and returns the combined results.- Returns:
- an array of
String
s. - See Also:
-
getMetadataFormat
Returns anIIOMetadataFormat
object describing the given metadata format, ornull
if no description is available. The supplied name must be one of those returned bygetMetadataFormatNames
(i.e., either the native format name, the standard format name, or one of those returned bygetExtraMetadataFormatNames
).The default implementation checks the name against the global standard metadata format name, and returns that format if it is supported. Otherwise, it checks against the native format names followed by any additional format names. If a match is found, it retrieves the name of the
IIOMetadataFormat
class fromnativeMetadataFormatClassName
orextraMetadataFormatClassNames
as appropriate, and constructs an instance of that class using itsgetInstance
method.- Parameters:
formatName
- the desired metadata format.- Returns:
- an
IIOMetadataFormat
object. - Throws:
IllegalArgumentException
- ifformatName
isnull
or is not one of the names recognized by the plug-in.IllegalStateException
- if the class corresponding to the format name cannot be loaded.
-
getAsTree
Returns an XML DOMNode
object that represents the root of a tree of metadata contained within this object according to the conventions defined by a given metadata format.The names of the available metadata formats may be queried using the
getMetadataFormatNames
method.- Parameters:
formatName
- the desired metadata format.- Returns:
- an XML DOM
Node
object forming the root of a tree. - Throws:
IllegalArgumentException
- ifformatName
isnull
or is not one of the names returned bygetMetadataFormatNames
.- See Also:
-
mergeTree
Alters the internal state of thisIIOMetadata
object from a tree of XML DOMNode
s whose syntax is defined by the given metadata format. The previous state is altered only as necessary to accommodate the nodes that are present in the given tree. If the tree structure or contents are invalid, anIIOInvalidTreeException
will be thrown.As the semantics of how a tree or subtree may be merged with another tree are completely format-specific, plug-in authors may implement this method in whatever manner is most appropriate for the format, including simply replacing all existing state with the contents of the given tree.
- Parameters:
formatName
- the desired metadata format.root
- an XML DOMNode
object forming the root of a tree.- Throws:
IllegalStateException
- if this object is read-only.IllegalArgumentException
- ifformatName
isnull
or is not one of the names returned bygetMetadataFormatNames
.IllegalArgumentException
- ifroot
isnull
.IIOInvalidTreeException
- if the tree cannot be parsed successfully using the rules of the given format.- See Also:
-
getStandardChromaNode
Returns anIIOMetadataNode
representing the chroma information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardCompressionNode
Returns anIIOMetadataNode
representing the compression information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardDataNode
Returns anIIOMetadataNode
representing the data format information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardDimensionNode
Returns anIIOMetadataNode
representing the dimension information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardDocumentNode
Returns anIIOMetadataNode
representing the document information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardTextNode
Returns anIIOMetadataNode
representing the textual information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardTileNode
Returns anIIOMetadataNode
representing the tiling information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
. - See Also:
-
getStandardTransparencyNode
Returns anIIOMetadataNode
representing the transparency information of the standardjavax_imageio_1.0
metadata format, ornull
if no such information is available. This method is intended to be called by the utility routinegetStandardTree
.The default implementation returns
null
.Subclasses should override this method to produce an appropriate subtree if they wish to support the standard metadata format.
- Returns:
- an
IIOMetadataNode
, ornull
.
-
getStandardTree
A utility method to return a tree ofIIOMetadataNode
s representing the metadata contained within this object according to the conventions of the standardjavax_imageio_1.0
metadata format.This method calls the various
getStandard*Node
methods to supply each of the subtrees rooted at the children of the root node. If any of those methods returnsnull
, the corresponding subtree will be omitted. If all of them returnnull
, a tree consisting of a single root node will be returned.- Returns:
- an
IIOMetadataNode
representing the root of a metadata tree in thejavax_imageio_1.0
format. - See Also:
-
setFromTree
Sets the internal state of thisIIOMetadata
object from a tree of XML DOMNode
s whose syntax is defined by the given metadata format. The previous state is discarded. If the tree's structure or contents are invalid, anIIOInvalidTreeException
will be thrown.The default implementation calls
reset
followed bymergeTree(formatName, root)
.- Parameters:
formatName
- the desired metadata format.root
- an XML DOMNode
object forming the root of a tree.- Throws:
IllegalStateException
- if this object is read-only.IllegalArgumentException
- ifformatName
isnull
or is not one of the names returned bygetMetadataFormatNames
.IllegalArgumentException
- ifroot
isnull
.IIOInvalidTreeException
- if the tree cannot be parsed successfully using the rules of the given format.- See Also:
-
reset
public abstract void reset()Resets all the data stored in this object to default values, usually to the state this object was in immediately after construction, though the precise semantics are plug-in specific. Note that there are many possible default values, depending on how the object was created.- Throws:
IllegalStateException
- if this object is read-only.- See Also:
-
setController
Sets theIIOMetadataController
to be used to provide settings for thisIIOMetadata
object when theactivateController
method is called, overriding any default controller. If the argument isnull
, no controller will be used, including any default. To restore the default, usesetController(getDefaultController())
.The default implementation sets the
controller
instance variable to the supplied value.- Parameters:
controller
- An appropriateIIOMetadataController
, ornull
.- See Also:
-
getController
Returns whateverIIOMetadataController
is currently installed. This could be the default if there is one,null
, or the argument of the most recent call tosetController
.The default implementation returns the value of the
controller
instance variable.- Returns:
- the currently installed
IIOMetadataController
, ornull
. - See Also:
-
getDefaultController
Returns the defaultIIOMetadataController
, if there is one, regardless of the currently installed controller. If there is no default controller, returnsnull
.The default implementation returns the value of the
defaultController
instance variable.- Returns:
- the default
IIOMetadataController
, ornull
. - See Also:
-
hasController
public boolean hasController()Returnstrue
if there is a controller installed for thisIIOMetadata
object.The default implementation returns
true
if thegetController
method returns a non-null
value.- Returns:
true
if a controller is installed.- See Also:
-
activateController
public boolean activateController()Activates the installedIIOMetadataController
for thisIIOMetadata
object and returns the resulting value. When this method returnstrue
, all values for thisIIOMetadata
object will be ready for the next write operation. Iffalse
is returned, no settings in this object will have been disturbed (i.e., the user canceled the operation).Ordinarily, the controller will be a GUI providing a user interface for a subclass of
IIOMetadata
for a particular plug-in. Controllers need not be GUIs, however.The default implementation calls
getController
and the callsactivate
on the returned object ifhasController
returnstrue
.- Returns:
true
if the controller completed normally.- Throws:
IllegalStateException
- if there is no controller currently installed.- See Also:
-