KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sound > midi > spi > MidiFileReader


1 /*
2  * @(#)MidiFileReader.java 1.13 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.midi.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.midi.MidiFileFormat JavaDoc;
16 import javax.sound.midi.Sequence JavaDoc;
17 import javax.sound.midi.InvalidMidiDataException JavaDoc;
18
19 /**
20  * A <code>MidiFileReader</code> supplies MIDI file-reading services. Classes implementing this
21  * interface can parse the format information from one or more types of
22  * MIDI file, and can produce a <code>Sequence</code> object from files of these types.
23  *
24  * @author Kara Kytle
25  * @version 1.13 03/12/19
26  * @since 1.3
27  */

28 public abstract class MidiFileReader {
29
30     /**
31      * Obtains the MIDI file format of the input stream provided. The stream must
32      * point to valid MIDI file data. In general, MIDI 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 a <code>MidiFileFormat</code> object describing the MIDI file format
42      * @throws InvalidMidiDataException if the stream does not point to valid MIDI
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 MidiFileFormat JavaDoc getMidiFileFormat(InputStream JavaDoc stream) throws InvalidMidiDataException JavaDoc, IOException JavaDoc;
49
50
51     /**
52      * Obtains the MIDI file format of the URL provided. The URL must
53      * point to valid MIDI file data.
54      * @param url the URL from which file format information should be
55      * extracted
56      * @return a <code>MidiFileFormat</code> object describing the MIDI file format
57      * @throws InvalidMidiDataException if the URL does not point to valid MIDI
58      * file data recognized by the system
59      * @throws IOException if an I/O exception occurs
60      */

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

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

96     public abstract Sequence JavaDoc getSequence(InputStream JavaDoc stream) throws InvalidMidiDataException JavaDoc, IOException JavaDoc;
97
98
99     /**
100      * Obtains a MIDI sequence from the URL provided. The URL must
101      * point to valid MIDI file data.
102      * @param url the URL for which the <code>Sequence</code> should be
103      * constructed
104      * @return a <code>Sequence</code> object based on the MIDI file data pointed
105      * to by the URL
106      * @throws InvalidMidiDataException if the URL does not point to valid MIDI
107      * file data recognized by the system
108      * @throws IOException if an I/O exception occurs
109      */

110     public abstract Sequence JavaDoc getSequence(URL JavaDoc url) throws InvalidMidiDataException JavaDoc, IOException JavaDoc;
111
112
113     /**
114      * Obtains a MIDI sequence from the <code>File</code> provided. The <code>File</code> must
115      * point to valid MIDI file data.
116      * @param file the <code>File</code> from which the <code>Sequence</code> should be
117      * constructed
118      * @return a <code>Sequence</code> object based on the MIDI file data pointed
119      * to by the <code>File</code>
120      * @throws InvalidMidiDataException if the <code>File</code> does not point to valid MIDI
121      * file data recognized by the system
122      * @throws IOException if an I/O exception occurs
123      */

124     public abstract Sequence JavaDoc getSequence(File JavaDoc file) throws InvalidMidiDataException JavaDoc, IOException JavaDoc;
125 }
126
Popular Tags