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.
DataBinder.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)
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 null
public 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 null
public void setAsText(@Nullable java.lang.String text)
setAsText
in interface java.beans.PropertyEditor
setAsText
in class java.beans.PropertyEditorSupport
public java.lang.String getAsText()
getAsText
in interface java.beans.PropertyEditor
getAsText
in class java.beans.PropertyEditorSupport