01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
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: * @see javax.el.ExpressionFactory
31: *
32: * @author Jacob Hookom [jacob@hookom.net]
33: * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
34: */
35: public class ExpressionFactoryImpl extends ExpressionFactory {
36:
37: /**
38: *
39: */
40: public ExpressionFactoryImpl() {
41: super ();
42: }
43:
44: public Object coerceToType(Object obj, Class type) {
45: return ELSupport.coerceToType(obj, type);
46: }
47:
48: public MethodExpression createMethodExpression(ELContext context,
49: String expression, Class<?> expectedReturnType,
50: Class<?>[] expectedParamTypes) {
51: if (expectedParamTypes == null) {
52: throw new NullPointerException(MessageFactory
53: .get("error.method.nullParms"));
54: }
55: ExpressionBuilder builder = new ExpressionBuilder(expression,
56: 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,
68: context);
69: return builder.createValueExpression(expectedType);
70: }
71:
72: public ValueExpression createValueExpression(Object instance,
73: Class expectedType) {
74: if (expectedType == null) {
75: throw new NullPointerException(MessageFactory
76: .get("error.value.expectedType"));
77: }
78: return new ValueExpressionLiteral(instance, expectedType);
79: }
80: }
|