Browse Source

polish

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1934 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Keith Donald 17 years ago
parent
commit
b0a5462cb3
  1. 6
      org.springframework.core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java
  2. 18
      org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java

6
org.springframework.core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java

@ -31,6 +31,12 @@ public class DefaultConversionService extends GenericConversionService { @@ -31,6 +31,12 @@ public class DefaultConversionService extends GenericConversionService {
* Create a new default conversion service, installing the default converters.
*/
public DefaultConversionService() {
initDefaultConverters();
}
// subclassing hooks
protected void initDefaultConverters() {
addConverter(new StringToBooleanConverter());
addConverter(new StringToCharacterConverter());
addConverter(new StringToLocaleConverter());

18
org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java

@ -58,9 +58,7 @@ public class GenericConversionService implements ConversionService, ConverterReg @@ -58,9 +58,7 @@ public class GenericConversionService implements ConversionService, ConverterReg
private final Set<GenericConverter> matchableConverters = new LinkedHashSet<GenericConverter>();
public GenericConversionService() {
addGenericConverter(new CollectionGenericConverter(this));
addGenericConverter(new MapGenericConverter(this));
addGenericConverter(new ArrayGenericConverter(this));
initGenericConverters();
}
/**
@ -183,6 +181,16 @@ public class GenericConversionService implements ConversionService, ConverterReg @@ -183,6 +181,16 @@ public class GenericConversionService implements ConversionService, ConverterReg
// subclassing hooks
protected void initGenericConverters() {
addGenericConverter(new CollectionGenericConverter(this));
addGenericConverter(new MapGenericConverter(this));
addGenericConverter(new ArrayGenericConverter(this));
}
protected void addGenericConverter(GenericConverter converter) {
this.matchableConverters.add(converter);
}
protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
GenericConverter converter = matchConverterByClassPair(sourceType.getObjectType(), targetType.getObjectType());
if (converter == null) {
@ -197,10 +205,6 @@ public class GenericConversionService implements ConversionService, ConverterReg @@ -197,10 +205,6 @@ public class GenericConversionService implements ConversionService, ConverterReg
// internal helpers
private void addGenericConverter(GenericConverter converter) {
this.matchableConverters.add(converter);
}
private List<Class> getRequiredTypeInfo(Object converter) {
List<Class> typeInfo = new ArrayList<Class>(2);
if (converter instanceof ConverterInfo) {

Loading…
Cancel
Save