renamed back to TypeDescriptor after ConversionContext proved not good enough name for any change

This commit is contained in:
Keith Donald
2009-05-23 21:23:10 +00:00
parent b9aa82a0c4
commit b093094c50
35 changed files with 200 additions and 205 deletions

View File

@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.core.convert.ConversionContext;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
@@ -236,7 +236,7 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
private static class FruitColourAccessor implements PropertyAccessor {
private static Map<String,Color> propertyMap = new HashMap<String,Color>();
private static ConversionContext mapElementTypeDescriptor = ConversionContext.valueOf(Color.class);
private static TypeDescriptor mapElementTypeDescriptor = TypeDescriptor.valueOf(Color.class);
static {
propertyMap.put("banana",Color.yellow);
@@ -295,7 +295,7 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(propertyMap.get(name),ConversionContext.valueOf(Color.class));
return new TypedValue(propertyMap.get(name),TypeDescriptor.valueOf(Color.class));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {

View File

@@ -18,7 +18,7 @@ package org.springframework.expression.spel;
import java.util.HashMap;
import java.util.Map;
import org.springframework.core.convert.ConversionContext;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
@@ -117,7 +117,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
assertEquals(TypedValue.NULL_TYPED_VALUE,state.getRootContextObject());
((StandardEvaluationContext)state.getEvaluationContext()).setRootObject(null,ConversionContext.NULL);
((StandardEvaluationContext)state.getEvaluationContext()).setRootObject(null,TypeDescriptor.NULL);
assertEquals(null,state.getRootContextObject().getValue());
}
@@ -222,10 +222,10 @@ public class ExpressionStateTests extends ExpressionTestCase {
public void testTypeConversion() throws EvaluationException {
ExpressionState state = getState();
String s = (String)state.convertValue(34,ConversionContext.valueOf(String.class));
String s = (String)state.convertValue(34,TypeDescriptor.valueOf(String.class));
assertEquals("34",s);
s = (String)state.convertValue(new TypedValue(34),ConversionContext.valueOf(String.class));
s = (String)state.convertValue(new TypedValue(34),TypeDescriptor.valueOf(String.class));
assertEquals("34",s);
}

View File

@@ -19,7 +19,7 @@ package org.springframework.expression.spel;
import java.util.ArrayList;
import java.util.List;
import org.springframework.core.convert.ConversionContext;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultTypeConverter;
import org.springframework.core.convert.support.GenericTypeConverter;
import org.springframework.expression.EvaluationException;
@@ -35,9 +35,9 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCase {
private static List<String> listOfString = new ArrayList<String>();
private static ConversionContext typeDescriptorForListOfString = null;
private static TypeDescriptor typeDescriptorForListOfString = null;
private static List<Integer> listOfInteger = new ArrayList<Integer>();
private static ConversionContext typeDescriptorForListOfInteger = null;
private static TypeDescriptor typeDescriptorForListOfInteger = null;
static {
listOfString.add("1");
@@ -50,8 +50,8 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
public void setUp() throws Exception {
super.setUp();
typeDescriptorForListOfString = new ConversionContext(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfString"));
typeDescriptorForListOfInteger = new ConversionContext(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfInteger"));
typeDescriptorForListOfString = new TypeDescriptor(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfString"));
typeDescriptorForListOfInteger = new TypeDescriptor(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfInteger"));
}
@@ -96,20 +96,20 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
private final DefaultTypeConverter service = new DefaultTypeConverter();
public boolean canConvert(Class<?> sourceType, Class<?> targetType) {
return this.service.canConvert(sourceType, ConversionContext.valueOf(targetType));
return this.service.canConvert(sourceType, TypeDescriptor.valueOf(targetType));
}
public boolean canConvert(Class<?> sourceType, ConversionContext typeDescriptor) {
public boolean canConvert(Class<?> sourceType, TypeDescriptor typeDescriptor) {
return this.service.canConvert(sourceType, typeDescriptor);
}
@SuppressWarnings("unchecked")
public <T> T convertValue(Object value, Class<T> targetType) throws EvaluationException {
return (T) this.service.convert(value,ConversionContext.valueOf(targetType));
return (T) this.service.convert(value,TypeDescriptor.valueOf(targetType));
}
@SuppressWarnings("unchecked")
public Object convertValue(Object value, ConversionContext typeDescriptor) throws EvaluationException {
public Object convertValue(Object value, TypeDescriptor typeDescriptor) throws EvaluationException {
return this.service.convert(value, typeDescriptor);
}
}

View File

@@ -19,7 +19,7 @@ package org.springframework.expression.spel;
import java.lang.reflect.Method;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionContext;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
@@ -214,7 +214,7 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(new Principal(),ConversionContext.valueOf(Principal.class));
return new TypedValue(new Principal(),TypeDescriptor.valueOf(Principal.class));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
@@ -244,7 +244,7 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(activePerson,ConversionContext.valueOf(Person.class));
return new TypedValue(activePerson,TypeDescriptor.valueOf(Person.class));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
@@ -283,7 +283,7 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
if (m.isVarArgs()) {
args = ReflectionHelper.setupArgumentsForVarargsInvocation(m.getParameterTypes(), args);
}
return new TypedValue(m.invoke(null, args), new ConversionContext(new MethodParameter(m,-1)));
return new TypedValue(m.invoke(null, args), new TypeDescriptor(new MethodParameter(m,-1)));
}
catch (Exception ex) {
throw new AccessException("Problem invoking hasRole", ex);