KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jasper > el > JspMethodExpression


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 package org.apache.jasper.el;
18
19 import java.io.Externalizable JavaDoc;
20 import java.io.IOException JavaDoc;
21 import java.io.ObjectInput JavaDoc;
22 import java.io.ObjectOutput JavaDoc;
23
24 import javax.el.ELContext;
25 import javax.el.ELException;
26 import javax.el.MethodExpression;
27 import javax.el.MethodInfo;
28 import javax.el.MethodNotFoundException;
29 import javax.el.PropertyNotFoundException;
30
31 public final class JspMethodExpression extends MethodExpression implements
32         Externalizable JavaDoc {
33
34     private String JavaDoc mark;
35
36     private MethodExpression target;
37
38     public JspMethodExpression() {
39         super();
40     }
41
42     public JspMethodExpression(String JavaDoc mark, MethodExpression target) {
43         this.target = target;
44         this.mark = mark;
45     }
46
47     public MethodInfo getMethodInfo(ELContext context)
48             throws NullPointerException JavaDoc, PropertyNotFoundException,
49             MethodNotFoundException, ELException {
50         try {
51             return this.target.getMethodInfo(context);
52         } catch (MethodNotFoundException e) {
53             if (e instanceof JspMethodNotFoundException) throw e;
54             throw new JspMethodNotFoundException(this.mark, e);
55         } catch (PropertyNotFoundException e) {
56             if (e instanceof JspPropertyNotFoundException) throw e;
57             throw new JspPropertyNotFoundException(this.mark, e);
58         } catch (ELException e) {
59             if (e instanceof JspELException) throw e;
60             throw new JspELException(this.mark, e);
61         }
62     }
63
64     public Object JavaDoc invoke(ELContext context, Object JavaDoc[] params)
65             throws NullPointerException JavaDoc, PropertyNotFoundException,
66             MethodNotFoundException, ELException {
67         try {
68             return this.target.invoke(context, params);
69         } catch (MethodNotFoundException e) {
70             if (e instanceof JspMethodNotFoundException) throw e;
71             throw new JspMethodNotFoundException(this.mark, e);
72         } catch (PropertyNotFoundException e) {
73             if (e instanceof JspPropertyNotFoundException) throw e;
74             throw new JspPropertyNotFoundException(this.mark, e);
75         } catch (ELException e) {
76             if (e instanceof JspELException) throw e;
77             throw new JspELException(this.mark, e);
78         }
79     }
80
81     public boolean equals(Object JavaDoc obj) {
82         return this.target.equals(obj);
83     }
84
85     public int hashCode() {
86         return this.target.hashCode();
87     }
88
89     public String JavaDoc getExpressionString() {
90         return this.target.getExpressionString();
91     }
92
93     public boolean isLiteralText() {
94         return this.target.isLiteralText();
95     }
96
97     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
98         out.writeUTF(this.mark);
99         out.writeObject(this.target);
100     }
101
102     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,
103             ClassNotFoundException JavaDoc {
104         this.mark = in.readUTF();
105         this.target = (MethodExpression) in.readObject();
106     }
107
108 }
109
Popular Tags