< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java

Print this page
rev 57600 : 8236980: toString() cleanup in JavaSound
Reviewed-by: XXX
   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 102      * Obtains this control's current value.
 103      *
 104      * @return current value
 105      */
 106     public boolean getValue() {
 107         return value;
 108     }
 109 
 110     /**
 111      * Obtains the label for the specified state.
 112      *
 113      * @param  state the state whose label will be returned
 114      * @return the label for the specified state, such as "true" or "on" for
 115      *         {@code true}, or "false" or "off" for {@code false}
 116      */
 117     public String getStateLabel(boolean state) {
 118         return ((state == true) ? trueStateLabel : falseStateLabel);
 119     }
 120 
 121     /**
 122      * Provides a string representation of the control.
 123      *
 124      * @return a string representation of the control
 125      */
 126     @Override
 127     public String toString() {
 128         return new String(super.toString() + " with current value: " + getStateLabel(getValue()));

 129     }
 130 
 131     /**
 132      * An instance of the {@code BooleanControl.Type} class identifies one kind
 133      * of boolean control. Static instances are provided for the common types.
 134      *
 135      * @author Kara Kytle
 136      * @since 1.3
 137      */
 138     public static class Type extends Control.Type {
 139 
 140         /**
 141          * Represents a control for the mute status of a line. Note that mute
 142          * status does not affect gain.
 143          */
 144         public static final Type MUTE = new Type("Mute");
 145 
 146         /**
 147          * Represents a control for whether reverberation is applied to a line.
 148          * Note that the status of this control not affect the reverberation
   1 /*
   2  * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 102      * Obtains this control's current value.
 103      *
 104      * @return current value
 105      */
 106     public boolean getValue() {
 107         return value;
 108     }
 109 
 110     /**
 111      * Obtains the label for the specified state.
 112      *
 113      * @param  state the state whose label will be returned
 114      * @return the label for the specified state, such as "true" or "on" for
 115      *         {@code true}, or "false" or "off" for {@code false}
 116      */
 117     public String getStateLabel(boolean state) {
 118         return ((state == true) ? trueStateLabel : falseStateLabel);
 119     }
 120 
 121     /**
 122      * Returns a string representation of the boolean control.
 123      *
 124      * @return a string representation of the boolean control
 125      */
 126     @Override
 127     public String toString() {
 128         return String.format("%s with current value: %s", super.toString(),
 129                              getStateLabel(getValue()));
 130     }
 131 
 132     /**
 133      * An instance of the {@code BooleanControl.Type} class identifies one kind
 134      * of boolean control. Static instances are provided for the common types.
 135      *
 136      * @author Kara Kytle
 137      * @since 1.3
 138      */
 139     public static class Type extends Control.Type {
 140 
 141         /**
 142          * Represents a control for the mute status of a line. Note that mute
 143          * status does not affect gain.
 144          */
 145         public static final Type MUTE = new Type("Mute");
 146 
 147         /**
 148          * Represents a control for whether reverberation is applied to a line.
 149          * Note that the status of this control not affect the reverberation
< prev index next >