blob: b7a9a5c33322acf6ac7d84ccb693bf5864d8e6f8 [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 javax.imageio.stream.ImageOutputStream;
25import java.io.IOException;
26import java.io.File;
27
28/**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080029 * The ImageOutputStreamSpi abstract class is a service provider interface (SPI)
30 * for ImageOutputStreams.
31 *
32 * @since Android 1.0
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070033 */
34public abstract class ImageOutputStreamSpi extends IIOServiceProvider implements
35 RegisterableService {
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080036
37 /**
38 * The output class.
39 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070040 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 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080052 * @param vendorName
53 * the vendor name.
54 * @param version
55 * the version.
56 * @param outputClass
57 * the output class.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070058 */
59 public ImageOutputStreamSpi(String vendorName, String version, Class<?> outputClass) {
60 super(vendorName, version);
61 this.outputClass = outputClass;
62 }
63
64 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080065 * Gets an output Class object that represents the class or interface that
66 * must be implemented by an output source.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070067 *
68 * @return the output class.
69 */
70 public Class<?> getOutputClass() {
71 return outputClass;
72 }
73
74 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080075 * 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.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070079 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080080 * @return true, if the ImageOutputStream can use a cache file, false
81 * otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070082 */
83 public boolean canUseCacheFile() {
84 return false; // def
85 }
86
87 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080088 * Returns true if the ImageOutputStream implementation requires the use of
89 * a cache file. The default implementation returns false.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070090 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080091 * @return true, if the ImageOutputStream implementation requires the use of
92 * a cache file, false otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070093 */
94 public boolean needsCacheFile() {
95 return false; // def
96 }
97
98 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080099 * 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.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700103 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800104 * @param output
105 * the output Object.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700106 * @return the ImageOutputStream.
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800107 * @throws IOException
108 * if an I/O exception has occurred.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700109 */
110 public ImageOutputStream createOutputStreamInstance(Object output) throws IOException {
111 return createOutputStreamInstance(output, true, null);
112 }
113
114 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800115 * 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.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700119 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800120 * @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.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700126 * @return the ImageOutputStream.
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800127 * @throws IOException
128 * if an I/O exception has occurred.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700129 */
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800130 public abstract ImageOutputStream createOutputStreamInstance(Object output, boolean useCache,
131 File cacheDir) throws IOException;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700132}