KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sound > sampled > spi > AudioFileReader


1 /*
2  * @(#)AudioFileReader.java 1.15 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.sound.sampled.spi;
9
10 import java.io.File JavaDoc;
11 import java.io.InputStream JavaDoc;
12 import java.io.IOException JavaDoc;
13 import java.net.URL JavaDoc;
14
15 import javax.sound.sampled.AudioFileFormat JavaDoc;
16 import javax.sound.sampled.AudioInputStream JavaDoc;
17 import javax.sound.sampled.UnsupportedAudioFileException JavaDoc;
18
19 /**
20  * Provider for audio file reading services. Classes providing concrete
21  * implementations can parse the format information from one or more types of
22  * audio file, and can produce audio input streams from files of these types.
23  *
24  * @author Kara Kytle
25  * @version 1.15 03/12/19
26  * @since 1.3
27  */

28 public abstract class AudioFileReader {
29     
30     /**
31      * Obtains the audio file format of the input stream provided. The stream must
32      * point to valid audio file data. In general, audio file readers may
33      * need to read some data from the stream before determining whether they
34      * support it. These parsers must
35      * be able to mark the stream, read enough data to determine whether they
36      * support the stream, and, if not, reset the stream's read pointer to its original
37      * position. If the input stream does not support this, this method may fail
38      * with an <code>IOException</code>.
39      * @param stream the input stream from which file format information should be
40      * extracted
41      * @return an <code>AudioFileFormat</code> object describing the audio file format
42      * @throws UnsupportedAudioFileException if the stream does not point to valid audio
43      * file data recognized by the system
44      * @throws IOException if an I/O exception occurs
45      * @see InputStream#markSupported
46      * @see InputStream#mark
47      */

48     public abstract AudioFileFormat JavaDoc getAudioFileFormat(InputStream JavaDoc stream) throws UnsupportedAudioFileException JavaDoc, IOException JavaDoc;
49     
50     /**
51      * Obtains the audio file format of the URL provided. The URL must
52      * point to valid audio file data.
53      * @param url the URL from which file format information should be
54      * extracted
55      * @return an <code>AudioFileFormat</code> object describing the audio file format
56      * @throws UnsupportedAudioFileException if the URL does not point to valid audio
57      * file data recognized by the system
58      * @throws IOException if an I/O exception occurs
59      */

60     public abstract AudioFileFormat JavaDoc getAudioFileFormat(URL JavaDoc url) throws UnsupportedAudioFileException JavaDoc, IOException JavaDoc;
61     
62     /**
63      * Obtains the audio file format of the <code>File</code> provided. The <code>File</code> must
64      * point to valid audio file data.
65      * @param file the <code>File</code> from which file format information should be
66      * extracted
67      * @return an <code>AudioFileFormat</code> object describing the audio file format
68      * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
69      * file data recognized by the system
70      * @throws IOException if an I/O exception occurs
71      */

72     public abstract AudioFileFormat JavaDoc getAudioFileFormat(File JavaDoc file) throws UnsupportedAudioFileException JavaDoc, IOException JavaDoc;
73     
74     /**
75      * Obtains an audio input stream from the input stream provided. The stream must
76      * point to valid audio file data. In general, audio file readers may
77      * need to read some data from the stream before determining whether they
78      * support it. These parsers must
79      * be able to mark the stream, read enough data to determine whether they
80      * support the stream, and, if not, reset the stream's read pointer to its original
81      * position. If the input stream does not support this, this method may fail
82      * with an <code>IOException</code>.
83      * @param stream the input stream from which the <code>AudioInputStream</code> should be
84      * constructed
85      * @return an <code>AudioInputStream</code> object based on the audio file data contained
86      * in the input stream.
87      * @throws UnsupportedAudioFileException if the stream does not point to valid audio
88      * file data recognized by the system
89      * @throws IOException if an I/O exception occurs
90      * @see InputStream#markSupported
91      * @see InputStream#mark
92      */

93     public abstract AudioInputStream JavaDoc getAudioInputStream(InputStream JavaDoc stream) throws UnsupportedAudioFileException JavaDoc, IOException JavaDoc;
94     
95     /**
96      * Obtains an audio input stream from the URL provided. The URL must
97      * point to valid audio file data.
98      * @param url the URL for which the <code>AudioInputStream</code> should be
99      * constructed
100      * @return an <code>AudioInputStream</code> object based on the audio file data pointed
101      * to by the URL
102      * @throws UnsupportedAudioFileException if the URL does not point to valid audio
103      * file data recognized by the system
104      * @throws IOException if an I/O exception occurs
105      */

106     public abstract AudioInputStream JavaDoc getAudioInputStream(URL JavaDoc url) throws UnsupportedAudioFileException JavaDoc, IOException JavaDoc;
107     
108     /**
109      * Obtains an audio input stream from the <code>File</code> provided. The <code>File</code> must
110      * point to valid audio file data.
111      * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
112      * constructed
113      * @return an <code>AudioInputStream</code> object based on the audio file data pointed
114      * to by the File
115      * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
116      * file data recognized by the system
117      * @throws IOException if an I/O exception occurs
118      */

119     public abstract AudioInputStream JavaDoc getAudioInputStream(File JavaDoc file) throws UnsupportedAudioFileException JavaDoc, IOException JavaDoc;
120 }
121
Popular Tags