类 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
- 另请参阅:
DataBinder.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)
构造器概要
构造器 构造器 说明 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.
字段详细资料
VALUE_TRUE
public static final String VALUE_TRUE
- 另请参阅:
- 常量字段值
VALUE_FALSE
public static final String VALUE_FALSE
- 另请参阅:
- 常量字段值
构造器详细资料
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(String trueString, 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 valuefalseString
- the String value that represents false: for example, "false" (VALUE_FALSE), "off" (VALUE_OFF), "no" (VALUE_NO) or some custom valueallowEmpty
- if empty strings should be allowed- 另请参阅:
VALUE_TRUE
,VALUE_FALSE
,VALUE_ON
,VALUE_OFF
,VALUE_YES
,VALUE_NO
方法详细资料
setAsText
public void setAsText(String text) throws IllegalArgumentException
- 指定者:
setAsText
在接口中PropertyEditor
- 覆盖:
setAsText
在类中PropertyEditorSupport
- 抛出:
IllegalArgumentException
getAsText
public String getAsText()
- 指定者:
getAsText
在接口中PropertyEditor
- 覆盖:
getAsText
在类中PropertyEditorSupport