Merge from the pain train
[official-gcc.git] / libjava / javax / imageio / spi / ImageReaderWriterSpi.java
blob9821adf88af81959d1f33aef05ea7fc2af01d066
1 /* ImageReaderWriterSpi.java -- Superclass for image reader and writer spis.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.imageio.spi;
42 /**
43 * An abstract superclass that contains the common parts of {@link
44 * javax.imageio.spi.ImageReaderSpi} and {@link
45 * javax.imageio.spi.ImageWriterSpi}.
47 * @since 1.4
49 * @author Sascha Brawer (brawer@dandelis.ch)
51 public abstract class ImageReaderWriterSpi
52 extends IIOServiceProvider
54 /**
55 * The human-readable, localized names of the supported image
56 * formats. This value should be non-<code>null</code> after
57 * construction.
59 * @see #getFormatNames()
61 protected String[] names;
64 /**
65 * The file suffixes of the supported image formats. This value
66 * should be non-<code>null</code> after construction.
68 * @see #getFileSuffixes()
70 protected String[] suffixes;
73 /**
74 * The MIME types of the supported image formats. This value
75 * should be non-<code>null</code> after construction.
77 * @see #getMIMETypes()
79 protected String[] MIMETypes;
82 /**
83 * The fully qualified name of the class that implements the {@link
84 * javax.imageio.ImageReader} or {@link javax.imageio.ImageWriter}
85 * interface. This value should be non-<code>null</code> after
86 * construction.
88 * @see #getPluginClassName()
90 protected String pluginClassName;
93 /**
94 * Indicates whether the per-stream {@linkplain
95 * javax.imageio.metadata.IIOMetadata metadata objects} associated
96 * with this plug-in support format
97 * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
98 * <code>getAsTree</code> and <code>setAsTree</code> methods.
100 * @see #isStandardStreamMetadataFormatSupported()
102 protected boolean supportsStandardStreamMetadataFormat;
106 * The name of the format that allows encoding all stream metadata
107 * without loss, or <code>null</code> if this plug-in does not
108 * provide a format that preserves all stream metadata.
110 protected String nativeStreamMetadataFormatName;
112 protected String nativeStreamMetadataFormatClassName;
116 * The names of additional formats for encoding stream metadata,
117 * other than the {@linkplain
118 * #isStandardStreamMetadataFormatSupported() standard} and the
119 * {@linkplain #getNativeStreamMetadataFormatName() native} formats,
120 * or <code>null</code> if this plug-in does not provide any extra
121 * formats.
123 protected String[] extraStreamMetadataFormatNames;
126 protected String[] extraStreamMetadataFormatClassNames;
130 * Indicates whether the per-image {@linkplain
131 * javax.imageio.metadata.IIOMetadata metadata objects} associated
132 * with this plug-in support format
133 * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
134 * <code>getAsTree</code> and <code>setAsTree</code> methods.
136 * @see #isStandardImageMetadataFormatSupported()
138 protected boolean supportsStandardImageMetadataFormat;
142 * The name of the format that allows encoding all image metadata
143 * without loss, or <code>null</code> if this plug-in does not
144 * provide a format that preserves all image metadata.
146 protected String nativeImageMetadataFormatName;
148 protected String nativeImageMetadataFormatClassName;
152 * The names of additional formats for encoding image metadata,
153 * other than the {@linkplain
154 * #isStandardImageMetadataFormatSupported() standard} and the
155 * {@linkplain #getNativeImageMetadataFormatName() native} formats,
156 * or <code>null</code> if this plug-in does not provide any extra
157 * formats.
159 protected String[] extraImageMetadataFormatNames;
162 protected String[] extraImageMetadataFormatClassNames;
166 * Constructs an <code>ImageReaderWriteSpi</code> instance, without
167 * specifying a number of parameters. Constructors of concrete
168 * subclasses must ensure that they set all inherited fields to
169 * meaningful values.
171 public ImageReaderWriterSpi()
177 * Constructs an <code>ImageReaderWriteSpi</code> instance,
178 * specifying a number of parameters.
180 * @param names the human-readable, localized names of the supported
181 * image formats, for example <code>[&#x201c;Tagged Image File
182 * Format&#x201d;, &#x201c;Portable Network
183 * Graphics&#x201d;]</code>.
185 * @param suffixes the file suffixes of the supported image formats,
186 * for example <code>[&#x201c;tiff&#x201d;, &#x201c;tif&#x201d;,
187 * &#x201c;png&#x201d;]</code>.
189 * @param MIMETypes the MIME types of the supported image formats,
190 * for example <code>[&#x201c;image/tiff&#x201d;,
191 * &#x201c;image/png&#x201d;]</code>.
193 * @param pluginClassName the fully qualified name of the class that
194 * implements the {@link javax.imageio.ImageReader} or {@link
195 * javax.imageio.ImageWriter} interface.
197 * @param supportsStandardStreamMetadataFormat whether the
198 * per-stream {@linkplain javax.imageio.metadata.IIOMetadata
199 * metadata objects} associated with this plug-in support format
200 * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
201 * <code>getAsTree</code> and <code>setAsTree</code> methods.
203 * @param nativeStreamMetadataFormatName the name of the format that
204 * allows encoding all stream metadata without loss, or
205 * <code>null</code> if this plug-in does not provide a format that
206 * preserves all stream metadata.
208 * @param extraStreamMetadataFormatNames the names of additional
209 * formats for encoding stream metadata, other than the {@linkplain
210 * #isStandardStreamMetadataFormatSupported() standard} and the
211 * {@linkplain #getNativeStreamMetadataFormatName() native} formats,
212 * or <code>null</code> if this plug-in does not provide any extra
213 * formats.
215 * @param supportsStandardImageMetadataFormat whether the per-image
216 * {@linkplain javax.imageio.metadata.IIOMetadata metadata objects}
217 * associated with this plug-in support format
218 * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
219 * <code>getAsTree</code> and <code>setAsTree</code> methods.
221 * @param nativeImageMetadataFormatName the name of the format that
222 * allows encoding all image metadata without loss, or
223 * <code>null</code> if this plug-in does not provide a format that
224 * preserves all image metadata.
226 * @param extraImageMetadataFormatNames the names of additional
227 * formats for encoding image metadata, other than the {@linkplain
228 * #isStandardImageMetadataFormatSupported() standard} and the
229 * {@linkplain #getNativeImageMetadataFormatName() native} formats,
230 * or <code>null</code> if this plug-in does not provide any extra
231 * formats.
233 * @throws IllegalArgumentException if <code>vendorName</code>
234 * or <code>version</code> is <code>null</code>.
236 public ImageReaderWriterSpi(String vendorName, String version,
237 String[] names, String[] suffixes,
238 String[] MIMETypes, String pluginClassName,
239 boolean supportsStandardStreamMetadataFormat,
240 String nativeStreamMetadataFormatName,
241 String nativeStreamMetadataFormatClassName,
242 String[] extraStreamMetadataFormatNames,
243 String[] extraStreamMetadataFormatClassNames,
244 boolean supportsStandardImageMetadataFormat,
245 String nativeImageMetadataFormatName,
246 String nativeImageMetadataFormatClassName,
247 String[] extraImageMetadataFormatNames,
248 String[] extraImageMetadataFormatClassNames)
250 /* The inherited constructor will throw IllegalArgumentException
251 * if one of its arguments is null.
253 super(vendorName, version);
255 if (names == null || names.length == 0 || pluginClassName == null)
256 throw new IllegalArgumentException();
258 this.names = names;
259 this.suffixes = suffixes;
260 this.MIMETypes = MIMETypes;
261 this.pluginClassName = pluginClassName;
263 this.supportsStandardStreamMetadataFormat
264 = supportsStandardStreamMetadataFormat;
266 this.nativeStreamMetadataFormatName
267 = nativeStreamMetadataFormatName;
269 this.nativeStreamMetadataFormatClassName
270 = nativeStreamMetadataFormatClassName;
272 this.extraStreamMetadataFormatNames
273 = extraStreamMetadataFormatNames;
275 this.extraStreamMetadataFormatClassNames
276 = extraStreamMetadataFormatClassNames;
278 this.supportsStandardImageMetadataFormat
279 = supportsStandardImageMetadataFormat;
281 this.nativeImageMetadataFormatName
282 = nativeImageMetadataFormatName;
284 this.nativeImageMetadataFormatClassName
285 = nativeImageMetadataFormatClassName;
287 this.extraImageMetadataFormatNames
288 = extraImageMetadataFormatNames;
290 this.extraImageMetadataFormatClassNames
291 = extraImageMetadataFormatClassNames;
296 * Returns the human-readable, localized names of the supported
297 * image formats. For example, a plug-in might return an array with
298 * the elements <code>[&#x201c;Tagged Image File Format&#x201d;,
299 * &#x201c;Portable Network Graphics&#x201d;]</code>.
301 public String[] getFormatNames()
303 return (String[]) names.clone();
308 * Returns the file suffixes of the supported image formats, for
309 * example <code>[&#x201c;tiff&#x201d;, &#x201c;tif&#x201d;,
310 * &#x201c;png&#x201d;]</code>.
312 public String[] getFileSuffixes()
314 return suffixes;
319 * Returns the MIME types of the supported image formats, for
320 * example <code>[&#x201c;image/tiff&#x201d;,
321 * &#x201c;image/png&#x201d;]</code>.
323 * @return an array of MIME type strings, or <code>null</code> if
324 * none of the supported formats has an associated MIME type.
326 public String[] getMIMETypes()
328 return MIMETypes;
333 * Returns the fully qualified name of the class that implements the
334 * {@link javax.imageio.ImageReader} or {@link
335 * javax.imageio.ImageWriter} interface.
337 public String getPluginClassName()
339 return pluginClassName;
344 * Returns whether the per-stream {@linkplain
345 * javax.imageio.metadata.IIOMetadata metadata objects} associated
346 * with this plug-in support format
347 * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
348 * <code>getAsTree</code> and <code>setAsTree</code> methods.
350 public boolean isStandardStreamMetadataFormatSupported()
352 return supportsStandardStreamMetadataFormat;
357 * Returns the name of the format that allows encoding all stream
358 * metadata without loss, or <code>null</code> if this plug-in does
359 * not provide a format that preserves all stream metadata.
361 * @see #getNativeImageMetadataFormatName()
363 public String getNativeStreamMetadataFormatName()
365 return nativeStreamMetadataFormatName;
370 * Returns the names of additional formats for encoding stream
371 * metadata, other than the {@linkplain
372 * #isStandardStreamMetadataFormatSupported() standard} and the
373 * {@linkplain #getNativeStreamMetadataFormatName() native} formats,
374 * or <code>null</code> if this plug-in does not provide any extra
375 * formats.
377 * @see #getExtraImageMetadataFormatNames()
379 public String[] getExtraStreamMetadataFormatNames()
381 return extraStreamMetadataFormatNames;
386 * Returns whether the per-image {@linkplain
387 * javax.imageio.metadata.IIOMetadata metadata objects} associated
388 * with this plug-in support format
389 * <code>&#x201c;javax_imageio_1.0&#x201d;</code> in their
390 * <code>getAsTree</code> and <code>setAsTree</code> methods.
392 public boolean isStandardImageMetadataFormatSupported()
394 return supportsStandardImageMetadataFormat;
399 * Returns the name of the format that allows encoding all image
400 * metadata without loss, or <code>null</code> if this plug-in does
401 * not provide a format that preserves all image metadata.
403 * @see #getNativeStreamMetadataFormatName()
405 public String getNativeImageMetadataFormatName()
407 return nativeImageMetadataFormatName;
412 * Returns the names of additional formats for encoding image
413 * metadata, other than the {@linkplain
414 * #isStandardImageMetadataFormatSupported() standard} and the
415 * {@linkplain #getNativeImageMetadataFormatName() native} formats,
416 * or <code>null</code> if this plug-in does not provide any extra
417 * formats.
419 * @see #getExtraStreamMetadataFormatNames()
421 public String[] getExtraImageMetadataFormatNames()
423 return extraImageMetadataFormatNames;