001/*002 * Copyright 2002-2018 the original author or authors.003 *004 * Licensed under the Apache License, Version 2.0 (the "License");005 * you may not use this file except in compliance with the License.006 * You may obtain a copy of the License at007 *008 * https://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * distributed under the License is distributed on an "AS IS" BASIS,012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.013 * See the License for the specific language governing permissions and014 * limitations under the License.015 */016017package org.springframework.beans.propertyeditors;018019import java.beans.PropertyEditorSupport;020021import org.springframework.lang.Nullable;022import org.springframework.util.StringUtils;023024/**025 * Property editor for Boolean/boolean properties.026 *027 * <p>This is not meant to be used as system PropertyEditor but rather as028 * locale-specific Boolean editor within custom controller code, to parse029 * UI-caused boolean strings into boolean properties of beans and check030 * them in the UI form.031 *032 * <p>In web MVC code, this editor will typically be registered with033 * {@code binder.registerCustomEditor} calls.034 *035 * @author Juergen Hoeller036 * @since 10.06.2003037 * @see org.springframework.validation.DataBinder#registerCustomEditor038 */039public class CustomBooleanEditor extends PropertyEditorSupport {040041 /**042 * Value of {@code "true"}.043 */044 public static final String VALUE_TRUE = "true";045046 /**047 * Value of {@code "false"}.048 */049 public static final String VALUE_FALSE = "false";050051 /**052 * Value of {@code "on"}.053 */054 public static final String VALUE_ON = "on";055056 /**057 * Value of {@code "off"}.058 */059 public static final String VALUE_OFF = "off";060061 /**062 * Value of {@code "yes"}.063 */064 public static final String VALUE_YES = "yes";065066 /**067 * Value of {@code "no"}.068 */069 public static final String VALUE_NO = "no";070071 /**072 * Value of {@code "1"}.073 */074 public static final String VALUE_1 = "1";075076 /**077 * Value of {@code "0"}.078 */079 public static final String VALUE_0 = "0";080081082 @Nullable083 private final String trueString;084