IN PROGRESS - issue SWF-720: Multiple checkboxes to Collection mapping

http://jira.springframework.org/browse/SWF-720
This commit is contained in:
Keith Donald
2008-06-30 23:05:40 +00:00
parent c706bf4e5f
commit 2962d438be
10 changed files with 42 additions and 24 deletions

View File

@@ -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);
}

View File

@@ -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();
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -76,7 +76,7 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
throw new UnsupportedOperationException("Auto-generated method stub");
}
public Class getClassByName(String name) throws ConversionExecutionException {
public Class getClassForAlias(String name) throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}

View File

@@ -44,7 +44,6 @@ public class DojoDecorationRendererTests extends TestCase {
UIInput childComponent = new UIInput();
childComponent.setValue(new TestValue());
DojoDecorationRenderer renderer = new DojoDecorationRenderer();
try {
renderer.getValueAsString(jsf.facesContext(), childComponent);
fail("getValueAsString should throw exception if no converter is found");

View File

@@ -219,6 +219,6 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, I
}
private Class fromStringToClass(String name) {
return conversionService.getClassByName(name);
return conversionService.getClassForAlias(name);
}
}

View File

@@ -237,7 +237,7 @@ class FlowRegistryFactoryBean implements FactoryBean, InitializingBean {
}
private Class fromStringToClass(String type) {
return flowBuilderServices.getConversionService().getClassByName(type);
return flowBuilderServices.getConversionService().getClassForAlias(type);
}
private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) {

View File

@@ -910,7 +910,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
}
private Class toClass(String name) {
return getLocalContext().getConversionService().getClassByName(name);
return getLocalContext().getConversionService().getClassForAlias(name);
}
private static class FlowRelativeResourceLoader implements ResourceLoader {

View File

@@ -124,8 +124,8 @@ public class FlowBuilderContextImpl implements FlowBuilderContext {
return getFlowBuilderServices().getConversionService().getConversionExecutor(sourceClass, targetClass);
}
public Class getClassByName(String name) {
return getFlowBuilderServices().getConversionService().getClassByName(name);
public Class getClassForAlias(String name) {
return getFlowBuilderServices().getConversionService().getClassForAlias(name);
}
}

View File

@@ -59,7 +59,7 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public Class getClassByName(String alias) throws ConversionExecutionException {
public Class getClassForAlias(String alias) throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}