KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)MidiDeviceProvider.java 1.19 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 javax.sound.midi.MidiDevice JavaDoc;
11 import javax.sound.midi.MidiUnavailableException JavaDoc;
12
13 /**
14  * A <code>MidiDeviceProvider</code> is a factory or provider for a particular
15  * type of MIDI device.
16  * This mechanism allows the implementation to determine
17  * how resources are managed in the creation and management of
18  * a device.
19  *
20  * @version 1.19 03/12/19
21  * @author Kara Kytle
22  */

23 public abstract class MidiDeviceProvider {
24
25
26     /**
27      * Indicates whether the device provider supports the device represented by
28      * the specified device info object.
29      * @param info an info object that describes the device for which support is queried
30      * @return <code>true</code> if the specified device is supported,
31      * otherwise <code>false</code>
32      */

33     public boolean isDeviceSupported(MidiDevice.Info JavaDoc info) {
34
35     MidiDevice.Info JavaDoc infos[] = getDeviceInfo();
36
37     for(int i=0; i<infos.length; i++) {
38         if( info.equals( infos[i] ) ) {
39         return true;
40         }
41     }
42     return false;
43     }
44
45
46     /**
47      * Obtains the set of info objects representing the device
48      * or devices provided by this <code>MidiDeviceProvider</code>.
49      * @return set of device info objects
50      */

51     public abstract MidiDevice.Info JavaDoc[] getDeviceInfo();
52
53
54     /**
55      * Obtains an instance of the device represented by the info object.
56      * @param info an info object that describes the desired device
57      * @return device instance
58      * @throws IllegalArgumentException if the info object specified does not
59      * match the info object for a device supported by this <code>MidiDeviceProvider</code>.
60      */

61     public abstract MidiDevice JavaDoc getDevice(MidiDevice.Info JavaDoc info);
62 }
63
Popular Tags