Class ImageReaderSpi
- All Implemented Interfaces:
- RegisterableService
ImageReaders.
 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 ImageReaders 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 ImageReaders
 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:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Class<?>[]An array ofClassobjects to be returned fromgetInputTypes, initiallynull.static final Class<?>[]Deprecated.protected String[]An array of strings to be returned fromgetImageWriterSpiNames, initiallynull.Fields declared in class javax.imageio.spi.ImageReaderWriterSpiextraImageMetadataFormatClassNames, extraImageMetadataFormatNames, extraStreamMetadataFormatClassNames, extraStreamMetadataFormatNames, MIMETypes, names, nativeImageMetadataFormatClassName, nativeImageMetadataFormatName, nativeStreamMetadataFormatClassName, nativeStreamMetadataFormatName, pluginClassName, suffixes, supportsStandardImageMetadataFormat, supportsStandardStreamMetadataFormatFields declared in class javax.imageio.spi.IIOServiceProvidervendorName, version
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedConstructs a blankImageReaderSpi.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 anImageReaderSpiwith a given set of values.
- 
Method SummaryModifier and TypeMethodDescriptionabstract booleancanDecodeInput(Object source) Returnstrueif the supplied source object appears to be of the format supported by this reader.Returns an instance of theImageReaderimplementation associated with this service provider.abstract ImageReadercreateReaderInstance(Object extension) Returns an instance of theImageReaderimplementation associated with this service provider.String[]Returns an array ofStrings containing the fully qualified names of all theImageWriterSpiclasses that can understand the internal metadata representation used by theImageReaderassociated with this service provider, ornullif there are no suchImageWriters specified.Class<?>[]Returns an array ofClassobjects indicating what types of objects may be used as arguments to the reader'ssetInputmethod.booleanisOwnReader(ImageReader reader) Returnstrueif theImageReaderobject passed in is an instance of theImageReaderassociated with this service provider.Methods declared in class javax.imageio.spi.ImageReaderWriterSpigetExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getImageMetadataFormat, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, getStreamMetadataFormat, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupportedMethods declared in class javax.imageio.spi.IIOServiceProvidergetDescription, getVendorName, getVersion, onDeregistration, onRegistration
- 
Field Details- 
STANDARD_INPUT_TYPEDeprecated.Instead of using this field, directly create the equivalent array{ ImageInputStream.class }.A single-element array, initially containingImageInputStream.class, to be returned fromgetInputTypes.
- 
inputTypesAn array ofClassobjects to be returned fromgetInputTypes, initiallynull.
- 
writerSpiNamesAn array of strings to be returned fromgetImageWriterSpiNames, initiallynull.
 
- 
- 
Constructor Details- 
ImageReaderSpiprotected ImageReaderSpi()Constructs a blankImageReaderSpi. It is up to the subclass to initialize instance variables and/or override method implementations in order to provide working versions of all methods.
- 
ImageReaderSpipublic 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 anImageReaderSpiwith a given set of values.- Parameters:
- vendorName- the vendor name, as a non-- null- String.
- version- a version identifier, as a non-- null- String.
- names- a non-- nullarray of- Strings indicating the format names. At least one entry must be present.
- suffixes- an array of- Strings indicating the common file suffixes. If no suffixes are defined,- nullshould be supplied. An array of length 0 will be normalized to- null.
- MIMETypes- an array of- Strings indicating the format's MIME types. If no MIME types are defined,- nullshould be supplied. An array of length 0 will be normalized to- null.
- readerClassName- the fully-qualified name of the associated- ImageReaderclass, as a non-- null String.
- inputTypes- a non-- nullarray of- Classobjects of length at least 1 indicating the legal input types.
- writerSpiNames- an array- Strings naming the classes of all associated- ImageWriters, or- null. An array of length 0 is normalized to- null.
- supportsStandardStreamMetadataFormat- a- booleanthat indicates whether a stream metadata object can use trees described by the standard metadata format.
- nativeStreamMetadataFormatName- a- String, or- null, to be returned from- getNativeStreamMetadataFormatName.
- nativeStreamMetadataFormatClassName- a- String, or- null, to be used to instantiate a metadata format object to be returned from- getNativeStreamMetadataFormat.
- extraStreamMetadataFormatNames- an array of- Strings, or- null, to be returned from- getExtraStreamMetadataFormatNames. An array of length 0 is normalized to- null.
- extraStreamMetadataFormatClassNames- an array of- Strings, or- null, to be used to instantiate a metadata format object to be returned from- getStreamMetadataFormat. An array of length 0 is normalized to- null.
- supportsStandardImageMetadataFormat- a- booleanthat indicates whether an image metadata object can use trees described by the standard metadata format.
- nativeImageMetadataFormatName- a- String, or- null, to be returned from- getNativeImageMetadataFormatName.
- nativeImageMetadataFormatClassName- a- String, or- null, to be used to instantiate a metadata format object to be returned from- getNativeImageMetadataFormat.
- extraImageMetadataFormatNames- an array of- Strings to be returned from- getExtraImageMetadataFormatNames. An array of length 0 is normalized to- null.
- extraImageMetadataFormatClassNames- an array of- Strings, or- null, to be used to instantiate a metadata format object to be returned from- getImageMetadataFormat. An array of length 0 is normalized to- null.
- Throws:
- IllegalArgumentException- if- vendorNameis- null.
- IllegalArgumentException- if- versionis- null.
- IllegalArgumentException- if- namesis- nullor has length 0.
- IllegalArgumentException- if- readerClassNameis- null.
- IllegalArgumentException- if- inputTypesis- nullor has length 0.
 
 
- 
- 
Method Details- 
getInputTypesReturns an array ofClassobjects indicating what types of objects may be used as arguments to the reader'ssetInputmethod.For most readers, which only accept input from an ImageInputStream, a single-element array containingImageInputStream.classshould be returned.- Returns:
- a non-nullarray ofClassobjects of length at least 1.
 
