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