Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / javax / imageio / spi / ImageInputStreamSpi.java
blob8679ed1f4d7cf5788ae3f872863df98e265e147b
1 /* ImageInputStreamSpi.java -- Service provider for image input 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.ImageInputStream;
46 /**
47 * An abstract superclass for service providers that create
48 * {@linkplain javax.imageio.stream.ImageInputStream image input
49 * streams} for a file, URL, byte array or any other source.
51 * @since 1.4
53 * @author Sascha Brawer (brawer@dandelis.ch)
55 public abstract class ImageInputStreamSpi
56 extends IIOServiceProvider
58 /**
59 * Indicates which kind of input is processable by the streams
60 * created by {@link #createInputStreamInstance(Object)}.
62 protected Class inputClass;
65 /**
66 * Constructs a service provider for image input streams, given no
67 * parameters. It is up to the sub-class to set {@link #vendorName},
68 * {@link #version} and {@link #inputClass} to non-null values.
70 protected ImageInputStreamSpi()
75 /**
76 * Constructs a service provider for image input streams, given the
77 * vendor name and a version string.
79 * @throws IllegalArgumentException if <code>vendorName</code>
80 * or <code>version</code> is <code>null</code>.
82 public ImageInputStreamSpi(String vendorName, String version,
83 Class inputClass)
85 super(vendorName, version);
86 this.inputClass = inputClass;
90 /**
91 * Determines which kind of input is processable by the streams
92 * created by {@link #createInputStreamInstance(Object)}.
94 public Class getInputClass()
96 return inputClass;
101 * Determines whether <code>ImageInputStreams</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>ImageInputStreams</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 ImageInputStream createInputStreamInstance(Object input,
134 boolean useCache,
135 File cacheDir)
136 throws IOException;
139 public ImageInputStream createInputStreamInstance(Object input)
140 throws IOException
142 return createInputStreamInstance(input, canUseCacheFile(), null);