Source Code Cross Referenced for ImageOutputStreamSpi.java in  » 6.0-JDK-Core » image » javax » imageio » spi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » image » javax.imageio.spi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2000-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.imageio.spi;
027
028        import java.io.File;
029        import java.io.IOException;
030        import javax.imageio.stream.ImageOutputStream;
031
032        /**
033         * The service provider interface (SPI) for
034         * <code>ImageOutputStream</code>s.  For more information on service
035         * provider interfaces, see the class comment for the
036         * <code>IIORegistry</code> class.
037         *
038         * <p> This interface allows arbitrary objects to be "wrapped" by
039         * instances of <code>ImageOutputStream</code>.  For example, a
040         * particular <code>ImageOutputStreamSpi</code> might allow a generic
041         * <code>OutputStream</code> to be used as a destination; another
042         * might output to a <code>File</code> or to a device such as a serial
043         * port.
044         *
045         * <p> By treating the creation of <code>ImageOutputStream</code>s as
046         * a pluggable service, it becomes possible to handle future output
047         * destinations without changing the API.  Also, high-performance
048         * implementations of <code>ImageOutputStream</code> (for example,
049         * native implementations for a particular platform) can be installed
050         * and used transparently by applications.
051         *
052         * @see IIORegistry
053         * @see javax.imageio.stream.ImageOutputStream
054         *
055         * @version 0.5
056         */
057        public abstract class ImageOutputStreamSpi extends IIOServiceProvider {
058
059            /**
060             * A <code>Class</code> object indicating the legal object type
061             * for use by the <code>createInputStreamInstance</code> method.
062             */
063            protected Class<?> outputClass;
064
065            /**
066             * Constructs a blank <code>ImageOutputStreamSpi</code>.  It is up
067             * to the subclass to initialize instance variables and/or
068             * override method implementations in order to provide working
069             * versions of all methods.
070             */
071            protected ImageOutputStreamSpi() {
072            }
073
074            /**
075             * Constructs an <code>ImageOutputStreamSpi</code> with a given
076             * set of values.
077             *
078             * @param vendorName the vendor name.
079             * @param version a version identifier.
080             * @param outputClass a <code>Class</code> object indicating the
081             * legal object type for use by the
082             * <code>createOutputStreamInstance</code> method.
083             *
084             * @exception IllegalArgumentException if <code>vendorName</code>
085             * is <code>null</code>.
086             * @exception IllegalArgumentException if <code>version</code>
087             * is <code>null</code>. 
088             */
089            public ImageOutputStreamSpi(String vendorName, String version,
090                    Class<?> outputClass) {
091                super (vendorName, version);
092                this .outputClass = outputClass;
093            }
094
095            /**
096             * Returns a <code>Class</code> object representing the class or
097             * interface type that must be implemented by an output
098             * destination in order to be "wrapped" in an
099             * <code>ImageOutputStream</code> via the
100             * <code>createOutputStreamInstance</code> method.
101             *
102             * <p> Typical return values might include
103             * <code>OutputStream.class</code> or <code>File.class</code>, but
104             * any class may be used.
105             *
106             * @return a <code>Class</code> variable.
107             *
108             * @see #createOutputStreamInstance(Object, boolean, File)
109             */
110            public Class<?> getOutputClass() {
111                return outputClass;
112            }
113
114            /**
115             * Returns <code>true</code> if the <code>ImageOutputStream</code>
116             * implementation associated with this service provider can
117             * optionally make use of a cache <code>File</code> for improved
118             * performance and/or memory footrprint.  If <code>false</code>,
119             * the value of the <code>cacheFile</code> argument to
120             * <code>createOutputStreamInstance</code> will be ignored.
121             *
122             * <p> The default implementation returns <code>false</code>.
123             *
124             * @return <code>true</code> if a cache file can be used by the
125             * output streams created by this service provider.
126             */
127            public boolean canUseCacheFile() {
128                return false;
129            }
130
131            /**
132             * Returns <code>true</code> if the <code>ImageOutputStream</code>
133             * implementation associated with this service provider requires
134             * the use of a cache <code>File</code>.
135             *
136             * <p> The default implementation returns <code>false</code>.
137             *
138             * @return <code>true</code> if a cache file is needed by the
139             * output streams created by this service provider.
140             */
141            public boolean needsCacheFile() {
142                return false;
143            }
144
145            /**
146             * Returns an instance of the <code>ImageOutputStream</code>
147             * implementation associated with this service provider.  If the
148             * use of a cache file is optional, the <code>useCache</code>
149             * parameter will be consulted.  Where a cache is required, or 
150             * not applicable, the value of <code>useCache</code> will be ignored.
151             *
152             * @param output an object of the class type returned by
153             * <code>getOutputClass</code>.
154             * @param useCache a <code>boolean</code> indicating whether a
155             * cache file should be used, in cases where it is optional.
156             * @param cacheDir a <code>File</code> indicating where the 
157             * cache file should be created, or <code>null</code> to use the
158             * system directory.
159             *
160             * @return an <code>ImageOutputStream</code> instance.
161             *
162             * @exception IllegalArgumentException if <code>output</code> is
163             * not an instance of the correct class or is <code>null</code>.
164             * @exception IllegalArgumentException if a cache file is needed,
165             * but <code>cacheDir</code> is non-<code>null</code> and is not a
166             * directory.
167             * @exception IOException if a cache file is needed but cannot be
168             * created.
169             *
170             * @see #getOutputClass
171             */
172            public abstract ImageOutputStream createOutputStreamInstance(
173                    Object output, boolean useCache, File cacheDir)
174                    throws IOException;
175
176            /**
177             * Returns an instance of the <code>ImageOutputStream</code>
178             * implementation associated with this service provider.  A cache
179             * file will be created in the system-dependent default
180             * temporary-file directory, if needed.
181             *
182             * @param output an object of the class type returned by
183             * <code>getOutputClass</code>.
184             *
185             * @return an <code>ImageOutputStream</code> instance.
186             *
187             * @exception IllegalArgumentException if <code>output</code> is
188             * not an instance of the correct class or is <code>null</code>.
189             * @exception IOException if a cache file is needed but cannot be
190             * created.
191             *
192             * @see #getOutputClass()
193             */
194            public ImageOutputStream createOutputStreamInstance(Object output)
195                    throws IOException {
196                return createOutputStreamInstance(output, true, null);
197            }
198        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.