TypeDescriptor.valueOf usage in favor of constants; TypedValue usage simplification

This commit is contained in:
Keith Donald
2009-12-15 19:41:52 +00:00
parent f37d7082a2
commit 2fef141a00
31 changed files with 120 additions and 138 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.context.expression;
import java.util.Map;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.PropertyAccessor;
@@ -39,7 +38,7 @@ public class MapAccessor implements PropertyAccessor {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((Map) target).get(name), TypeDescriptor.OBJECT);
return new TypedValue(((Map) target).get(name));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
@@ -52,7 +51,7 @@ public class MapAccessor implements PropertyAccessor {
}
public Class[] getSpecificTargetClasses() {
return new Class[] {Map.class};
return new Class[] { Map.class };
}
}

View File

@@ -115,10 +115,11 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
}
}
if (this.conversionService != null) {
// Try custom formatter...
// Try custom converter...
TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField);
if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, TypeDescriptor.STRING)) {
return this.conversionService.convert(value, fieldDesc, TypeDescriptor.STRING);
TypeDescriptor strDesc = TypeDescriptor.valueOf(String.class);
if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, strDesc)) {
return this.conversionService.convert(value, fieldDesc, strDesc);
}
}
return value;
@@ -152,7 +153,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
TypeDescriptor td = (field != null ?
getPropertyAccessor().getPropertyTypeDescriptor(fixedField(field)) :
TypeDescriptor.valueOf(valueType));
if (this.conversionService.canConvert(TypeDescriptor.STRING, td)) {
if (this.conversionService.canConvert(TypeDescriptor.valueOf(String.class), td)) {
editor = new ConvertingPropertyEditorAdapter(this.conversionService, td);
}
}