The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | /** |
| 18 | * @author Rustem V. Rafikov |
| 19 | * @version $Revision: 1.3 $ |
| 20 | */ |
| 21 | package javax.imageio.spi; |
| 22 | |
| 23 | import javax.imageio.stream.ImageInputStream; |
| 24 | import javax.imageio.ImageReader; |
| 25 | import java.io.IOException; |
| 26 | |
| 27 | /** |
| 28 | * The ImageReaderSpi abstract class is a service provider |
| 29 | * interface (SPI) for ImageReaders. |
| 30 | */ |
| 31 | public abstract class ImageReaderSpi extends ImageReaderWriterSpi { |
| 32 | |
| 33 | /** |
| 34 | * The STANDARD_INPUT_TYPE contains ImageInputStream.class. |
| 35 | */ |
| 36 | public static final Class[] STANDARD_INPUT_TYPE = new Class[] {ImageInputStream.class}; |
| 37 | |
| 38 | /** The input types. */ |
| 39 | protected Class[] inputTypes; |
| 40 | |
| 41 | /** The writer SPI names. */ |
| 42 | protected String[] writerSpiNames; |
| 43 | |
| 44 | /** |
| 45 | * Instantiates a new ImageReaderSpi. |
| 46 | */ |
| 47 | protected ImageReaderSpi() { |
| 48 | throw new UnsupportedOperationException("Not supported yet"); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Instantiates a new ImageReaderSpi. |
| 53 | * |
| 54 | * @param vendorName the vendor name. |
| 55 | * @param version the version. |
| 56 | * @param names the format names. |
| 57 | * @param suffixes the array of strings representing the file suffixes. |
| 58 | * @param MIMETypes the an array of strings representing MIME types. |
| 59 | * @param pluginClassName the plugin class name. |
| 60 | * @param inputTypes the input types. |
| 61 | * @param writerSpiNames the array of strings with class names of all |
| 62 | * associated ImageWriters. |
| 63 | * @param supportsStandardStreamMetadataFormat the value indicating |
| 64 | * if stream metadata can be described by standart metadata format. |
| 65 | * @param nativeStreamMetadataFormatName the native stream metadata |
| 66 | * format name, returned by getNativeStreamMetadataFormatName. |
| 67 | * @param nativeStreamMetadataFormatClassName the native stream |
| 68 | * metadata format class name, returned by getNativeStreamMetadataFormat. |
| 69 | * @param extraStreamMetadataFormatNames the extra stream metadata |
| 70 | * format names, returned by getExtraStreamMetadataFormatNames. |
| 71 | * @param extraStreamMetadataFormatClassNames the extra stream metadata |
| 72 | * format class names, returned by getStreamMetadataFormat. |
| 73 | * @param supportsStandardImageMetadataFormat the value indicating |
| 74 | * if image metadata can be described by standart metadata format. |
| 75 | * @param nativeImageMetadataFormatName the native image metadata |
| 76 | * format name, returned by getNativeImageMetadataFormatName. |
| 77 | * @param nativeImageMetadataFormatClassName the native image |
| 78 | * metadata format class name, returned by getNativeImageMetadataFormat. |
| 79 | * @param extraImageMetadataFormatNames the extra image metadata |
| 80 | * format names, returned by getExtraImageMetadataFormatNames. |
| 81 | * @param extraImageMetadataFormatClassNames the extra image metadata |
| 82 | * format class names, returned by getImageMetadataFormat. |
| 83 | */ |
| 84 | public ImageReaderSpi(String vendorName, String version, String[] names, String[] suffixes, |
| 85 | String[] MIMETypes, String pluginClassName, |
| 86 | Class[] inputTypes, String[] writerSpiNames, |
| 87 | boolean supportsStandardStreamMetadataFormat, |
| 88 | String nativeStreamMetadataFormatName, |
| 89 | String nativeStreamMetadataFormatClassName, |
| 90 | String[] extraStreamMetadataFormatNames, |
| 91 | String[] extraStreamMetadataFormatClassNames, |
| 92 | boolean supportsStandardImageMetadataFormat, |
| 93 | String nativeImageMetadataFormatName, |
| 94 | String nativeImageMetadataFormatClassName, |
| 95 | String[] extraImageMetadataFormatNames, |
| 96 | String[] extraImageMetadataFormatClassNames) { |
| 97 | super(vendorName, version, names, suffixes, MIMETypes, pluginClassName, |
| 98 | supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName, |
| 99 | nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames, |
| 100 | extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat, |
| 101 | nativeImageMetadataFormatName, nativeImageMetadataFormatClassName, |
| 102 | extraImageMetadataFormatNames, extraImageMetadataFormatClassNames); |
| 103 | |
| 104 | if (inputTypes == null || inputTypes.length == 0) { |
| 105 | throw new NullPointerException("input types array cannot be NULL or empty"); |
| 106 | } |
| 107 | this.inputTypes = inputTypes; |
| 108 | this.writerSpiNames = writerSpiNames; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Gets an array of Class objects whose types can be used |
| 113 | * as input for this reader. |
| 114 | * |
| 115 | * @return the input types. |
| 116 | */ |
| 117 | public Class[] getInputTypes() { |
| 118 | return inputTypes; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Returns true if the format of source object is |
| 123 | * supported by this reader. |
| 124 | * |
| 125 | * @param source the source object to be decoded |
| 126 | * (for example an ImageInputStream). |
| 127 | * |
| 128 | * @return true if the format of source object is |
| 129 | * supported by this reader, false otherwise. |
| 130 | * |
| 131 | * @throws IOException Signals that an I/O exception has occurred. |
| 132 | */ |
| 133 | public abstract boolean canDecodeInput(Object source) throws IOException; |
| 134 | |
| 135 | /** |
| 136 | * Returns an instance of the ImageReader implementation for |
| 137 | * this service provider. |
| 138 | * |
| 139 | * @return the ImageReader. |
| 140 | * |
| 141 | * @throws IOException Signals that an I/O exception has occurred. |
| 142 | */ |
| 143 | public ImageReader createReaderInstance() throws IOException { |
| 144 | return createReaderInstance(null); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Returns an instance of the ImageReader implementation for |
| 149 | * this service provider. |
| 150 | * |
| 151 | * @param extension the a plugin specific extension object, or null. |
| 152 | * |
| 153 | * @return the ImageReader. |
| 154 | * |
| 155 | * @throws IOException Signals that an I/O exception has occurred. |
| 156 | */ |
| 157 | public abstract ImageReader createReaderInstance(Object extension) throws IOException; |
| 158 | |
| 159 | /** |
| 160 | * Checks whether or not the specified ImageReader object |
| 161 | * is an instance of the ImageReader associated with this |
| 162 | * service provider or not. |
| 163 | * |
| 164 | * @param reader the ImageReader. |
| 165 | * |
| 166 | * @return true, if the specified ImageReader object |
| 167 | * is an instance of the ImageReader associated with this |
| 168 | * service provider, false otherwise. |
| 169 | */ |
| 170 | public boolean isOwnReader(ImageReader reader) { |
| 171 | throw new UnsupportedOperationException("Not supported yet"); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Gets an array of strings with names of the ImageWriterSpi |
| 176 | * classes that support the internal metadata representation |
| 177 | * used by the ImageReader of this service provider, or null if |
| 178 | * there are no such ImageWriters. |
| 179 | * |
| 180 | * @return an array of strings with names of the ImageWriterSpi |
| 181 | * classes. |
| 182 | */ |
| 183 | public String[] getImageWriterSpiNames() { |
| 184 | throw new UnsupportedOperationException("Not supported yet"); |
| 185 | } |
| 186 | } |