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. package javax.sound.midi.spi;
  8. import javax.sound.midi.MidiDevice;
  9. import javax.sound.midi.MidiUnavailableException;
  10. /**
  11. * A <code>MidiDeviceProvider</code> is a factory or provider for a particular
  12. * type of MIDI device.
  13. * This mechanism allows the implementation to determine
  14. * how resources are managed in the creation and management of
  15. * a device.
  16. *
  17. * @version 1.19 03/12/19
  18. * @author Kara Kytle
  19. */
  20. public abstract class MidiDeviceProvider {
  21. /**
  22. * Indicates whether the device provider supports the device represented by
  23. * the specified device info object.
  24. * @param info an info object that describes the device for which support is queried
  25. * @return <code>true</code> if the specified device is supported,
  26. * otherwise <code>false</code>
  27. */
  28. public boolean isDeviceSupported(MidiDevice.Info info) {
  29. MidiDevice.Info infos[] = getDeviceInfo();
  30. for(int i=0; i<infos.length; i++) {
  31. if( info.equals( infos[i] ) ) {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. /**
  38. * Obtains the set of info objects representing the device
  39. * or devices provided by this <code>MidiDeviceProvider</code>.
  40. * @return set of device info objects
  41. */
  42. public abstract MidiDevice.Info[] getDeviceInfo();
  43. /**
  44. * Obtains an instance of the device represented by the info object.
  45. * @param info an info object that describes the desired device
  46. * @return device instance
  47. * @throws IllegalArgumentException if the info object specified does not
  48. * match the info object for a device supported by this <code>MidiDeviceProvider</code>.
  49. */
  50. public abstract MidiDevice getDevice(MidiDevice.Info info);
  51. }