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

Print this page


   1 /*
   2  * Copyright (c) 1999, 2003, 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


 108      * by setting a value.
 109      * @param value desired new value.
 110      */
 111     public void setValue(boolean value) {
 112         this.value = value;
 113     }
 114 
 115 
 116 
 117     /**
 118      * Obtains this control's current value.
 119      * @return current value.
 120      */
 121     public boolean getValue() {
 122         return value;
 123     }
 124 
 125 
 126     /**
 127      * Obtains the label for the specified state.

 128      * @return the label for the specified state, such as "true" or "on"
 129      * for <code>true</code>, or "false" or "off" for <code>false</code>.
 130      */
 131     public String getStateLabel(boolean state) {
 132         return ((state == true) ? trueStateLabel : falseStateLabel);
 133     }
 134 
 135 
 136 
 137     // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
 138 
 139 
 140     /**
 141      * Provides a string representation of the control
 142      * @return a string description
 143      */
 144     public String toString() {
 145         return new String(super.toString() + " with current value: " + getStateLabel(getValue()));
 146     }
 147 


   1 /*
   2  * Copyright (c) 1999, 2013, 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


 108      * by setting a value.
 109      * @param value desired new value.
 110      */
 111     public void setValue(boolean value) {
 112         this.value = value;
 113     }
 114 
 115 
 116 
 117     /**
 118      * Obtains this control's current value.
 119      * @return current value.
 120      */
 121     public boolean getValue() {
 122         return value;
 123     }
 124 
 125 
 126     /**
 127      * Obtains the label for the specified state.
 128      * @param state the state whose label will be returned
 129      * @return the label for the specified state, such as "true" or "on"
 130      * for <code>true</code>, or "false" or "off" for <code>false</code>.
 131      */
 132     public String getStateLabel(boolean state) {
 133         return ((state == true) ? trueStateLabel : falseStateLabel);
 134     }
 135 
 136 
 137 
 138     // ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
 139 
 140 
 141     /**
 142      * Provides a string representation of the control
 143      * @return a string description
 144      */
 145     public String toString() {
 146         return new String(super.toString() + " with current value: " + getStateLabel(getValue()));
 147     }
 148