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