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