IN PROGRESS - issue SWF-720: Multiple checkboxes to Collection mapping
http://jira.springframework.org/browse/SWF-720
This commit is contained in:
@@ -40,11 +40,10 @@ public interface ConversionService {
|
||||
throws ConversionExecutorNotFoundException;
|
||||
|
||||
/**
|
||||
* Lookup a class by its fully qualified name or alias. As an example, for Long.class the fully qualified class name
|
||||
* is <code>java.lang.Long</code> and the alias is <code>long</code>.
|
||||
* @param name the fully qualified class name or alias
|
||||
* @return the class
|
||||
* Lookup a class by it alias. For example, <code>long</code> for <code>java.lang.Long</code>
|
||||
* @param alias the class alias
|
||||
* @return the class, or <code>null</code> if no alias exists
|
||||
*/
|
||||
public Class getClassByName(String name);
|
||||
public Class getClassForAlias(String alias);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.springframework.binding.convert.converters;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
|
||||
public class PropertyEditorConverter extends StringToObject {
|
||||
|
||||
private PropertyEditor propertyEditor;
|
||||
|
||||
public PropertyEditorConverter(PropertyEditor propertyEditor, Class targetClass) {
|
||||
super(targetClass);
|
||||
this.propertyEditor = propertyEditor;
|
||||
}
|
||||
|
||||
protected Object toObject(String string, Class targetClass) throws Exception {
|
||||
synchronized (propertyEditor) {
|
||||
propertyEditor.setAsText(string);
|
||||
return propertyEditor.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
protected String toString(Object object) throws Exception {
|
||||
synchronized (propertyEditor) {
|
||||
propertyEditor.setValue(object);
|
||||
return propertyEditor.getAsText();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import org.springframework.binding.convert.converters.ObjectToArray;
|
||||
import org.springframework.binding.convert.converters.ReverseConverter;
|
||||
import org.springframework.binding.convert.converters.TwoWayConverter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Base implementation of a conversion service. Initially empty, e.g. no converters are registered by default.
|
||||
@@ -160,22 +159,15 @@ public class GenericConversionService implements ConversionService {
|
||||
}
|
||||
}
|
||||
|
||||
public Class getClassByName(String name) throws IllegalArgumentException {
|
||||
public Class getClassForAlias(String name) throws IllegalArgumentException {
|
||||
Class clazz = (Class) aliasMap.get(name);
|
||||
if (clazz != null) {
|
||||
return clazz;
|
||||
} else {
|
||||
if (parent != null) {
|
||||
return parent.getClassByName(name);
|
||||
return parent.getClassForAlias(name);
|
||||
} else {
|
||||
try {
|
||||
return ClassUtils.forName(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
IllegalArgumentException iae = new IllegalArgumentException(
|
||||
"No Class alias or instance found with name '" + name + "' in this ConversionService");
|
||||
iae.initCause(e);
|
||||
throw iae;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user