• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 package javax.imageio.spi;
23 
24 import javax.imageio.stream.ImageInputStream;
25 import javax.imageio.ImageReader;
26 import java.io.IOException;
27 
28 /**
29  * The ImageReaderSpi abstract class is a service provider interface (SPI) for
30  * ImageReaders.
31  *
32  * @since Android 1.0
33  */
34 public abstract class ImageReaderSpi extends ImageReaderWriterSpi {
35 
36     /**
37      * The STANDARD_INPUT_TYPE contains ImageInputStream.class.
38      */
39     public static final Class[] STANDARD_INPUT_TYPE = new Class[] {
40         ImageInputStream.class
41     };
42 
43     /**
44      * The input types.
45      */
46     protected Class[] inputTypes;
47 
48     /**
49      * The writer SPI names.
50      */
51     protected String[] writerSpiNames;
52 
53     /**
54      * Instantiates a new ImageReaderSpi.
55      */
ImageReaderSpi()56     protected ImageReaderSpi() {
57         throw new UnsupportedOperationException("Not supported yet");
58     }
59 
60     /**
61      * Instantiates a new ImageReaderSpi.
62      *
63      * @param vendorName
64      *            the vendor name.
65      * @param version
66      *            the version.
67      * @param names
68      *            the format names.
69      * @param suffixes
70      *            the array of strings representing the file suffixes.
71      * @param MIMETypes
72      *            the an array of strings representing MIME types.
73      * @param pluginClassName
74      *            the plug-in class name.
75      * @param inputTypes
76      *            the input types.
77      * @param writerSpiNames
78      *            the array of strings with class names of all associated
79      *            ImageWriters.
80      * @param supportsStandardStreamMetadataFormat
81      *            the value indicating if stream metadata can be described by
82      *            standard metadata format.
83      * @param nativeStreamMetadataFormatName
84      *            the native stream metadata format name, returned by
85      *            getNativeStreamMetadataFormatName.
86      * @param nativeStreamMetadataFormatClassName
87      *            the native stream metadata format class name, returned by
88      *            getNativeStreamMetadataFormat.
89      * @param extraStreamMetadataFormatNames
90      *            the extra stream metadata format names, returned by
91      *            getExtraStreamMetadataFormatNames.
92      * @param extraStreamMetadataFormatClassNames
93      *            the extra stream metadata format class names, returned by
94      *            getStreamMetadataFormat.
95      * @param supportsStandardImageMetadataFormat
96      *            the value indicating if image metadata can be described by
97      *            standard metadata format.
98      * @param nativeImageMetadataFormatName
99      *            the native image metadata format name, returned by
100      *            getNativeImageMetadataFormatName.
101      * @param nativeImageMetadataFormatClassName
102      *            the native image metadata format class name, returned by
103      *            getNativeImageMetadataFormat.
104      * @param extraImageMetadataFormatNames
105      *            the extra image metadata format names, returned by
106      *            getExtraImageMetadataFormatNames.
107      * @param extraImageMetadataFormatClassNames
108      *            the extra image metadata format class names, returned by
109      *            getImageMetadataFormat.
110      */
ImageReaderSpi(String vendorName, String version, String[] names, String[] suffixes, String[] MIMETypes, String pluginClassName, Class[] inputTypes, String[] writerSpiNames, boolean supportsStandardStreamMetadataFormat, String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName, String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames, boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName, String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames, String[] extraImageMetadataFormatClassNames)111     public ImageReaderSpi(String vendorName, String version, String[] names, String[] suffixes,
112             String[] MIMETypes, String pluginClassName, Class[] inputTypes,
113             String[] writerSpiNames, boolean supportsStandardStreamMetadataFormat,
114             String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName,
115             String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames,
116             boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName,
117             String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames,
118             String[] extraImageMetadataFormatClassNames) {
119         super(vendorName, version, names, suffixes, MIMETypes, pluginClassName,
120                 supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName,
121                 nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames,
122                 extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat,
123                 nativeImageMetadataFormatName, nativeImageMetadataFormatClassName,
124                 extraImageMetadataFormatNames, extraImageMetadataFormatClassNames);
125 
126         if (inputTypes == null || inputTypes.length == 0) {
127             throw new NullPointerException("input types array cannot be NULL or empty");
128         }
129         this.inputTypes = inputTypes;
130         this.writerSpiNames = writerSpiNames;
131     }
132 
133     /**
134      * Gets an array of Class objects whose types can be used as input for this
135      * reader.
136      *
137      * @return the input types.
138      */
getInputTypes()139     public Class[] getInputTypes() {
140         return inputTypes;
141     }
142 
143     /**
144      * Returns true if the format of source object is supported by this reader.
145      *
146      * @param source
147      *            the source object to be decoded (for example an
148      *            ImageInputStream).
149      * @return true, if the format of source object is supported by this reader,
150      *         false otherwise.
151      * @throws IOException
152      *             if an I/O exception has occurred.
153      */
canDecodeInput(Object source)154     public abstract boolean canDecodeInput(Object source) throws IOException;
155 
156     /**
157      * Returns an instance of the ImageReader implementation for this service
158      * provider.
159      *
160      * @return the ImageReader.
161      * @throws IOException
162      *             if an I/O exception has occurred.
163      */
createReaderInstance()164     public ImageReader createReaderInstance() throws IOException {
165         return createReaderInstance(null);
166     }
167 
168     /**
169      * Returns an instance of the ImageReader implementation for this service
170      * provider.
171      *
172      * @param extension
173      *            the a plug-in specific extension object, or null.
174      * @return the ImageReader.
175      * @throws IOException
176      *             if an I/O exception has occurred.
177      */
createReaderInstance(Object extension)178     public abstract ImageReader createReaderInstance(Object extension) throws IOException;
179 
180     /**
181      * Checks whether or not the specified ImageReader object is an instance of
182      * the ImageReader associated with this service provider or not.
183      *
184      * @param reader
185      *            the ImageReader.
186      * @return true, if the specified ImageReader object is an instance of the
187      *         ImageReader associated with this service provider, false
188      *         otherwise.
189      */
isOwnReader(ImageReader reader)190     public boolean isOwnReader(ImageReader reader) {
191         throw new UnsupportedOperationException("Not supported yet");
192     }
193 
194     /**
195      * Gets an array of strings with names of the ImageWriterSpi classes that
196      * support the internal metadata representation used by the ImageReader of
197      * this service provider, or null if there are no such ImageWriters.
198      *
199      * @return the array of strings with names of the ImageWriterSpi classes.
200      */
getImageWriterSpiNames()201     public String[] getImageWriterSpiNames() {
202         throw new UnsupportedOperationException("Not supported yet");
203     }
204 }
205