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