Path: blob/master/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java
41171 views
/*1* Copyright (c) 1999, 2020, 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.IOException;29import java.io.InputStream;30import java.net.URL;3132import javax.sound.midi.InvalidMidiDataException;33import javax.sound.midi.MidiFileFormat;34import javax.sound.midi.Sequence;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* Constructor for subclasses to call.49*/50protected MidiFileReader() {}5152/**53* Obtains the MIDI file format of the input stream provided. The stream54* must point to valid MIDI file data. In general, MIDI file readers may55* need to read some data from the stream before determining whether they56* support it. These parsers must be able to mark the stream, read enough57* data to determine whether they support the stream, and, if not, reset the58* stream's read pointer to its original position. If the input stream does59* not support this, this method may fail with an {@code IOException}.60*61* @param stream the input stream from which file format information should62* be extracted63* @return a {@code MidiFileFormat} object describing the MIDI file format64* @throws InvalidMidiDataException if the stream does not point to valid65* MIDI file data recognized by the system66* @throws IOException if an I/O exception occurs67* @throws NullPointerException if {@code stream} is {@code null}68* @see InputStream#markSupported69* @see InputStream#mark70*/71public abstract MidiFileFormat getMidiFileFormat(InputStream stream)72throws InvalidMidiDataException, IOException;7374/**75* Obtains the MIDI file format of the {@code URL} provided. The {@code URL}76* must point to valid MIDI file data.77*78* @param url the {@code URL} from which file format information should be79* extracted80* @return a {@code MidiFileFormat} object describing the MIDI file format81* @throws InvalidMidiDataException if the {@code URL} does not point to82* valid MIDI file data recognized by the system83* @throws IOException if an I/O exception occurs84* @throws NullPointerException if {@code url} is {@code null}85*/86public abstract MidiFileFormat getMidiFileFormat(URL url)87throws InvalidMidiDataException, IOException;8889/**90* Obtains the MIDI file format of the {@code File} provided. The91* {@code File} must point to valid MIDI file data.92*93* @param file the {@code File} from which file format information should94* be extracted95* @return a {@code MidiFileFormat} object describing the MIDI file format96* @throws InvalidMidiDataException if the {@code File} does not point to97* valid MIDI file data recognized by the system98* @throws IOException if an I/O exception occurs99* @throws NullPointerException if {@code file} is {@code null}100*/101public abstract MidiFileFormat getMidiFileFormat(File file)102throws InvalidMidiDataException, IOException;103104/**105* Obtains a MIDI sequence from the input stream provided. The stream must106* point to valid MIDI file data. In general, MIDI file readers may need to107* read some data from the stream before determining whether they support108* it. These parsers must be able to mark the stream, read enough data to109* determine whether they support the stream, and, if not, reset the110* stream's read pointer to its original position. If the input stream does111* not support this, this method may fail with an {@code IOException}.112*113* @param stream the input stream from which the {@code Sequence} should be114* constructed115* @return a {@code Sequence} object based on the MIDI file data contained116* in the input stream117* @throws InvalidMidiDataException if the stream does not point to valid118* MIDI file data recognized by the system119* @throws IOException if an I/O exception occurs120* @throws NullPointerException if {@code stream} is {@code null}121* @see InputStream#markSupported122* @see InputStream#mark123*/124public abstract Sequence getSequence(InputStream stream)125throws InvalidMidiDataException, IOException;126127/**128* Obtains a MIDI sequence from the {@code URL} provided. The {@code URL}129* must point to valid MIDI file data.130*131* @param url the {@code URL} for which the {@code Sequence} should be132* constructed133* @return a {@code Sequence} object based on the MIDI file data pointed to134* by the {@code URL}135* @throws InvalidMidiDataException if the {@code URL} does not point to136* valid MIDI file data recognized by the system137* @throws IOException if an I/O exception occurs138* @throws NullPointerException if {@code url} is {@code null}139*/140public abstract Sequence getSequence(URL url)141throws InvalidMidiDataException, IOException;142143/**144* Obtains a MIDI sequence from the {@code File} provided. The {@code File}145* must point to valid MIDI file data.146*147* @param file the {@code File} from which the {@code Sequence} should be148* constructed149* @return a {@code Sequence} object based on the MIDI file data pointed to150* by the {@code File}151* @throws InvalidMidiDataException if the {@code File} does not point to152* valid MIDI file data recognized by the system153* @throws IOException if an I/O exception occurs154* @throws NullPointerException if {@code file} is {@code null}155*/156public abstract Sequence getSequence(File file)157throws InvalidMidiDataException, IOException;158}159160161