jdk/src/share/classes/javax/sound/sampled/CompoundControl.java
author prr
Wed, 18 Jun 2014 13:14:15 -0700
changeset 25144 e2bf17cee34b
parent 25128 2dfdfa369071
parent 24969 afa6934dd8e8
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.sound.sampled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    29
 * A {@code CompoundControl}, such as a graphic equalizer, provides control over
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    30
 * two or more related properties, each of which is itself represented as a
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    31
 * {@code Control}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @author Kara Kytle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public abstract class CompoundControl extends Control {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     * The set of member controls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private Control[] controls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * Constructs a new compound control object with the given parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     *
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    46
     * @param  type the type of control represented this compound control object
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    47
     * @param  memberControls the set of member controls
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    protected CompoundControl(Type type, Control[] memberControls) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        super(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        this.controls = memberControls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Returns the set of member controls that comprise the compound control.
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    56
     *
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    57
     * @return the set of member controls
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public Control[] getMemberControls() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        Control[] localArray = new Control[controls.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        for (int i = 0; i < controls.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            localArray[i] = controls[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        return localArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    70
     * Provides a string representation of the control.
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    71
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @return a string description
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    74
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 5506
diff changeset
    77
        StringBuilder sb = new StringBuilder();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        for (int i = 0; i < controls.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            if (i != 0) {
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 5506
diff changeset
    80
                sb.append(", ");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                if ((i + 1) == controls.length) {
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 5506
diff changeset
    82
                    sb.append("and ");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            }
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 5506
diff changeset
    85
            sb.append(controls[i].getType());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 5506
diff changeset
    88
        return new String(getType() + " Control containing " + sb + " Controls.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    92
     * An instance of the {@code CompoundControl.Type} inner class identifies
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    93
     * one kind of compound control. Static instances are provided for the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * common types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @author Kara Kytle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public static class Type extends Control.Type {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
         * Constructs a new compound control type.
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   103
         *
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   104
         * @param  name the name of the new compound control type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
         */
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   106
        protected Type(final String name) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   109
    }
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   110
}