org.springframework.beans.propertyeditors

## 类 CustomBooleanEditor

- java.lang.Object
- - java.beans.PropertyEditorSupport
  - - org.springframework.beans.propertyeditors.CustomBooleanEditor

- 所有已实现的接口:
    PropertyEditor

      public class CustomBooleanEditor
      extends PropertyEditorSupport

  Property editor for Boolean/boolean properties.

  This is not meant to be used as system PropertyEditor but rather as locale-specific Boolean editor within custom controller code, to parse UI-caused boolean strings into boolean properties of beans and check them in the UI form.

  In web MVC code, this editor will typically be registered with `binder.registerCustomEditor` calls.

  从以下版本开始:
    10.06.2003
  作者:
    Juergen Hoeller
  另请参阅:
    `org.springframework.validation.DataBinder#registerCustomEditor`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `VALUE_0`
    `static String` | `VALUE_1`
    `static String` | `VALUE_FALSE`
    `static String` | `VALUE_NO`
    `static String` | `VALUE_OFF`
    `static String` | `VALUE_ON`
    `static String` | `VALUE_TRUE`
    `static String` | `VALUE_YES`

  - ### 构造器概要

    构造器
    构造器和说明
    `CustomBooleanEditor(boolean allowEmpty)` Create a new CustomBooleanEditor instance, with "true"/"on"/"yes" and "false"/"off"/"no" as recognized String values.
    `CustomBooleanEditor(String trueString, String falseString, boolean allowEmpty)` Create a new CustomBooleanEditor instance, with configurable String values for true and false.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `String` | `getAsText()`
    `void` | `setAsText(String text)`

    - ### 从类继承的方法 java.beans.PropertyEditorSupport

      `addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### VALUE_TRUE

          public static final String VALUE_TRUE

      另请参阅:
        常量字段值

    - #### VALUE_FALSE

          public static final String VALUE_FALSE

      另请参阅:
        常量字段值

    - #### VALUE_ON

          public static final String VALUE_ON

      另请参阅:
        常量字段值

    - #### VALUE_OFF

          public static final String VALUE_OFF

      另请参阅:
        常量字段值

    - #### VALUE_YES

          public static final String VALUE_YES

      另请参阅:
        常量字段值

    - #### VALUE_NO

          public static final String VALUE_NO

      另请参阅:
        常量字段值

    - #### VALUE_1

          public static final String VALUE_1

      另请参阅:
        常量字段值

    - #### VALUE_0

          public static final String VALUE_0

      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### CustomBooleanEditor

          public CustomBooleanEditor(boolean allowEmpty)

      Create a new CustomBooleanEditor instance, with "true"/"on"/"yes" and "false"/"off"/"no" as recognized String values.

      The "allowEmpty" parameter states if an empty String should be allowed for parsing, i.e. get interpreted as null value. Else, an IllegalArgumentException gets thrown in that case.

      参数:
        `allowEmpty` - if empty strings should be allowed

    - #### CustomBooleanEditor

          public CustomBooleanEditor(@Nullable
                                     String trueString,
                                     @Nullable
                                     String falseString,
                                     boolean allowEmpty)

      Create a new CustomBooleanEditor instance, with configurable String values for true and false.

      The "allowEmpty" parameter states if an empty String should be allowed for parsing, i.e. get interpreted as null value. Else, an IllegalArgumentException gets thrown in that case.

      参数:
        `trueString` - the String value that represents true: for example, "true" (VALUE_TRUE), "on" (VALUE_ON), "yes" (VALUE_YES) or some custom value
        `falseString` - the String value that represents false: for example, "false" (VALUE_FALSE), "off" (VALUE_OFF), "no" (VALUE_NO) or some custom value
        `allowEmpty` - if empty strings should be allowed
      另请参阅:
        `VALUE_TRUE`, `VALUE_FALSE`, `VALUE_ON`, `VALUE_OFF`, `VALUE_YES`, `VALUE_NO`

  - ### 方法详细资料

    - #### setAsText

          public void setAsText(@Nullable
                                String text)
                         throws IllegalArgumentException

      指定者:
        `setAsText` 在接口中 `PropertyEditor`
      覆盖:
        `setAsText` 在类中 `PropertyEditorSupport`
      抛出:
        `IllegalArgumentException`

    - #### getAsText

          public String getAsText()

      指定者:
        `getAsText` 在接口中 `PropertyEditor`
      覆盖:
        `getAsText` 在类中 `PropertyEditorSupport`