|
Spec-Zone .ru
спецификации, руководства, описания, API
|
public abstract class ImageReaderSpi extends ImageReaderWriterSpi
ImageReaders. Для получения дополнительной информации по классам поставщика услуг см. комментарий class для IIORegistry class. Каждый ImageReaderSpi обеспечивает несколько типов информации о ImageReader class, с которым это связывается.
Имя поставщика, который определил SPI class и краткое описание class, доступно через getVendorName, getDescription, и getVersion методы. Эти методы могут интернационализироваться, чтобы обеспечить специфичный для локали вывод. Эти методы предназначаются, главным образом, чтобы предоставить короткую, удобочитаемую информацию, которая могла бы использоваться, чтобы организовать раскрывающееся меню или другой список.
Списки имен формата, суффиксов файла, и типов MIME, связанных со службой, могут быть получены посредством getFormatNames, getFileSuffixes, и getMIMETypes методы. Эти методы могут использоваться, чтобы идентифицировать кандидата ImageReaders для того, чтобы декодировать определенный файл или поток, основанный на ручном выборе формата, именовании файла, или ассоциациях MIME (например, получая доступ к файлу по HTTP или как присоединение электронной почты).
Более надежный способ определить, который ImageReaders, вероятно, будут в состоянии проанализировать определенный поток данных, обеспечивается canDecodeInput метод. Это методы позволяет поставщику услуг осматривать фактическое потоковое содержание.
Наконец, экземпляр ImageReader class, связанный с этим поставщиком услуг, может быть получен, вызывая createReaderInstance метод. Любая тяжелая инициализация, такая как загрузка собственных библиотек или создание больших таблиц, должна быть задержана, по крайней мере, до первого вызова этого метода.
IIORegistry, ImageReader| Модификатор и Тип | Поле и Описание |
|---|---|
protected Class[] |
inputTypes
Массив
Class объекты, которые будут возвращены из getInputTypes, первоначально null. |
static Class[] |
STANDARD_INPUT_TYPE
Осуждаемый.
Вместо того, чтобы использовать это поле, непосредственно создайте эквивалентный массив
{ ImageInputStream.class } |
protected String[] |
writerSpiNames
An array of strings to be returned from
getImageWriterSpiNames, initially null. |
extraImageMetadataFormatClassNames, extraImageMetadataFormatNames, extraStreamMetadataFormatClassNames, extraStreamMetadataFormatNames, MIMETypes, names, nativeImageMetadataFormatClassName, nativeImageMetadataFormatName, nativeStreamMetadataFormatClassName, nativeStreamMetadataFormatName, pluginClassName, suffixes, supportsStandardImageMetadataFormat, supportsStandardStreamMetadataFormatvendorName, version| Modifier | Constructor and Description |
|---|---|
protected |
ImageReaderSpi()
Constructs a blank
ImageReaderSpi. |
|
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. |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
canDecodeInput(Object source)
Returns
true if the supplied source object appears to be of the format supported by this reader. |
ImageReader |
createReaderInstance()
Returns an instance of the
ImageReader implementation associated with this service provider. |
abstract ImageReader |
createReaderInstance(Object extension)
Returns an instance of the
ImageReader implementation associated with this service provider. |
Строка[] |
getImageWriterSpiNames()
Returns an array of
Strings 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 ImageWriters specified. |
Класс[] |
getInputTypes()
Returns an array of
Class objects indicating what types of objects may be used as arguments to the reader's setInput method. |
boolean |
isOwnReader(ImageReader reader)
Returns
true if the ImageReader object passed in is an instance of the ImageReader associated with this service provider. |
getExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getImageMetadataFormat, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, getStreamMetadataFormat, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupportedgetDescription, getVendorName, getVersion, onDeregistration, onRegistration@Deprecated public static final Class[] STANDARD_INPUT_TYPE
{ ImageInputStream.class }.ImageInputStream.class, to be returned from getInputTypes.protected Class[] inputTypes
Class objects to be returned from getInputTypes, initially null.protected String[] writerSpiNames
getImageWriterSpiNames, initially null.protected ImageReaderSpi()
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.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)
ImageReaderSpi with a given set of values.vendorName - the vendor name, as a non-null
String.version - a version identifier, as a non-null
String.names - a non-null array 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, null should 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, null should be supplied. An array of length 0 will be normalized to null.readerClassName - the fully-qualified name of the associated ImageReader class, as a non-null String.inputTypes - a non-null array of Class objects 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 boolean that 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 boolean that 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.IllegalArgumentException - if vendorName is null.IllegalArgumentException - if version is null.IllegalArgumentException - if names is null or has length 0.IllegalArgumentException - if readerClassName is null.IllegalArgumentException - if inputTypes is null or has length 0.public Class[] getInputTypes()
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.
null array of Classobjects of length at least 1.public abstract boolean canDecodeInput(Object source) throws IOException
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 ImageReaderSpis 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.
source - the object (typically an ImageInputStream) to be decoded.true if it is likely that this stream can be decoded.IllegalArgumentException - if source is null.IOException - if an I/O error occurs while reading the stream.public ImageReader createReaderInstance() throws IOException
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).
ImageReader instance.IOException - if an error occurs during loading, or initialization of the reader class, or during instantiation or initialization of the reader object.public abstract ImageReader createReaderInstance(Object extension) throws IOException
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).
extension - a plug-in specific extension object, which may be null.ImageReader instance.IOException - if the attempt to instantiate the reader fails.IllegalArgumentException - if the ImageReader's contructor throws an IllegalArgumentException to indicate that the extension object is unsuitable.public boolean isOwnReader(ImageReader reader)
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.
reader - an ImageReader instance.true if reader is recognized.IllegalArgumentException - if reader is null.public String[] getImageWriterSpiNames()
Strings 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 ImageWriters 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.
Strings of length at least 1 containing names of ImageWriterSpi, or null.ImageIO.getImageWriter(ImageReader)
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.
DRAFT ea-b92