public class StringTrimmerEditor
extends java.beans.PropertyEditorSupport
Optionally allows transforming an empty string into a null value.
Needs to be explicitly registered, e.g. for command binding.
org.springframework.validation.DataBinder#registerCustomEditor| Constructor and Description |
|---|
StringTrimmerEditor(boolean emptyAsNull)
Create a new StringTrimmerEditor.
|
StringTrimmerEditor(java.lang.String charsToDelete,
boolean emptyAsNull)
Create a new StringTrimmerEditor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAsText() |
void |
setAsText(java.lang.String text) |
public StringTrimmerEditor(boolean emptyAsNull)
emptyAsNull - true if an empty String is to be
transformed into nullpublic StringTrimmerEditor(java.lang.String charsToDelete,
boolean emptyAsNull)
charsToDelete - a set of characters to delete, in addition to
trimming an input String. Useful for deleting unwanted line breaks:
e.g. "\r\n\f" will delete all new lines and line feeds in a String.emptyAsNull - true if an empty String is to be
transformed into nullpublic void setAsText(java.lang.String text)
setAsText in interface java.beans.PropertyEditorsetAsText in class java.beans.PropertyEditorSupportpublic java.lang.String getAsText()
getAsText in interface java.beans.PropertyEditorgetAsText in class java.beans.PropertyEditorSupport