blob: fc859a87197ccda42b912166a8d7c9cdbb0c881b [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
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 Projecte09fd9e2008-12-17 18:05:43 -080021
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070022package javax.imageio.spi;
23
24import java.io.File;
25import java.io.IOException;
26import javax.imageio.stream.ImageInputStream;
27
28/**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080029 * The ImageInputStreamSpi abstract class is a service provider interface (SPI)
30 * for ImageInputStreams.
31 *
32 * @since Android 1.0
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070033 */
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080034public abstract class ImageInputStreamSpi extends IIOServiceProvider implements RegisterableService {
35
36 /**
37 * The input class.
38 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070039 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 Projecte09fd9e2008-12-17 18:05:43 -080051 * @param vendorName
52 * the vendor name.
53 * @param version
54 * the version.
55 * @param inputClass
56 * the input class.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070057 */
58 public ImageInputStreamSpi(String vendorName, String version, Class<?> inputClass) {
59 super(vendorName, version);
60 this.inputClass = inputClass;
61 }
62
63 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080064 * Gets an input Class object that represents class or interface that must
65 * be implemented by an input source.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070066 *
67 * @return the input class.
68 */
69 public Class<?> getInputClass() {
70 return inputClass;
71 }
72
73 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080074 * 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 Project7c1b96a2008-10-21 07:00:00 -070078 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080079 * @return true, if the ImageInputStream can use a cache file, false
80 * otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070081 */
82 public boolean canUseCacheFile() {
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080083 return false; // -- def
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070084 }
85
86 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080087 * Returns true if the ImageInputStream implementation requires the use of a
88 * cache file. The default implementation returns false.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070089 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080090 * @return true, if the ImageInputStream implementation requires the use of
91 * a cache file, false otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070092 */
93 public boolean needsCacheFile() {
94 return false; // def
95 }
96
97 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080098 * 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 Project7c1b96a2008-10-21 07:00:00 -0700102 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800103 * @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 Project7c1b96a2008-10-21 07:00:00 -0700109 * @return the ImageInputStream.
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800110 * @throws IOException
111 * if an I/O exception has occurred.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700112 */
113 public abstract ImageInputStream createInputStreamInstance(Object input, boolean useCache,
114 File cacheDir) throws IOException;
115
116 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800117 * 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 Project7c1b96a2008-10-21 07:00:00 -0700121 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800122 * @param input
123 * the input Object.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700124 * @return the ImageInputStream.
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800125 * @throws IOException
126 * if an I/O exception has occurred.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700127 */
128 public ImageInputStream createInputStreamInstance(Object input) throws IOException {
129 return createInputStreamInstance(input, true, null);
130 }
131}