Source Code Cross Referenced for AudioFileWriter.java in  » 6.0-JDK-Core » sound » javax » sound » sampled » 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 » sound » javax.sound.sampled.spi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1999-2003 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.sound.sampled.spi;
027
028        import java.io.File;
029        import java.io.InputStream;
030        import java.io.IOException;
031        import java.io.OutputStream;
032
033        import javax.sound.sampled.AudioFileFormat;
034        import javax.sound.sampled.AudioInputStream;
035
036        /**
037         * Provider for audio file writing services.  Classes providing concrete
038         * implementations can write one or more types of audio file from an audio
039         * stream.
040         *
041         * @author Kara Kytle
042         * @version 1.31, 07/05/05
043         * @since 1.3
044         */
045        public abstract class AudioFileWriter {
046
047            /**
048             * Obtains the file types for which file writing support is provided by this
049             * audio file writer.
050             * @return array of file types.  If no file types are supported,
051             * an array of length 0 is returned.
052             */
053            public abstract AudioFileFormat.Type[] getAudioFileTypes();
054
055            /**
056             * Indicates whether file writing support for the specified file type is provided
057             * by this audio file writer.
058             * @param fileType the file type for which write capabilities are queried
059             * @return <code>true</code> if the file type is supported,
060             * otherwise <code>false</code>
061             */
062            public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {
063
064                AudioFileFormat.Type types[] = getAudioFileTypes();
065
066                for (int i = 0; i < types.length; i++) {
067                    if (fileType.equals(types[i])) {
068                        return true;
069                    }
070                }
071                return false;
072            }
073
074            /**
075             * Obtains the file types that this audio file writer can write from the
076             * audio input stream specified.
077             * @param stream the audio input stream for which audio file type support
078             * is queried
079             * @return array of file types.  If no file types are supported,
080             * an array of length 0 is returned.
081             */
082            public abstract AudioFileFormat.Type[] getAudioFileTypes(
083                    AudioInputStream stream);
084
085            /**
086             * Indicates whether an audio file of the type specified can be written
087             * from the audio input stream indicated.
088             * @param fileType file type for which write capabilities are queried
089             * @param stream for which file writing support is queried
090             * @return <code>true</code> if the file type is supported for this audio input stream,
091             * otherwise <code>false</code>
092             */
093            public boolean isFileTypeSupported(AudioFileFormat.Type fileType,
094                    AudioInputStream stream) {
095
096                AudioFileFormat.Type types[] = getAudioFileTypes(stream);
097
098                for (int i = 0; i < types.length; i++) {
099                    if (fileType.equals(types[i])) {
100                        return true;
101                    }
102                }
103                return false;
104            }
105
106            /**
107             * Writes a stream of bytes representing an audio file of the file type
108             * indicated to the output stream provided.  Some file types require that
109             * the length be written into the file header, and cannot be written from
110             * start to finish unless the length is known in advance.  An attempt
111             * to write such a file type will fail with an IOException if the length in
112             * the audio file format is
113             * {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED AudioSystem.NOT_SPECIFIED}.
114             * @param stream the audio input stream containing audio data to be
115             * written to the output stream
116             * @param fileType file type to be written to the output stream
117             * @param out stream to which the file data should be written
118             * @return the number of bytes written to the output stream
119             * @throws IOException if an I/O exception occurs
120             * @throws IllegalArgumentException if the file type is not supported by
121             * the system
122             * @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream)
123             * @see #getAudioFileTypes
124             */
125            public abstract int write(AudioInputStream stream,
126                    AudioFileFormat.Type fileType, OutputStream out)
127                    throws IOException;
128
129            /**
130             * Writes a stream of bytes representing an audio file of the file format
131             * indicated to the external file provided.
132             * @param stream the audio input stream containing audio data to be
133             * written to the file
134             * @param fileType file type to be written to the file
135             * @param out external file to which the file data should be written
136             * @return the number of bytes written to the file
137             * @throws IOException if an I/O exception occurs
138             * @throws IllegalArgumentException if the file format is not supported by
139             * the system
140             * @see #isFileTypeSupported
141             * @see #getAudioFileTypes
142             */
143            public abstract int write(AudioInputStream stream,
144                    AudioFileFormat.Type fileType, File out) throws IOException;
145
146        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.