public class StringTrimmerEditor extends 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(String charsToDelete,
boolean emptyAsNull)
Create a new StringTrimmerEditor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAsText() |
void |
setAsText(String text) |
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditorpublic StringTrimmerEditor(boolean emptyAsNull)
emptyAsNull - true if an empty String is to be
transformed into nullpublic StringTrimmerEditor(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(String text)
setAsText in interface PropertyEditorsetAsText in class PropertyEditorSupportpublic String getAsText()
getAsText in interface PropertyEditorgetAsText in class PropertyEditorSupport