1 17 18 package org.apache.el; 19 20 import javax.el.ELContext; 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.util.MessageFactory; 28 29 30 36 public class ExpressionFactoryImpl extends ExpressionFactory { 37 38 41 public ExpressionFactoryImpl() { 42 super(); 43 } 44 45 public Object coerceToType(Object obj, Class type) { 46 return ELSupport.coerceToType(obj, type); 47 } 48 49 public MethodExpression createMethodExpression(ELContext context, 50 String expression, Class <?> expectedReturnType, 51 Class <?>[] expectedParamTypes) { 52 if (expectedParamTypes == null) { 53 throw new NullPointerException (MessageFactory 54 .get("error.method.nullParms")); 55 } 56 ExpressionBuilder builder = new ExpressionBuilder(expression, context); 57 return builder.createMethodExpression(expectedReturnType, 58 expectedParamTypes); 59 } 60 61 public ValueExpression createValueExpression(ELContext context, 62 String expression, Class expectedType) { 63 if (expectedType == null) { 64 throw new NullPointerException (MessageFactory 65 .get("error.value.expectedType")); 66 } 67 ExpressionBuilder builder = new ExpressionBuilder(expression, context); 68 return builder.createValueExpression(expectedType); 69 } 70 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 | Popular Tags |