KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > el > ExpressionFactoryImpl


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 /**
31  * @see javax.el.ExpressionFactory
32  *
33  * @author Jacob Hookom [jacob@hookom.net]
34  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
35  */

36 public class ExpressionFactoryImpl extends ExpressionFactory {
37
38     /**
39      *
40      */

41     public ExpressionFactoryImpl() {
42         super();
43     }
44
45     public Object JavaDoc coerceToType(Object JavaDoc obj, Class JavaDoc type) {
46         return ELSupport.coerceToType(obj, type);
47     }
48
49     public MethodExpression createMethodExpression(ELContext context,
50             String JavaDoc expression, Class JavaDoc<?> expectedReturnType,
51             Class JavaDoc<?>[] expectedParamTypes) {
52         if (expectedParamTypes == null) {
53             throw new NullPointerException JavaDoc(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 JavaDoc expression, Class JavaDoc expectedType) {
63         if (expectedType == null) {
64             throw new NullPointerException JavaDoc(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 JavaDoc instance,
72             Class JavaDoc expectedType) {
73         if (expectedType == null) {
74             throw new NullPointerException JavaDoc(MessageFactory
75                     .get("error.value.expectedType"));
76         }
77         return new ValueExpressionLiteral(instance, expectedType);
78     }
79 }
80
Popular Tags