org.springframework.beans.propertyeditors
public class: CharacterEditor [javadoc |
source]
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.beans.propertyeditors.CharacterEditor
All Implemented Interfaces:
PropertyEditor
Editor for a
java.lang.Character , to populate a property
of type
Character or
char from a String value.
Note that the JDK does not contain a default
property editor for char!
org.springframework.beans.BeanWrapperImpl will register this
editor by default.
Also supports conversion from a Unicode character sequence; e.g.
u0041 ('A').
| Method from org.springframework.beans.propertyeditors.CharacterEditor 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.CharacterEditor Detail: |
public String getAsText() {
Object value = getValue();
return (value != null ? value.toString() : "");
}
|
public void setAsText(String text) throws IllegalArgumentException {
if (this.allowEmpty && !StringUtils.hasLength(text)) {
// Treat empty String as null value.
setValue(null);
}
else if (text == null) {
throw new IllegalArgumentException("null String cannot be converted to char type");
}
else if (isUnicodeCharacterSequence(text)) {
setAsUnicode(text);
}
else if (text.length() != 1) {
throw new IllegalArgumentException("String [" + text + "] with length " +
text.length() + " cannot be converted to char type");
}
else {
setValue(new Character(text.charAt(0)));
}
}
|