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.
DataBinder.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)
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, supportsCustomEditor
public StringTrimmerEditor(boolean emptyAsNull)
emptyAsNull
- true
if an empty String is to be
transformed into null
public 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 null
public void setAsText(String text)
setAsText
in interface PropertyEditor
setAsText
in class PropertyEditorSupport
public String getAsText()
getAsText
in interface PropertyEditor
getAsText
in class PropertyEditorSupport