org.springframework.beans.propertyeditors
public class: ClassEditor [javadoc |
source]
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.beans.propertyeditors.ClassEditor
All Implemented Interfaces:
PropertyEditor
Property editor for
java.lang.Class , to enable the direct
population of a
Class property without recourse to having to use a
String class name property as bridge.
Also supports "java.lang.String[]"-style array class names, in contrast to the
standard Class#forName(String) method.
Also see:
- java.lang.Class#forName
- org.springframework.util.ClassUtils#forName(String, ClassLoader)
- author:
Juergen - Hoeller
- author:
Rick - Evans
- since:
13.05.2003 -
| Constructor: |
public ClassEditor() {
this(null);
}
Create a default ClassEditor, using the thread context ClassLoader. |
public ClassEditor(ClassLoader classLoader) {
this.classLoader =
(classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
}
Create a default ClassEditor, using the given ClassLoader. Parameters:
classLoader - the ClassLoader to use
(or null for the thread context ClassLoader)
|
| Method from org.springframework.beans.propertyeditors.ClassEditor 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.ClassEditor Detail: |
public String getAsText() {
Class clazz = (Class) getValue();
if (clazz != null) {
return ClassUtils.getQualifiedName(clazz);
}
else {
return "";
}
}
|
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
setValue(ClassUtils.resolveClassName(text.trim(), this.classLoader));
}
else {
setValue(null);
}
}
|