Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java
41171 views
1
/*
2
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package javax.sound.sampled.spi;
27
28
import java.io.File;
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.net.URL;
32
33
import javax.sound.sampled.AudioFileFormat;
34
import javax.sound.sampled.AudioInputStream;
35
import javax.sound.sampled.UnsupportedAudioFileException;
36
37
/**
38
* Provider for audio file reading services. Classes providing concrete
39
* implementations can parse the format information from one or more types of
40
* audio file, and can produce audio input streams from files of these types.
41
*
42
* @author Kara Kytle
43
* @since 1.3
44
*/
45
public abstract class AudioFileReader {
46
47
/**
48
* Constructor for subclasses to call.
49
*/
50
protected AudioFileReader() {}
51
52
/**
53
* Obtains the audio file format of the input stream provided. The stream
54
* must point to valid audio file data. In general, audio file readers may
55
* need to read some data from the stream before determining whether they
56
* support it. These parsers must be able to mark the stream, read enough
57
* data to determine whether they support the stream, and reset the stream's
58
* read pointer to its original position. If the input stream does not
59
* support this, this method may fail with an {@code IOException}.
60
*
61
* @param stream the input stream from which file format information should
62
* be extracted
63
* @return an {@code AudioFileFormat} object describing the audio file
64
* format
65
* @throws UnsupportedAudioFileException if the stream does not point to
66
* valid audio file data recognized by the system
67
* @throws IOException if an I/O exception occurs
68
* @throws NullPointerException if {@code stream} is {@code null}
69
* @see InputStream#markSupported
70
* @see InputStream#mark
71
*/
72
public abstract AudioFileFormat getAudioFileFormat(InputStream stream)
73
throws UnsupportedAudioFileException, IOException;
74
75
/**
76
* Obtains the audio file format of the {@code URL} provided. The
77
* {@code URL} must point to valid audio file data.
78
*
79
* @param url the {@code URL} from which file format information should be
80
* extracted
81
* @return an {@code AudioFileFormat} object describing the audio file
82
* format
83
* @throws UnsupportedAudioFileException if the {@code URL} does not point
84
* to valid audio file data recognized by the system
85
* @throws IOException if an I/O exception occurs
86
* @throws NullPointerException if {@code url} is {@code null}
87
*/
88
public abstract AudioFileFormat getAudioFileFormat(URL url)
89
throws UnsupportedAudioFileException, IOException;
90
91
/**
92
* Obtains the audio file format of the {@code File} provided. The
93
* {@code File} must point to valid audio file data.
94
*
95
* @param file the {@code File} from which file format information should
96
* be extracted
97
* @return an {@code AudioFileFormat} object describing the audio file
98
* format
99
* @throws UnsupportedAudioFileException if the {@code File} does not point
100
* to valid audio file data recognized by the system
101
* @throws IOException if an I/O exception occurs
102
* @throws NullPointerException if {@code file} is {@code null}
103
*/
104
public abstract AudioFileFormat getAudioFileFormat(File file)
105
throws UnsupportedAudioFileException, IOException;
106
107
/**
108
* Obtains an audio input stream from the input stream provided. The stream
109
* must point to valid audio file data. In general, audio file readers may
110
* need to read some data from the stream before determining whether they
111
* support it. These parsers must be able to mark the stream, read enough
112
* data to determine whether they support the stream, and reset the stream's
113
* read pointer to its original position. If the input stream does not
114
* support this, this method may fail with an {@code IOException}.
115
*
116
* @param stream the input stream from which the {@code AudioInputStream}
117
* should be constructed
118
* @return an {@code AudioInputStream} object based on the audio file data
119
* contained in the input stream
120
* @throws UnsupportedAudioFileException if the stream does not point to
121
* valid audio file data recognized by the system
122
* @throws IOException if an I/O exception occurs
123
* @throws NullPointerException if {@code stream} is {@code null}
124
* @see InputStream#markSupported
125
* @see InputStream#mark
126
*/
127
public abstract AudioInputStream getAudioInputStream(InputStream stream)
128
throws UnsupportedAudioFileException, IOException;
129
130
/**
131
* Obtains an audio input stream from the {@code URL} provided. The
132
* {@code URL} must point to valid audio file data.
133
*
134
* @param url the {@code URL} for which the {@code AudioInputStream} should
135
* be constructed
136
* @return an {@code AudioInputStream} object based on the audio file data
137
* pointed to by the {@code URL}
138
* @throws UnsupportedAudioFileException if the {@code URL} does not point
139
* to valid audio file data recognized by the system
140
* @throws IOException if an I/O exception occurs
141
* @throws NullPointerException if {@code url} is {@code null}
142
*/
143
public abstract AudioInputStream getAudioInputStream(URL url)
144
throws UnsupportedAudioFileException, IOException;
145
146
/**
147
* Obtains an audio input stream from the {@code File} provided. The
148
* {@code File} must point to valid audio file data.
149
*
150
* @param file the {@code File} for which the {@code AudioInputStream}
151
* should be constructed
152
* @return an {@code AudioInputStream} object based on the audio file data
153
* pointed to by the File
154
* @throws UnsupportedAudioFileException if the {@code File} does not point
155
* to valid audio file data recognized by the system
156
* @throws IOException if an I/O exception occurs
157
* @throws NullPointerException if {@code file} is {@code null}
158
*/
159
public abstract AudioInputStream getAudioInputStream(File file)
160
throws UnsupportedAudioFileException, IOException;
161
}
162
163