KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > el > ExpressionFactoryImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  *
21  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
22  *
23  * Portions Copyright Apache Software Foundation.
24  */

25 package com.sun.el;
26
27 import javax.el.ELContext;
28 import javax.el.ExpressionFactory;
29 import javax.el.MethodExpression;
30 import javax.el.ValueExpression;
31
32 import com.sun.el.lang.ExpressionBuilder;
33 import com.sun.el.lang.ELSupport;
34 import com.sun.el.util.MessageFactory;
35
36 /**
37  * @see javax.el.ExpressionFactory
38  *
39  * @author Jacob Hookom [jacob@hookom.net]
40  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $
41  */

42 public class ExpressionFactoryImpl extends ExpressionFactory {
43
44     /**
45      *
46      */

47     public ExpressionFactoryImpl() {
48         super();
49     }
50
51     public Object JavaDoc coerceToType(Object JavaDoc obj, Class JavaDoc type) {
52         return ELSupport.coerceToType(obj, type);
53     }
54
55     public MethodExpression createMethodExpression(ELContext context,
56             String JavaDoc expression, Class JavaDoc expectedReturnType,
57             Class JavaDoc[] expectedParamTypes) {
58         if (expectedParamTypes == null) {
59             throw new NullPointerException JavaDoc(MessageFactory
60                     .get("error.method.nullParms"));
61         }
62         ExpressionBuilder builder = new ExpressionBuilder(expression, context);
63         return builder.createMethodExpression(expectedReturnType,
64                 expectedParamTypes);
65     }
66
67     public ValueExpression createValueExpression(ELContext context,
68             String JavaDoc expression, Class JavaDoc expectedType) {
69         if (expectedType == null) {
70             throw new NullPointerException JavaDoc(MessageFactory
71                     .get("error.value.expectedType"));
72         }
73         ExpressionBuilder builder = new ExpressionBuilder(expression, context);
74         return builder.createValueExpression(expectedType);
75     }
76
77     public ValueExpression createValueExpression(Object JavaDoc instance,
78             Class JavaDoc expectedType) {
79         if (expectedType == null) {
80             throw new NullPointerException JavaDoc(MessageFactory
81                     .get("error.value.expectedType"));
82         }
83         return new ValueExpressionLiteral(instance, expectedType);
84     }
85 }
86
Popular Tags