1. /*
  2. * @(#)Control.java 1.25 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.sampled;
  8. /**
  9. * {@link Line Lines} often have a set of controls, such as gain and pan, that affect
  10. * the audio signal passing through the line. Java Sound's <code>Line</code> objects
  11. * let you obtain a particular control object by passing its class as the
  12. * argument to a {@link Line#getControl(Control.Type) getControl} method.
  13. * <p>
  14. * Because the various types of controls have different purposes and features,
  15. * all of their functionality is accessed from the subclasses that define
  16. * each kind of control.
  17. *
  18. * @author Kara Kytle
  19. * @version 1.25, 03/12/19
  20. *
  21. * @see Line#getControls
  22. * @see Line#isControlSupported
  23. * @since 1.3
  24. */
  25. public abstract class Control {
  26. // INSTANCE VARIABLES
  27. /**
  28. * The control type.
  29. */
  30. private final Type type;
  31. // CONSTRUCTORS
  32. /**
  33. * Constructs a Control with the specified type.
  34. * @param type the kind of control desired
  35. */
  36. protected Control(Type type) {
  37. this.type = type;
  38. }
  39. // METHODS
  40. /**
  41. * Obtains the control's type.
  42. * @return the control's type.
  43. */
  44. public Type getType() {
  45. return type;
  46. }
  47. // ABSTRACT METHODS
  48. /**
  49. * Obtains a String describing the control type and its current state.
  50. * @return a String representation of the Control.
  51. */
  52. public String toString() {
  53. return new String(getType() + " Control");
  54. }
  55. /**
  56. * An instance of the <code>Type</code> class represents the type of
  57. * the control. Static instances are provided for the
  58. * common types.
  59. */
  60. public static class Type {
  61. // CONTROL TYPE DEFINES
  62. // INSTANCE VARIABLES
  63. /**
  64. * Type name.
  65. */
  66. private String name;
  67. // CONSTRUCTOR
  68. /**
  69. * Constructs a new control type with the name specified.
  70. * The name should be a descriptive string appropriate for
  71. * labelling the control in an application, such as "Gain" or "Balance."
  72. * @param name the name of the new control type.
  73. */
  74. protected Type(String name) {
  75. this.name = name;
  76. }
  77. // METHODS
  78. /**
  79. * Finalizes the equals method
  80. */
  81. public final boolean equals(Object obj) {
  82. return super.equals(obj);
  83. }
  84. /**
  85. * Finalizes the hashCode method
  86. */
  87. public final int hashCode() {
  88. return super.hashCode();
  89. }
  90. /**
  91. * Provides the <code>String</code> representation of the control type. This <code>String</code> is
  92. * the same name that was passed to the constructor.
  93. *
  94. * @return the control type name
  95. */
  96. public final String toString() {
  97. return name;
  98. }
  99. } // class Type
  100. } // class Control