1
17 package org.apache.el;
18
19 import javax.el.ELContext;
20 import javax.el.ELResolver;
21 import javax.el.ExpressionFactory;
22 import javax.el.MethodExpression;
23 import javax.el.ValueExpression;
24
25 import org.apache.el.lang.ELSupport;
26 import org.apache.el.lang.ExpressionBuilder;
27 import org.apache.el.stream.StreamELResolverImpl;
28 import org.apache.el.util.MessageFactory;
29
30
31
36 public class ExpressionFactoryImpl extends ExpressionFactory {
37
38
41 public ExpressionFactoryImpl() {
42 super();
43 }
44
45 @Override
46 public Object coerceToType(Object obj, Class<?> type) {
47 return ELSupport.coerceToType(null, obj, type);
48 }
49
50 @Override
51 public MethodExpression createMethodExpression(ELContext context,
52 String expression, Class<?> expectedReturnType,
53 Class<?>[] expectedParamTypes) {
54 ExpressionBuilder builder = new ExpressionBuilder(expression, context);
55 return builder.createMethodExpression(expectedReturnType,
56 expectedParamTypes);
57 }
58
59 @Override
60 public ValueExpression createValueExpression(ELContext context,
61 String expression, Class<?> expectedType) {
62 if (expectedType == null) {
63 throw new NullPointerException(MessageFactory
64 .get("error.value.expectedType"));
65 }
66 ExpressionBuilder builder = new ExpressionBuilder(expression, context);
67 return builder.createValueExpression(expectedType);
68 }
69
70 @Override
71 public ValueExpression createValueExpression(Object instance,
72 Class<?> expectedType) {
73 if (expectedType == null) {
74 throw new NullPointerException(MessageFactory
75 .get("error.value.expectedType"));
76 }
77 return new ValueExpressionLiteral(instance, expectedType);
78 }
79
80 @Override
81 public ELResolver getStreamELResolver() {
82 return new StreamELResolverImpl();
83 }
84 }
85