spring:eval tag initial commit

This commit is contained in:
Keith Donald
2010-02-11 22:53:49 +00:00
parent 16aa399040
commit f23b55dc13
8 changed files with 309 additions and 12 deletions

View File

@@ -439,16 +439,17 @@ public class TypeDescriptor {
public String toString() {
if (this == TypeDescriptor.NULL) {
return "TypeDescriptor.NULL";
return "[TypeDescriptor.NULL]";
}
else {
StringBuilder builder = new StringBuilder();
builder.append("TypeDescriptor ");
builder.append("[TypeDescriptor ");
Annotation[] anns = getAnnotations();
for (Annotation ann : anns) {
builder.append("@").append(ann.annotationType().getName()).append(' ');
}
builder.append(ClassUtils.getQualifiedName(getType()));
builder.append("]");
return builder.toString();
}
}

View File

@@ -28,7 +28,6 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConversionService;
@@ -39,6 +38,7 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.core.convert.converter.ConverterRegistry;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.core.style.StylerUtils;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -121,9 +121,12 @@ public class GenericConversionService implements ConversionService, ConverterReg
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
assertNotNull(sourceType, targetType);
if (logger.isDebugEnabled()) {
logger.debug("Converting value " + StylerUtils.style(source) +" of " + sourceType + " to " + targetType);
}
if (sourceType == TypeDescriptor.NULL) {
Assert.isTrue(source == null, "The source must be null if sourceType == TypeDescriptor.NULL");
return convertNullSource(sourceType, targetType);
return convertNullSource(sourceType, targetType);
}
if (targetType == TypeDescriptor.NULL) {
return null;