GNU Classpath (0.17) | ||
Frames | No Frames |
1: /* ImageReaderWriterSpi.java -- Superclass for image reader and writer spis. 2: Copyright (C) 2004, 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 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. 10: 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. 15: 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., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 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. 25: 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. */ 37: 38: 39: package javax.imageio.spi; 40: 41: 42: /** 43: * An abstract superclass that contains the common parts of {@link 44: * javax.imageio.spi.ImageReaderSpi} and {@link 45: * javax.imageio.spi.ImageWriterSpi}. 46: * 47: * @since 1.4 48: * 49: * @author Sascha Brawer (brawer@dandelis.ch) 50: */ 51: public abstract class ImageReaderWriterSpi 52: extends IIOServiceProvider 53: { 54: /** 55: * The human-readable, localized names of the supported image 56: * formats. This value should be non-<code>null</code> after 57: * construction. 58: * 59: * @see #getFormatNames() 60: */ 61: protected String[] names; 62: 63: 64: /** 65: * The file suffixes of the supported image formats. This value 66: * should be non-<code>null</code> after construction. 67: * 68: * @see #getFileSuffixes() 69: */ 70: protected String[] suffixes; 71: 72: 73: /** 74: * The MIME types of the supported image formats. This value 75: * should be non-<code>null</code> after construction. 76: * 77: * @see #getMIMETypes() 78: */ 79: protected String[] MIMETypes; 80: 81: 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. 87: * 88: * @see #getPluginClassName() 89: */ 90: protected String pluginClassName; 91: 92: 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>“javax_imageio_1.0”</code> in their 98: * <code>getAsTree</code> and <code>setAsTree</code> methods. 99: * 100: * @see #isStandardStreamMetadataFormatSupported() 101: */ 102: protected boolean supportsStandardStreamMetadataFormat; 103: 104: 105: /** 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. 109: */ 110: protected String nativeStreamMetadataFormatName; 111: 112: protected String nativeStreamMetadataFormatClassName; 113: 114: 115: /** 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. 122: */ 123: protected String[] extraStreamMetadataFormatNames; 124: 125: 126: protected String[] extraStreamMetadataFormatClassNames; 127: 128: 129: /** 130: * Indicates whether the per-image {@linkplain 131: * javax.imageio.metadata.IIOMetadata metadata objects} associated 132: * with this plug-in support format 133: * <code>“javax_imageio_1.0”</code> in their 134: * <code>getAsTree</code> and <code>setAsTree</code> methods. 135: * 136: * @see #isStandardImageMetadataFormatSupported() 137: */ 138: protected boolean supportsStandardImageMetadataFormat; 139: 140: 141: /** 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. 145: */ 146: protected String nativeImageMetadataFormatName; 147: 148: protected String nativeImageMetadataFormatClassName; 149: 150: 151: /** 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. 158: */ 159: protected String[] extraImageMetadataFormatNames; 160: 161: 162: protected String[] extraImageMetadataFormatClassNames; 163: 164: 165: /** 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. 170: */ 171: public ImageReaderWriterSpi() 172: { 173: } 174: 175: 176: /** 177: * Constructs an <code>ImageReaderWriteSpi</code> instance, 178: * specifying a number of parameters. 179: * 180: * @param names the human-readable, localized names of the supported 181: * image formats, for example <code>[“Tagged Image File 182: * Format”, “Portable Network 183: * Graphics”]</code>. 184: * 185: * @param suffixes the file suffixes of the supported image formats, 186: * for example <code>[“tiff”, “tif”, 187: * “png”]</code>. 188: * 189: * @param MIMETypes the MIME types of the supported image formats, 190: * for example <code>[“image/tiff”, 191: * “image/png”]</code>. 192: * 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. 196: * 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>“javax_imageio_1.0”</code> in their 201: * <code>getAsTree</code> and <code>setAsTree</code> methods. 202: * 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. 207: * 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. 214: * 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>“javax_imageio_1.0”</code> in their 219: * <code>getAsTree</code> and <code>setAsTree</code> methods. 220: * 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. 225: * 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. 232: * 233: * @throws IllegalArgumentException if <code>vendorName</code> 234: * or <code>version</code> is <code>null</code>. 235: */ 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) 249: { 250: /* The inherited constructor will throw IllegalArgumentException 251: * if one of its arguments is null. 252: */ 253: super(vendorName, version); 254: 255: if (names == null || names.length == 0 || pluginClassName == null) 256: throw new IllegalArgumentException(); 257: 258: this.names = names; 259: this.suffixes = suffixes; 260: this.MIMETypes = MIMETypes; 261: this.pluginClassName = pluginClassName; 262: 263: this.supportsStandardStreamMetadataFormat 264: = supportsStandardStreamMetadataFormat; 265: 266: this.nativeStreamMetadataFormatName 267: = nativeStreamMetadataFormatName; 268: 269: this.nativeStreamMetadataFormatClassName 270: = nativeStreamMetadataFormatClassName; 271: 272: this.extraStreamMetadataFormatNames 273: = extraStreamMetadataFormatNames; 274: 275: this.extraStreamMetadataFormatClassNames 276: = extraStreamMetadataFormatClassNames; 277: 278: this.supportsStandardImageMetadataFormat 279: = supportsStandardImageMetadataFormat; 280: 281: this.nativeImageMetadataFormatName 282: = nativeImageMetadataFormatName; 283: 284: this.nativeImageMetadataFormatClassName 285: = nativeImageMetadataFormatClassName; 286: 287: this.extraImageMetadataFormatNames 288: = extraImageMetadataFormatNames; 289: 290: this.extraImageMetadataFormatClassNames 291: = extraImageMetadataFormatClassNames; 292: } 293: 294: 295: /** 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>[“Tagged Image File Format”, 299: * “Portable Network Graphics”]</code>. 300: */ 301: public String[] getFormatNames() 302: { 303: return (String[]) names.clone(); 304: } 305: 306: 307: /** 308: * Returns the file suffixes of the supported image formats, for 309: * example <code>[“tiff”, “tif”, 310: * “png”]</code>. 311: */ 312: public String[] getFileSuffixes() 313: { 314: return suffixes; 315: } 316: 317: 318: /** 319: * Returns the MIME types of the supported image formats, for 320: * example <code>[“image/tiff”, 321: * “image/png”]</code>. 322: * 323: * @return an array of MIME type strings, or <code>null</code> if 324: * none of the supported formats has an associated MIME type. 325: */ 326: public String[] getMIMETypes() 327: { 328: return MIMETypes; 329: } 330: 331: 332: /** 333: * Returns the fully qualified name of the class that implements the 334: * {@link javax.imageio.ImageReader} or {@link 335: * javax.imageio.ImageWriter} interface. 336: */ 337: public String getPluginClassName() 338: { 339: return pluginClassName; 340: } 341: 342: 343: /** 344: * Returns whether the per-stream {@linkplain 345: * javax.imageio.metadata.IIOMetadata metadata objects} associated 346: * with this plug-in support format 347: * <code>“javax_imageio_1.0”</code> in their 348: * <code>getAsTree</code> and <code>setAsTree</code> methods. 349: */ 350: public boolean isStandardStreamMetadataFormatSupported() 351: { 352: return supportsStandardStreamMetadataFormat; 353: } 354: 355: 356: /** 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. 360: * 361: * @see #getNativeImageMetadataFormatName() 362: */ 363: public String getNativeStreamMetadataFormatName() 364: { 365: return nativeStreamMetadataFormatName; 366: } 367: 368: 369: /** 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. 376: * 377: * @see #getExtraImageMetadataFormatNames() 378: */ 379: public String[] getExtraStreamMetadataFormatNames() 380: { 381: return extraStreamMetadataFormatNames; 382: } 383: 384: 385: /** 386: * Returns whether the per-image {@linkplain 387: * javax.imageio.metadata.IIOMetadata metadata objects} associated 388: * with this plug-in support format 389: * <code>“javax_imageio_1.0”</code> in their 390: * <code>getAsTree</code> and <code>setAsTree</code> methods. 391: */ 392: public boolean isStandardImageMetadataFormatSupported() 393: { 394: return supportsStandardImageMetadataFormat; 395: } 396: 397: 398: /** 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. 402: * 403: * @see #getNativeStreamMetadataFormatName() 404: */ 405: public String getNativeImageMetadataFormatName() 406: { 407: return nativeImageMetadataFormatName; 408: } 409: 410: 411: /** 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. 418: * 419: * @see #getExtraStreamMetadataFormatNames() 420: */ 421: public String[] getExtraImageMetadataFormatNames() 422: { 423: return extraImageMetadataFormatNames; 424: } 425: }
GNU Classpath (0.17) |