- 
canDecodeInputReturnstrueif the supplied source object appears to be of the format supported by this reader. Returningtruefrom 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 anImageInputStream, 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 ImageReaderSpis can properly determine whether they are able to decode the object. In particular, if the source is anImageInputStream, amark/resetpair should be used to preserve the stream position.Formats such as "raw," which can potentially attempt to read nearly any stream, should return falsein order to avoid being invoked in preference to a closer match.If sourceis not an instance of one of the classes returned bygetInputTypes, the method should simply returnfalse.- Parameters:
- source- the object (typically an- ImageInputStream) to be decoded.
- Returns:
- trueif it is likely that this stream can be decoded.
- Throws:
- IllegalArgumentException- if- sourceis- null.
- IOException- if an I/O error occurs while reading the stream.
 
- 
createReaderInstanceReturns an instance of theImageReaderimplementation associated with this service provider. The returned object will initially be in an initial state as if itsresetmethod had been called.The default implementation simply returns createReaderInstance(null).- Returns:
- an ImageReaderinstance.
- Throws:
- IOException- if an error occurs during loading, or initialization of the reader class, or during instantiation or initialization of the reader object.
 
- 
createReaderInstanceReturns an instance of theImageReaderimplementation associated with this service provider. The returned object will initially be in an initial state as if itsresetmethod had been called.An Objectmay 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 may be- null.
- Returns:
- an ImageReaderinstance.
- Throws:
- IOException- if the attempt to instantiate the reader fails.
- IllegalArgumentException- if the- ImageReader's constructor throws an- IllegalArgumentExceptionto indicate that the extension object is unsuitable.
 
- 
isOwnReaderReturnstrueif theImageReaderobject passed in is an instance of theImageReaderassociated with this service provider.The default implementation compares the fully-qualified class name of the readerargument with the class name passed into the constructor. This method may be overridden if more sophisticated checking is required.- Parameters:
- reader- an- ImageReaderinstance.
- Returns:
- trueif- readeris recognized.
- Throws:
- IllegalArgumentException- if- readeris- null.
 
- 
getImageWriterSpiNamesReturns an array ofStrings containing the fully qualified names of all theImageWriterSpiclasses that can understand the internal metadata representation used by theImageReaderassociated with this service provider, ornullif there are no suchImageWriters specified. If a non-nullvalue 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 ImageWriterreturned byImageIO.getImageWriter(ImageReader).This mechanism may be used to obtain ImageWritersthat will understand the internal structure of non-pixel meta-data (seeIIOTreeInfo) generated by anImageReader. By obtaining this data from theImageReaderand passing it on to one of theImageWritersobtained 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.- Returns:
- an array of Strings of length at least 1 containing names ofImageWriterSpi, ornull.
- See Also:
 
 
- 
{ ImageInputStream.class }.