64 * associated with this service provider may be obtained by calling
65 * the <code>createReaderInstance</code> method. Any heavyweight
66 * initialization, such as the loading of native libraries or creation
67 * of large tables, should be deferred at least until the first
68 * invocation of this method.
69 *
70 * @see IIORegistry
71 * @see javax.imageio.ImageReader
72 *
73 */
74 public abstract class ImageReaderSpi extends ImageReaderWriterSpi {
75
76 /**
77 * A single-element array, initially containing
78 * <code>ImageInputStream.class</code>, to be returned from
79 * <code>getInputTypes</code>.
80 * @deprecated Instead of using this field, directly create
81 * the equivalent array <code>{ ImageInputStream.class }</code>.
82 */
83 @Deprecated
84 public static final Class[] STANDARD_INPUT_TYPE =
85 { ImageInputStream.class };
86
87 /**
88 * An array of <code>Class</code> objects to be returned from
89 * <code>getInputTypes</code>, initially <code>null</code>.
90 */
91 protected Class[] inputTypes = null;
92
93 /**
94 * An array of strings to be returned from
95 * <code>getImageWriterSpiNames</code>, initially
96 * <code>null</code>.
97 */
98 protected String[] writerSpiNames = null;
99
100 /**
101 * The <code>Class</code> of the reader, initially
102 * <code>null</code>.
103 */
104 private Class readerClass = null;
105
106 /**
107 * Constructs a blank <code>ImageReaderSpi</code>. It is up to
108 * the subclass to initialize instance variables and/or override
109 * method implementations in order to provide working versions of
110 * all methods.
111 */
112 protected ImageReaderSpi() {
113 }
114
115 /**
116 * Constructs an <code>ImageReaderSpi</code> with a given
117 * set of values.
118 *
119 * @param vendorName the vendor name, as a non-<code>null</code>
120 * <code>String</code>.
121 * @param version a version identifier, as a non-<code>null</code>
122 * <code>String</code>.
123 * @param names a non-<code>null</code> array of
124 * <code>String</code>s indicating the format names. At least one
180 * <code>getImageMetadataFormat</code>. An array of length
181 * 0 is normalized to <code>null</code>.
182 *
183 * @exception IllegalArgumentException if <code>vendorName</code>
184 * is <code>null</code>.
185 * @exception IllegalArgumentException if <code>version</code>
186 * is <code>null</code>.
187 * @exception IllegalArgumentException if <code>names</code>
188 * is <code>null</code> or has length 0.
189 * @exception IllegalArgumentException if <code>readerClassName</code>
190 * is <code>null</code>.
191 * @exception IllegalArgumentException if <code>inputTypes</code>
192 * is <code>null</code> or has length 0.
193 */
194 public ImageReaderSpi(String vendorName,
195 String version,
196 String[] names,
197 String[] suffixes,
198 String[] MIMETypes,
199 String readerClassName,
200 Class[] inputTypes,
201 String[] writerSpiNames,
202 boolean supportsStandardStreamMetadataFormat,
203 String nativeStreamMetadataFormatName,
204 String nativeStreamMetadataFormatClassName,
205 String[] extraStreamMetadataFormatNames,
206 String[] extraStreamMetadataFormatClassNames,
207 boolean supportsStandardImageMetadataFormat,
208 String nativeImageMetadataFormatName,
209 String nativeImageMetadataFormatClassName,
210 String[] extraImageMetadataFormatNames,
211 String[] extraImageMetadataFormatClassNames) {
212 super(vendorName, version,
213 names, suffixes, MIMETypes, readerClassName,
214 supportsStandardStreamMetadataFormat,
215 nativeStreamMetadataFormatName,
216 nativeStreamMetadataFormatClassName,
217 extraStreamMetadataFormatNames,
218 extraStreamMetadataFormatClassNames,
219 supportsStandardImageMetadataFormat,
220 nativeImageMetadataFormatName,
237
238 // If length == 0, leave it null
239 if (writerSpiNames != null && writerSpiNames.length > 0) {
240 this.writerSpiNames = writerSpiNames.clone();
241 }
242 }
243
244 /**
245 * Returns an array of <code>Class</code> objects indicating what
246 * types of objects may be used as arguments to the reader's
247 * <code>setInput</code> method.
248 *
249 * <p> For most readers, which only accept input from an
250 * <code>ImageInputStream</code>, a single-element array
251 * containing <code>ImageInputStream.class</code> should be
252 * returned.
253 *
254 * @return a non-<code>null</code> array of
255 * <code>Class</code>objects of length at least 1.
256 */
257 public Class[] getInputTypes() {
258 return inputTypes.clone();
259 }
260
261 /**
262 * Returns <code>true</code> if the supplied source object appears
263 * to be of the format supported by this reader. Returning
264 * <code>true</code> from this method does not guarantee that
265 * reading will succeed, only that there appears to be a
266 * reasonable chance of success based on a brief inspection of the
267 * stream contents. If the source is an
268 * <code>ImageInputStream</code>, implementations will commonly
269 * check the first several bytes of the stream for a "magic
270 * number" associated with the format. Once actual reading has
271 * commenced, the reader may still indicate failure at any time
272 * prior to the completion of decoding.
273 *
274 * <p> It is important that the state of the object not be
275 * disturbed in order that other <code>ImageReaderSpi</code>s can
276 * properly determine whether they are able to decode the object.
277 * In particular, if the source is an
|
64 * associated with this service provider may be obtained by calling
65 * the <code>createReaderInstance</code> method. Any heavyweight
66 * initialization, such as the loading of native libraries or creation
67 * of large tables, should be deferred at least until the first
68 * invocation of this method.
69 *
70 * @see IIORegistry
71 * @see javax.imageio.ImageReader
72 *
73 */
74 public abstract class ImageReaderSpi extends ImageReaderWriterSpi {
75
76 /**
77 * A single-element array, initially containing
78 * <code>ImageInputStream.class</code>, to be returned from
79 * <code>getInputTypes</code>.
80 * @deprecated Instead of using this field, directly create
81 * the equivalent array <code>{ ImageInputStream.class }</code>.
82 */
83 @Deprecated
84 public static final Class<?>[] STANDARD_INPUT_TYPE =
85 { ImageInputStream.class };
86
87 /**
88 * An array of <code>Class</code> objects to be returned from
89 * <code>getInputTypes</code>, initially <code>null</code>.
90 */
91 protected Class<?>[] inputTypes = null;
92
93 /**
94 * An array of strings to be returned from
95 * <code>getImageWriterSpiNames</code>, initially
96 * <code>null</code>.
97 */
98 protected String[] writerSpiNames = null;
99
100 /**
101 * The <code>Class</code> of the reader, initially
102 * <code>null</code>.
103 */
104 private Class<?> readerClass = null;
105
106 /**
107 * Constructs a blank <code>ImageReaderSpi</code>. It is up to
108 * the subclass to initialize instance variables and/or override
109 * method implementations in order to provide working versions of
110 * all methods.
111 */
112 protected ImageReaderSpi() {
113 }
114
115 /**
116 * Constructs an <code>ImageReaderSpi</code> with a given
117 * set of values.
118 *
119 * @param vendorName the vendor name, as a non-<code>null</code>
120 * <code>String</code>.
121 * @param version a version identifier, as a non-<code>null</code>
122 * <code>String</code>.
123 * @param names a non-<code>null</code> array of
124 * <code>String</code>s indicating the format names. At least one
180 * <code>getImageMetadataFormat</code>. An array of length
181 * 0 is normalized to <code>null</code>.
182 *
183 * @exception IllegalArgumentException if <code>vendorName</code>
184 * is <code>null</code>.
185 * @exception IllegalArgumentException if <code>version</code>
186 * is <code>null</code>.
187 * @exception IllegalArgumentException if <code>names</code>
188 * is <code>null</code> or has length 0.
189 * @exception IllegalArgumentException if <code>readerClassName</code>
190 * is <code>null</code>.
191 * @exception IllegalArgumentException if <code>inputTypes</code>
192 * is <code>null</code> or has length 0.
193 */
194 public ImageReaderSpi(String vendorName,
195 String version,
196 String[] names,
197 String[] suffixes,
198 String[] MIMETypes,
199 String readerClassName,
200 Class<?>[] inputTypes,
201 String[] writerSpiNames,
202 boolean supportsStandardStreamMetadataFormat,
203 String nativeStreamMetadataFormatName,
204 String nativeStreamMetadataFormatClassName,
205 String[] extraStreamMetadataFormatNames,
206 String[] extraStreamMetadataFormatClassNames,
207 boolean supportsStandardImageMetadataFormat,
208 String nativeImageMetadataFormatName,
209 String nativeImageMetadataFormatClassName,
210 String[] extraImageMetadataFormatNames,
211 String[] extraImageMetadataFormatClassNames) {
212 super(vendorName, version,
213 names, suffixes, MIMETypes, readerClassName,
214 supportsStandardStreamMetadataFormat,
215 nativeStreamMetadataFormatName,
216 nativeStreamMetadataFormatClassName,
217 extraStreamMetadataFormatNames,
218 extraStreamMetadataFormatClassNames,
219 supportsStandardImageMetadataFormat,
220 nativeImageMetadataFormatName,
237
238 // If length == 0, leave it null
239 if (writerSpiNames != null && writerSpiNames.length > 0) {
240 this.writerSpiNames = writerSpiNames.clone();
241 }
242 }
243
244 /**
245 * Returns an array of <code>Class</code> objects indicating what
246 * types of objects may be used as arguments to the reader's
247 * <code>setInput</code> method.
248 *
249 * <p> For most readers, which only accept input from an
250 * <code>ImageInputStream</code>, a single-element array
251 * containing <code>ImageInputStream.class</code> should be
252 * returned.
253 *
254 * @return a non-<code>null</code> array of
255 * <code>Class</code>objects of length at least 1.
256 */
257 public Class<?>[] getInputTypes() {
258 return inputTypes.clone();
259 }
260
261 /**
262 * Returns <code>true</code> if the supplied source object appears
263 * to be of the format supported by this reader. Returning
264 * <code>true</code> from this method does not guarantee that
265 * reading will succeed, only that there appears to be a
266 * reasonable chance of success based on a brief inspection of the
267 * stream contents. If the source is an
268 * <code>ImageInputStream</code>, implementations will commonly
269 * check the first several bytes of the stream for a "magic
270 * number" associated with the format. Once actual reading has
271 * commenced, the reader may still indicate failure at any time
272 * prior to the completion of decoding.
273 *
274 * <p> It is important that the state of the object not be
275 * disturbed in order that other <code>ImageReaderSpi</code>s can
276 * properly determine whether they are able to decode the object.
277 * In particular, if the source is an
|