Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / javax / imageio / spi / ImageOutputStreamSpi.java
blob43781aa11126d97f1c3b444abc747e5a98138752
1 /* ImageOutputStreamSpi.java -- Service provider for image output streams.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.imageio.spi;
41 import java.io.File;
42 import java.io.IOException;
44 import javax.imageio.stream.ImageOutputStream;
46 /**
47 * An abstract superclass for service providers that create
48 * {@linkplain javax.imageio.stream.ImageOutputStream image output
49 * streams} for a file, URL, byte array or any other target.
51 * @since 1.4
53 * @author Sascha Brawer (brawer@dandelis.ch)
55 public abstract class ImageOutputStreamSpi
56 extends IIOServiceProvider
58 /**
59 * Indicates which kind of output is produced by the streams
60 * created by {@link #createOutputStreamInstance(Object)}.
62 protected Class outputClass;
65 /**
66 * Constructs a service provider for image output streams, given no
67 * parameters. It is up to the sub-class to set {@link #vendorName},
68 * {@link #version} and {@link #outputClass} to non-null values.
70 protected ImageOutputStreamSpi()
75 /**
76 * Constructs a service provider for image output streams, given the
77 * vendor name, a version string and the kind of producable output.
79 * @throws IllegalArgumentException if <code>vendorName</code>
80 * or <code>version</code> is <code>null</code>.
82 public ImageOutputStreamSpi(String vendorName, String version,
83 Class outputClass)
85 super(vendorName, version);
86 this.outputClass = outputClass;
90 /**
91 * Determines which kind of output is produced by the streams
92 * created by {@link #createOutputStreamInstance(Object)}.
94 public Class getOutputClass()
96 return outputClass;
101 * Determines whether <code>ImageOutputStreams</code> created
102 * by this service provider benefit from using a cache file.
104 * <p>The default behavior is to return <code>false</code>.
106 * @return <code>true</code> if the created streams are faster or
107 * need less memory when a cache file is being used;
108 * <code>false</code> if no positive effect results from the cache
109 * file.
111 public boolean canUseCacheFile()
113 return false;
118 * Determines whether <code>ImageOutputStreams</code> created
119 * by this service provider require the use of a cache file.
121 * <p>The default behavior is to return <code>false</code>.
123 * @return <code>true</code> if the created streams can only work
124 * when a cache file is being used; <code>false</code> if no cache
125 * file is needed.
127 public boolean needsCacheFile()
129 return false;
133 public abstract ImageOutputStream createOutputStreamInstance(
134 Object output, boolean useCache, File cacheDir)
135 throws IOException;
138 public ImageOutputStream createOutputStreamInstance(Object output)
139 throws IOException
141 return createOutputStreamInstance(output, canUseCacheFile(), null);