| java.lang.Object javax.imageio.spi.IIOServiceProvider javax.imageio.spi.ImageReaderWriterSpi javax.imageio.spi.ImageReaderSpi
ImageReaderSpi | abstract public class ImageReaderSpi extends ImageReaderWriterSpi (Code) | | The service provider interface (SPI) for ImageReader s.
For more information on service provider classes, see the class comment
for the IIORegistry class.
Each ImageReaderSpi provides several types of information
about the ImageReader class with which it is associated.
The name of the vendor who defined the SPI class and a
brief description of the class are available via the
getVendorName , getDescription ,
and getVersion methods.
These methods may be internationalized to provide locale-specific
output. These methods are intended mainly to provide short,
human-readable information that might be used to organize a pop-up
menu or other list.
Lists of format names, file suffixes, and MIME types associated
with the service may be obtained by means of the
getFormatNames , getFileSuffixes , and
getMIMETypes methods. These methods may be used to
identify candidate ImageReader s for decoding a
particular file or stream based on manual format selection, file
naming, or MIME associations (for example, when accessing a file
over HTTP or as an email attachment).
A more reliable way to determine which ImageReader s
are likely to be able to parse a particular data stream is provided
by the canDecodeInput method. This methods allows the
service provider to inspect the actual stream contents.
Finally, an instance of the ImageReader class
associated with this service provider may be obtained by calling
the createReaderInstance method. Any heavyweight
initialization, such as the loading of native libraries or creation
of large tables, should be deferred at least until the first
invocation of this method.
See Also: IIORegistry See Also: javax.imageio.ImageReader version: 0.5 |
Field Summary | |
final public static Class[] | STANDARD_INPUT_TYPE A single-element array, initially containing
ImageInputStream.class , to be returned from
getInputTypes . | protected Class[] | inputTypes An array of Class objects to be returned from
getInputTypes , initially null . | protected String[] | writerSpiNames An array of strings to be returned from
getImageWriterSpiNames , initially
null . |
Constructor Summary | |
protected | ImageReaderSpi() Constructs a blank ImageReaderSpi . | public | ImageReaderSpi(String vendorName, String version, String[] names, String[] suffixes, String[] MIMETypes, String readerClassName, Class[] inputTypes, String[] writerSpiNames, boolean supportsStandardStreamMetadataFormat, String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName, String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames, boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName, String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames, String[] extraImageMetadataFormatClassNames) Constructs an ImageReaderSpi with a given
set of values.
Parameters: vendorName - the vendor name, as a non-null String . Parameters: version - a version identifier, as a non-null String . Parameters: names - a non-null array ofString s indicating the format names. |
Method Summary | |
abstract public boolean | canDecodeInput(Object source) Returns true if the supplied source object appears
to be of the format supported by this reader. | public ImageReader | createReaderInstance() Returns an instance of the ImageReader
implementation associated with this service provider. | abstract public ImageReader | createReaderInstance(Object extension) Returns an instance of the ImageReader
implementation associated with this service provider.
The returned object will initially be in an initial state
as if its reset method had been called.
An Object may be supplied to the plug-in at
construction time. | public String[] | getImageWriterSpiNames() Returns an array of String s containing the fully
qualified names of all the ImageWriterSpi classes
that can understand the internal metadata representation used
by the ImageReader associated with this service
provider, or null if there are no such
ImageWriter s specified. | public Class[] | getInputTypes() Returns an array of Class objects indicating what
types of objects may be used as arguments to the reader's
setInput method. | public boolean | isOwnReader(ImageReader reader) Returns true if the ImageReader object
passed in is an instance of the ImageReader
associated with this service provider.
The default implementation compares the fully-qualified
class name of the reader argument with the class
name passed into the constructor. |
STANDARD_INPUT_TYPE | final public static Class[] STANDARD_INPUT_TYPE(Code) | | A single-element array, initially containing
ImageInputStream.class , to be returned from
getInputTypes .
|
inputTypes | protected Class[] inputTypes(Code) | | An array of Class objects to be returned from
getInputTypes , initially null .
|
writerSpiNames | protected String[] writerSpiNames(Code) | | An array of strings to be returned from
getImageWriterSpiNames , initially
null .
|
ImageReaderSpi | protected ImageReaderSpi()(Code) | | Constructs a blank ImageReaderSpi . It is up to
the subclass to initialize instance variables and/or override
method implementations in order to provide working versions of
all methods.
|
ImageReaderSpi | public ImageReaderSpi(String vendorName, String version, String[] names, String[] suffixes, String[] MIMETypes, String readerClassName, Class[] inputTypes, String[] writerSpiNames, boolean supportsStandardStreamMetadataFormat, String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName, String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames, boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName, String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames, String[] extraImageMetadataFormatClassNames)(Code) | | Constructs an ImageReaderSpi with a given
set of values.
Parameters: vendorName - the vendor name, as a non-null String . Parameters: version - a version identifier, as a non-null String . Parameters: names - a non-null array ofString s indicating the format names. At least oneentry must be present. Parameters: suffixes - an array of String s indicating thecommon file suffixes. If no suffixes are defined,null should be supplied. An array of length 0will be normalized to null . Parameters: MIMETypes - an array of String s indicatingthe format's MIME types. If no MIME types are defined,null should be supplied. An array of length 0will be normalized to null . Parameters: readerClassName - the fully-qualified name of theassociated ImageReader class, as anon-null String . Parameters: inputTypes - a non-null array ofClass objects of length at least 1 indicating thelegal input types. Parameters: writerSpiNames - an array String s naming theclasses of all associated ImageWriter s, ornull . An array of length 0 is normalized tonull . Parameters: supportsStandardStreamMetadataFormat - aboolean that indicates whether a stream metadataobject can use trees described by the standard metadata format. Parameters: nativeStreamMetadataFormatName - aString , or null , to be returned fromgetNativeStreamMetadataFormatName . Parameters: nativeStreamMetadataFormatClassName - aString , or null , to be used to instantiatea metadata format object to be returned fromgetNativeStreamMetadataFormat . Parameters: extraStreamMetadataFormatNames - an array ofString s, or null , to be returned fromgetExtraStreamMetadataFormatNames . An array of length0 is normalized to null . Parameters: extraStreamMetadataFormatClassNames - an array ofString s, or null , to be used to instantiatea metadata format object to be returned fromgetStreamMetadataFormat . An array of length0 is normalized to null . Parameters: supportsStandardImageMetadataFormat - aboolean that indicates whether an image metadataobject can use trees described by the standard metadata format. Parameters: nativeImageMetadataFormatName - aString , or null , to be returned fromgetNativeImageMetadataFormatName . Parameters: nativeImageMetadataFormatClassName - aString , or null , to be used to instantiatea metadata format object to be returned fromgetNativeImageMetadataFormat . Parameters: extraImageMetadataFormatNames - an array ofString s to be returned fromgetExtraImageMetadataFormatNames . An array of length 0is normalized to null . Parameters: extraImageMetadataFormatClassNames - an array ofString s, or null , to be used to instantiatea metadata format object to be returned fromgetImageMetadataFormat . An array of length0 is normalized to null . exception: IllegalArgumentException - if vendorName is null . exception: IllegalArgumentException - if version is null . exception: IllegalArgumentException - if names is null or has length 0. exception: IllegalArgumentException - if readerClassName is null . exception: IllegalArgumentException - if inputTypes is null or has length 0. |
canDecodeInput | abstract public boolean canDecodeInput(Object source) throws IOException(Code) | | Returns true if the supplied source object appears
to be of the format supported by this reader. Returning
true from this method does not guarantee that
reading will succeed, only that there appears to be a
reasonable chance of success based on a brief inspection of the
stream contents. If the source is an
ImageInputStream , implementations will commonly
check the first several bytes of the stream for a "magic
number" associated with the format. Once actual reading has
commenced, the reader may still indicate failure at any time
prior to the completion of decoding.
It is important that the state of the object not be
disturbed in order that other ImageReaderSpi s can
properly determine whether they are able to decode the object.
In particular, if the source is an
ImageInputStream , a
mark /reset pair should be used to
preserve the stream position.
Formats such as "raw," which can potentially attempt
to read nearly any stream, should return false
in order to avoid being invoked in preference to a closer
match.
If source is not an instance of one of the
classes returned by getInputTypes , the method
should simply return false .
Parameters: source - the object (typically anImageInputStream ) to be decoded. true if it is likely that this stream canbe decoded. exception: IllegalArgumentException - if source isnull . exception: IOException - if an I/O error occurs while reading thestream. |
createReaderInstance | public ImageReader createReaderInstance() throws IOException(Code) | | Returns an instance of the ImageReader
implementation associated with this service provider.
The returned object will initially be in an initial state
as if its reset method had been called.
The default implementation simply returns
createReaderInstance(null) .
an ImageReader instance. exception: IOException - if an error occurs during loading, or initialization of the reader class, or during instantiationor initialization of the reader object. |
createReaderInstance | abstract public ImageReader createReaderInstance(Object extension) throws IOException(Code) | | Returns an instance of the ImageReader
implementation associated with this service provider.
The returned object will initially be in an initial state
as if its reset method had been called.
An Object may be supplied to the plug-in at
construction time. The nature of the object is entirely
plug-in specific.
Typically, a plug-in will implement this method using code
such as return new MyImageReader(this) .
Parameters: extension - a plug-in specific extension object, which maybe null . an ImageReader instance. exception: IOException - if the attempt to instantiatethe reader fails. exception: IllegalArgumentException - if theImageReader 's contructor throws anIllegalArgumentException to indicate that theextension object is unsuitable. |
getImageWriterSpiNames | public String[] getImageWriterSpiNames()(Code) | | Returns an array of String s containing the fully
qualified names of all the ImageWriterSpi classes
that can understand the internal metadata representation used
by the ImageReader associated with this service
provider, or null if there are no such
ImageWriter s specified. If a
non-null value is returned, it must have non-zero
length.
The first item in the array must be the name of the service
provider for the "preferred" writer, as it will be used to
instantiate the ImageWriter returned by
ImageIO.getImageWriter(ImageReader) .
This mechanism may be used to obtain
ImageWriters that will understand the internal
structure of non-pixel meta-data (see
IIOTreeInfo ) generated by an
ImageReader . By obtaining this data from the
ImageReader and passing it on to one of the
ImageWriters obtained with this method, a client
program can read an image, modify it in some way, and write it
back out while preserving all meta-data, without having to
understand anything about the internal structure of the
meta-data, or even about the image format.
an array of String s of length at least 1containing names of ImageWriterSpi , ornull . See Also: javax.imageio.ImageIO.getImageWriter(ImageReader) |
getInputTypes | public Class[] getInputTypes()(Code) | | Returns an array of Class objects indicating what
types of objects may be used as arguments to the reader's
setInput method.
For most readers, which only accept input from an
ImageInputStream , a single-element array
containing ImageInputStream.class should be
returned.
a non-null array ofClass objects of length at least 1. |
isOwnReader | public boolean isOwnReader(ImageReader reader)(Code) | | Returns true if the ImageReader object
passed in is an instance of the ImageReader
associated with this service provider.
The default implementation compares the fully-qualified
class name of the reader argument with the class
name passed into the constructor. This method may be overridden
if more sophisticated checking is required.
Parameters: reader - an ImageReader instance. true if reader is recognized. exception: IllegalArgumentException - if reader isnull . |
|
|