Path: blob/master/src/java.desktop/share/classes/javax/sound/sampled/Control.java
41159 views
/*1* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sound.sampled;2627/**28* {@link Line Lines} often have a set of controls, such as gain and pan, that29* affect the audio signal passing through the line. Java Sound's {@code Line}30* objects let you obtain a particular control object by passing its class as31* the argument to a {@link Line#getControl(Control.Type) getControl} method.32* <p>33* Because the various types of controls have different purposes and features,34* all of their functionality is accessed from the subclasses that define each35* kind of control.36*37* @author Kara Kytle38* @see Line#getControls39* @see Line#isControlSupported40* @since 1.341*/42public abstract class Control {4344/**45* The control type.46*/47private final Type type;4849/**50* Constructs a control with the specified type.51*52* @param type the kind of control desired53*/54protected Control(Type type) {55this.type = type;56}5758/**59* Obtains the control's type.60*61* @return the control's type62*/63public Type getType() {64return type;65}6667/**68* Returns a string representation of the control.69*70* @return a string representation of the control71*/72@Override73public String toString() {74return String.format("%s control", getType());75}7677/**78* An instance of the {@code Type} class represents the type of the control.79*/80public static class Type {8182/**83* Type name.84*/85private final String name;8687/**88* Constructs a new control type with the name specified. The name89* should be a descriptive string appropriate for labelling the control90* in an application, such as "Gain" or "Balance".91*92* @param name the name of the new control type93*/94protected Type(String name) {95this.name = name;96}9798/**99* Indicates whether the specified object is equal to this control type,100* returning {@code true} if the objects are the same.101*102* @param obj the reference object with which to compare103* @return {@code true} if the specified object is equal to this control104* type; {@code false} otherwise105*/106@Override107public final boolean equals(Object obj) {108return super.equals(obj);109}110111/**112* Returns a hash code value for this control type.113*114* @return a hash code value for this control type115*/116@Override117public final int hashCode() {118return super.hashCode();119}120121/**122* Returns type's name as the string representation of the control type.123*124* @return a string representation of the control type125*/126@Override127public final String toString() {128return name;129}130}131}132133134