1. /*
  2. * @(#)CompoundControl.java 1.10 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. * A <code>CompoundControl</code>, such as a graphic equalizer, provides control
  10. * over two or more related properties, each of which is itself represented as
  11. * a <code>Control</code>.
  12. *
  13. * @author Kara Kytle
  14. * @version 1.10, 03/12/19
  15. * @since 1.3
  16. */
  17. public abstract class CompoundControl extends Control {
  18. // TYPE DEFINES
  19. // INSTANCE VARIABLES
  20. /**
  21. * The set of member controls.
  22. */
  23. private Control[] controls;
  24. // CONSTRUCTORS
  25. /**
  26. * Constructs a new compound control object with the given parameters.
  27. *
  28. * @param type the type of control represented this compound control object
  29. * @param memberControls the set of member controls
  30. */
  31. protected CompoundControl(Type type, Control[] memberControls) {
  32. super(type);
  33. this.controls = memberControls;
  34. }
  35. // METHODS
  36. /**
  37. * Returns the set of member controls that comprise the compound control.
  38. * @return the set of member controls.
  39. */
  40. public Control[] getMemberControls() {
  41. Control[] localArray = new Control[controls.length];
  42. for (int i = 0; i < controls.length; i++) {
  43. localArray[i] = controls[i];
  44. }
  45. return localArray;
  46. }
  47. // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
  48. /**
  49. * Provides a string representation of the control
  50. * @return a string description
  51. */
  52. public String toString() {
  53. StringBuffer buf = new StringBuffer();
  54. for (int i = 0; i < controls.length; i++) {
  55. if (i != 0) {
  56. buf.append(", ");
  57. if ((i + 1) == controls.length) {
  58. buf.append("and ");
  59. }
  60. }
  61. buf.append(controls[i].getType());
  62. }
  63. return new String(getType() + " Control containing " + buf + " Controls.");
  64. }
  65. // INNER CLASSES
  66. /**
  67. * An instance of the <code>CompoundControl.Type</code> inner class identifies one kind of
  68. * compound control. Static instances are provided for the
  69. * common types.
  70. *
  71. * @author Kara Kytle
  72. * @version 1.10, 03/12/19
  73. * @since 1.3
  74. */
  75. public static class Type extends Control.Type {
  76. // TYPE DEFINES
  77. // CONSTRUCTOR
  78. /**
  79. * Constructs a new compound control type.
  80. * @param name the name of the new compound control type
  81. */
  82. protected Type(String name) {
  83. super(name);
  84. }
  85. } // class Type
  86. } // class CompoundControl