Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/sound/midi/spi/MidiFileReader.java
38923 views
/*1* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sound.midi.spi;2627import java.io.File;28import java.io.InputStream;29import java.io.IOException;30import java.net.URL;3132import javax.sound.midi.MidiFileFormat;33import javax.sound.midi.Sequence;34import javax.sound.midi.InvalidMidiDataException;3536/**37* A {@code MidiFileReader} supplies MIDI file-reading services. Classes38* implementing this interface can parse the format information from one or more39* types of MIDI file, and can produce a {@link Sequence} object from files of40* these types.41*42* @author Kara Kytle43* @since 1.344*/45public abstract class MidiFileReader {4647/**48* Obtains the MIDI file format of the input stream provided. The stream49* must point to valid MIDI file data. In general, MIDI file readers may50* need to read some data from the stream before determining whether they51* support it. These parsers must be able to mark the stream, read enough52* data to determine whether they support the stream, and, if not, reset the53* stream's read pointer to its original position. If the input stream does54* not support this, this method may fail with an {@code IOException}.55*56* @param stream the input stream from which file format information57* should be extracted58* @return a {@code MidiFileFormat} object describing the MIDI file format59* @throws InvalidMidiDataException if the stream does not point to valid60* MIDI file data recognized by the system61* @throws IOException if an I/O exception occurs62* @see InputStream#markSupported63* @see InputStream#mark64*/65public abstract MidiFileFormat getMidiFileFormat(InputStream stream)66throws InvalidMidiDataException, IOException;6768/**69* Obtains the MIDI file format of the URL provided. The URL must point to70* valid MIDI file data.71*72* @param url the URL from which file format information should be73* extracted74* @return a {@code MidiFileFormat} object describing the MIDI file format75* @throws InvalidMidiDataException if the URL does not point to valid MIDI76* file data recognized by the system77* @throws IOException if an I/O exception occurs78*/79public abstract MidiFileFormat getMidiFileFormat(URL url)80throws InvalidMidiDataException, IOException;8182/**83* Obtains the MIDI file format of the {@code File} provided. The84* {@code File} must point to valid MIDI file data.85*86* @param file the {@code File} from which file format information should87* be extracted88* @return a {@code MidiFileFormat} object describing the MIDI file format89* @throws InvalidMidiDataException if the {@code File} does not point to90* valid MIDI file data recognized by the system91* @throws IOException if an I/O exception occurs92*/93public abstract MidiFileFormat getMidiFileFormat(File file)94throws InvalidMidiDataException, IOException;9596/**97* Obtains a MIDI sequence from the input stream provided. The stream must98* point to valid MIDI file data. In general, MIDI file readers may need to99* read some data from the stream before determining whether they support100* it. These parsers must be able to mark the stream, read enough data to101* determine whether they support the stream, and, if not, reset the102* stream's read pointer to its original position. If the input stream does103* not support this, this method may fail with an IOException.104*105* @param stream the input stream from which the {@code Sequence} should106* be constructed107* @return a {@code Sequence} object based on the MIDI file data contained108* in the input stream.109* @throws InvalidMidiDataException if the stream does not point to valid110* MIDI file data recognized by the system111* @throws IOException if an I/O exception occurs112* @see InputStream#markSupported113* @see InputStream#mark114*/115public abstract Sequence getSequence(InputStream stream)116throws InvalidMidiDataException, IOException;117118/**119* Obtains a MIDI sequence from the URL provided. The URL must point to120* valid MIDI file data.121*122* @param url the URL for which the {@code Sequence} should be constructed123* @return a {@code Sequence} object based on the MIDI file data pointed to124* by the URL125* @throws InvalidMidiDataException if the URL does not point to valid MIDI126* file data recognized by the system127* @throws IOException if an I/O exception occurs128*/129public abstract Sequence getSequence(URL url)130throws InvalidMidiDataException, IOException;131132/**133* Obtains a MIDI sequence from the {@code File} provided. The {@code File}134* must point to valid MIDI file data.135*136* @param file the {@code File} from which the {@code Sequence} should be137* constructed138* @return a {@code Sequence} object based on the MIDI file data pointed to139* by the {@code File}140* @throws InvalidMidiDataException if the {@code File} does not point to141* valid MIDI file data recognized by the system142* @throws IOException if an I/O exception occurs143*/144public abstract Sequence getSequence(File file)145throws InvalidMidiDataException, IOException;146}147148149