jdk/src/java.desktop/share/classes/javax/sound/sampled/Control.java
author serb
Thu, 31 Aug 2017 13:00:23 -0700
changeset 47195 b309b58eb190
parent 40444 afabcfc2f3ef
permissions -rw-r--r--
8181566: JavaSound javadoc clarification Reviewed-by: amenkov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
47195
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
     2
 * Copyright (c) 1999, 2017, 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
 * {@link Line Lines} often have a set of controls, such as gain and pan, that
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    30
 * affect the audio signal passing through the line. Java Sound's {@code Line}
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    31
 * objects let you obtain a particular control object by passing its class as
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    32
 * the argument to a {@link Line#getControl(Control.Type) getControl} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Because the various types of controls have different purposes and features,
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    35
 * all of their functionality is accessed from the subclasses that define each
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    36
 * kind of control.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author Kara Kytle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @see Line#getControls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @see Line#isControlSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public abstract class Control {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * The control type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private final Type type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
47195
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
    51
     * Constructs a control with the specified type.
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    52
     *
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    53
     * @param  type the kind of control desired
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected Control(Type type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Obtains the control's type.
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    61
     *
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    62
     * @return the control's type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public Type getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
47195
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
    69
     * Obtains a string describing the control type and its current state.
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    70
     *
47195
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
    71
     * @return a string representation of the control
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    73
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return new String(getType() + " Control");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    79
     * An instance of the {@code Type} class represents the type of the control.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public static class Type {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
         * Type name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
         */
40444
afabcfc2f3ef 8163949: Cleanup of classes which are related to JavaSound
serb
parents: 25859
diff changeset
    86
        private final String name;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        /**
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    89
         * Constructs a new control type with the name specified. The name
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    90
         * should be a descriptive string appropriate for labelling the control
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    91
         * in an application, such as "Gain" or "Balance".
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    92
         *
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
    93
         * @param  name the name of the new control type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        protected Type(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        /**
47195
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   100
         * Indicates whether the specified object is equal to this control type,
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   101
         * returning {@code true} if the objects are the same.
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   102
         *
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   103
         * @param  obj the reference object with which to compare
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   104
         * @return {@code true} if the specified object is equal to this control
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   105
         *         type; {@code false} otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
         */
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   107
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        public final boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            return super.equals(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        /**
47195
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   113
         * Returns a hash code value for this control type.
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   114
         *
b309b58eb190 8181566: JavaSound javadoc clarification
serb
parents: 40444
diff changeset
   115
         * @return a hash code value for this control type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
         */
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   117
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        public final int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            return super.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        /**
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   123
         * Provides the {@code String} representation of the control type. This
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   124
         * {@code String} is the same name that was passed to the constructor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
         * @return the control type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
         */
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   128
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        public final String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
25128
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   132
    }
2dfdfa369071 8043979: Javadoc cleanup of javax.sound.sampled package
serb
parents: 5506
diff changeset
   133
}