objects flowing around in expression evaluation are now TypedValue's - these carry generics info, used for conversions.

This commit is contained in:
Andy Clement
2009-04-03 23:39:14 +00:00
parent f6c1144e8d
commit 4c5854d017
66 changed files with 749 additions and 382 deletions

View File

@@ -17,15 +17,18 @@
package org.springframework.context.expression;
import org.springframework.beans.factory.config.BeanExpressionContext;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
/**
* EL property accessor that knows how to traverse the beans and contextual objects
* of a Spring {@link org.springframework.beans.factory.config.BeanExpressionContext}.
*
* @author Juergen Hoeller
* @author Andy Clement
* @since 3.0
*/
public class BeanExpressionContextAccessor implements PropertyAccessor {
@@ -34,8 +37,8 @@ public class BeanExpressionContextAccessor implements PropertyAccessor {
return (((BeanExpressionContext) target).containsObject(name));
}
public Object read(EvaluationContext context, Object target, String name) throws AccessException {
return ((BeanExpressionContext) target).getObject(name);
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((BeanExpressionContext) target).getObject(name));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {

View File

@@ -17,15 +17,18 @@
package org.springframework.context.expression;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
/**
* EL property accessor that knows how to traverse the beans of a
* Spring {@link org.springframework.beans.factory.BeanFactory}.
*
* @author Juergen Hoeller
* @author Andy Clement
* @since 3.0
*/
public class BeanFactoryAccessor implements PropertyAccessor {
@@ -34,8 +37,8 @@ public class BeanFactoryAccessor implements PropertyAccessor {
return (((BeanFactory) target).containsBean(name));
}
public Object read(EvaluationContext context, Object target, String name) throws AccessException {
return ((BeanFactory) target).getBean(name);
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((BeanFactory) target).getBean(name));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {

View File

@@ -21,12 +21,15 @@ import java.util.Map;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ast.CommonTypeDescriptors;
/**
* EL property accessor that knows how to traverse the keys
* of a standard {@link java.util.Map}.
*
* @author Juergen Hoeller
* @author Andy Clement
* @since 3.0
*/
public class MapAccessor implements PropertyAccessor {
@@ -35,8 +38,8 @@ public class MapAccessor implements PropertyAccessor {
return (((Map) target).containsKey(name));
}
public Object read(EvaluationContext context, Object target, String name) throws AccessException {
return ((Map) target).get(name);
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(((Map) target).get(name),CommonTypeDescriptors.OBJECT_TYPE_DESCRIPTOR);
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {