org.springframework.beans.propertyeditors
public class: StringTrimmerEditor [javadoc |
source]
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.beans.propertyeditors.StringTrimmerEditor
All Implemented Interfaces:
PropertyEditor
Property editor that trims Strings.
Optionally allows transforming an empty string into a null value.
Needs to be explictly registered, e.g. for command binding.
Also see:
- org.springframework.validation.DataBinder#registerCustomEditor
- org.springframework.web.servlet.mvc.BaseCommandController#initBinder
- author:
Juergen - Hoeller
| Method from org.springframework.beans.propertyeditors.StringTrimmerEditor Summary: |
|---|
|
getAsText, setAsText |
| Methods from java.beans.PropertyEditorSupport: |
|---|
|
addPropertyChangeListener, firePropertyChange, getAsText, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setAsText, setSource, setValue, supportsCustomEditor |
| Method from org.springframework.beans.propertyeditors.StringTrimmerEditor Detail: |
public String getAsText() {
Object value = getValue();
return (value != null ? value.toString() : "");
}
|
public void setAsText(String text) {
if (text == null) {
setValue(null);
}
else {
String value = text.trim();
if (this.charsToDelete != null) {
value = StringUtils.deleteAny(value, this.charsToDelete);
}
if (this.emptyAsNull && "".equals(value)) {
setValue(null);
}
else {
setValue(value);
}
}
}
|