generic converter updates

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1933 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Keith Donald
2009-09-18 20:08:45 +00:00
parent fad7b691bf
commit 4342f50946
2 changed files with 8 additions and 12 deletions
@@ -55,8 +55,8 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
}
@Override
protected GenericConverter getConverter(Class sourceType, TypeDescriptor targetType) {
if (String.class.equals(sourceType)) {
protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (String.class.equals(sourceType.getType())) {
Formatter formatter = this.formatterRegistry.getFormatter(targetType);
if (formatter != null) {
return new FormattingConverter(formatter);
@@ -76,13 +76,18 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
this.formatter = formatter;
}
public Object convert(Object source, TypeDescriptor targetType) {
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
throw new UnsupportedOperationException("Should not be called");
}
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
try {
return this.formatter.parse((String) source, LocaleContextHolder.getLocale());
} catch (ParseException ex) {
throw new IllegalArgumentException("Could not convert formatted value '" + source + "'", ex);
}
}
}
}
@@ -1,9 +0,0 @@
package org.springframework.core.convert.support;
import org.springframework.core.convert.TypeDescriptor;
public interface MatchableGenericConverter extends GenericConverter {
boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType);
}