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 java.io.File; |
| 24 | import java.io.IOException; |
| 25 | import javax.imageio.stream.ImageInputStream; |
| 26 | |
| 27 | /** |
| 28 | * The ImageInputStreamSpi abstract class is a service provider |
| 29 | * interface (SPI) for ImageInputStreams. |
| 30 | */ |
| 31 | public abstract class ImageInputStreamSpi extends IIOServiceProvider implements |
| 32 | RegisterableService { |
| 33 | |
| 34 | /** The input class. */ |
| 35 | protected Class<?> inputClass; |
| 36 | |
| 37 | /** |
| 38 | * Instantiates a new ImageInputStreamSpi. |
| 39 | */ |
| 40 | protected ImageInputStreamSpi() { |
| 41 | throw new UnsupportedOperationException("Not supported yet"); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Instantiates a new ImageInputStreamSpi. |
| 46 | * |
| 47 | * @param vendorName the vendor name. |
| 48 | * @param version the version. |
| 49 | * @param inputClass the input class. |
| 50 | */ |
| 51 | public ImageInputStreamSpi(String vendorName, String version, Class<?> inputClass) { |
| 52 | super(vendorName, version); |
| 53 | this.inputClass = inputClass; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Gets an input Class object that represents class or |
| 58 | * interface that must be implemented by an input source. |
| 59 | * |
| 60 | * @return the input class. |
| 61 | */ |
| 62 | public Class<?> getInputClass() { |
| 63 | return inputClass; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns true if the ImageInputStream can use a cache |
| 68 | * file. If this method returns false, the value of the |
| 69 | * useCache parameter of createInputStreamInstance will |
| 70 | * be ignored. The default implementation returns false. |
| 71 | * |
| 72 | * @return true if the ImageInputStream can use a cache |
| 73 | * file, false otherwise. |
| 74 | */ |
| 75 | public boolean canUseCacheFile() { |
| 76 | return false; //-- def |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Returns true if the ImageInputStream implementation |
| 81 | * requires the use of a cache file. The default implementation |
| 82 | * returns false. |
| 83 | * |
| 84 | * @return true if the ImageInputStream implementation |
| 85 | * requires the use of a cache file, false otherwise. |
| 86 | */ |
| 87 | public boolean needsCacheFile() { |
| 88 | return false; // def |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Creates the ImageInputStream associated with this |
| 93 | * service provider. The input object should |
| 94 | * be an instance of the class returned by th getInputClass |
| 95 | * method. This method uses the specified directory |
| 96 | * for the cache file if the useCache parameter is true. |
| 97 | * |
| 98 | * @param input the input Object. |
| 99 | * @param useCache the flag indicating if a cache file |
| 100 | * is needed or not. |
| 101 | * @param cacheDir the cache directory. |
| 102 | * |
| 103 | * @return the ImageInputStream. |
| 104 | * |
| 105 | * @throws IOException Signals that an I/O exception has occurred. |
| 106 | */ |
| 107 | public abstract ImageInputStream createInputStreamInstance(Object input, boolean useCache, |
| 108 | File cacheDir) throws IOException; |
| 109 | |
| 110 | /** |
| 111 | * Creates the ImageInputStream associated with this |
| 112 | * service provider. The input object should |
| 113 | * be an instance of the class returned by getInputClass |
| 114 | * method. This method uses the default system directory |
| 115 | * for the cache file, if it is needed. |
| 116 | * |
| 117 | * @param input the input Object. |
| 118 | * |
| 119 | * @return the ImageInputStream. |
| 120 | * |
| 121 | * @throws IOException Signals that an I/O exception has occurred. |
| 122 | */ |
| 123 | public ImageInputStream createInputStreamInstance(Object input) throws IOException { |
| 124 | return createInputStreamInstance(input, true, null); |
| 125 | } |
| 126 | } |