KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > el > TagMethodExpression


1 /**
2  * Licensed under the Common Development and Distribution License,
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.sun.com/cddl/
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11  * implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */

14
15 package com.sun.facelets.el;
16
17 import java.io.Externalizable JavaDoc;
18 import java.io.IOException JavaDoc;
19 import java.io.ObjectInput JavaDoc;
20 import java.io.ObjectOutput JavaDoc;
21
22 import javax.el.ELContext;
23 import javax.el.ELException;
24 import javax.el.MethodExpression;
25 import javax.el.MethodInfo;
26 import javax.el.MethodNotFoundException;
27 import javax.el.PropertyNotFoundException;
28
29 import com.sun.facelets.tag.TagAttribute;
30
31 /**
32  *
33  *
34  * @author Jacob Hookom
35  * @version $Id: TagMethodExpression.java,v 1.6 2005/08/24 04:38:57 jhook Exp $
36  */

37 public final class TagMethodExpression extends MethodExpression implements
38         Externalizable JavaDoc {
39     
40     private static final long serialVersionUID = 1L;
41     
42     private String JavaDoc attr;
43     private MethodExpression orig;
44
45     public TagMethodExpression() {
46         super();
47     }
48     
49     public TagMethodExpression(TagAttribute attr, MethodExpression orig) {
50         this.attr = attr.toString();
51         this.orig = orig;
52     }
53
54     public MethodInfo getMethodInfo(ELContext context) {
55         try {
56             return this.orig.getMethodInfo(context);
57         } catch (PropertyNotFoundException pnfe) {
58             throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
59         } catch (MethodNotFoundException mnfe) {
60             throw new MethodNotFoundException(this.attr + ": " + mnfe.getMessage(), mnfe.getCause());
61         } catch (ELException e) {
62             throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
63         }
64     }
65
66     public Object JavaDoc invoke(ELContext context, Object JavaDoc[] params) {
67         try {
68             return this.orig.invoke(context, params);
69         } catch (PropertyNotFoundException pnfe) {
70             throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
71         } catch (MethodNotFoundException mnfe) {
72             throw new MethodNotFoundException(this.attr + ": " + mnfe.getMessage(), mnfe.getCause());
73         } catch (ELException e) {
74             throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
75         }
76     }
77
78     public String JavaDoc getExpressionString() {
79         return this.orig.getExpressionString();
80     }
81
82     public boolean equals(Object JavaDoc obj) {
83         return this.orig.equals(obj);
84     }
85
86     public int hashCode() {
87         return this.orig.hashCode();
88     }
89
90     public boolean isLiteralText() {
91         return this.orig.isLiteralText();
92     }
93
94     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
95         out.writeObject(this.orig);
96         out.writeUTF(this.attr);
97     }
98
99     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,
100             ClassNotFoundException JavaDoc {
101         this.orig = (MethodExpression) in.readObject();
102         this.attr = in.readUTF();
103     }
104
105     public String JavaDoc toString() {
106         return this.attr + ": " + this.orig;
107     }
108 }
109
Popular Tags