001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jasper.el;
018:
019: import java.io.Externalizable;
020: import java.io.IOException;
021: import java.io.ObjectInput;
022: import java.io.ObjectOutput;
023:
024: import javax.el.ELContext;
025: import javax.el.ELException;
026: import javax.el.MethodExpression;
027: import javax.el.MethodInfo;
028: import javax.el.MethodNotFoundException;
029: import javax.el.PropertyNotFoundException;
030:
031: public final class JspMethodExpression extends MethodExpression
032: implements Externalizable {
033:
034: private String mark;
035:
036: private MethodExpression target;
037:
038: public JspMethodExpression() {
039: super ();
040: }
041:
042: public JspMethodExpression(String mark, MethodExpression target) {
043: this .target = target;
044: this .mark = mark;
045: }
046:
047: public MethodInfo getMethodInfo(ELContext context)
048: throws NullPointerException, PropertyNotFoundException,
049: MethodNotFoundException, ELException {
050: try {
051: return this .target.getMethodInfo(context);
052: } catch (MethodNotFoundException e) {
053: if (e instanceof JspMethodNotFoundException)
054: throw e;
055: throw new JspMethodNotFoundException(this .mark, e);
056: } catch (PropertyNotFoundException e) {
057: if (e instanceof JspPropertyNotFoundException)
058: throw e;
059: throw new JspPropertyNotFoundException(this .mark, e);
060: } catch (ELException e) {
061: if (e instanceof JspELException)
062: throw e;
063: throw new JspELException(this .mark, e);
064: }
065: }
066:
067: public Object invoke(ELContext context, Object[] params)
068: throws NullPointerException, PropertyNotFoundException,
069: MethodNotFoundException, ELException {
070: try {
071: return this .target.invoke(context, params);
072: } catch (MethodNotFoundException e) {
073: if (e instanceof JspMethodNotFoundException)
074: throw e;
075: throw new JspMethodNotFoundException(this .mark, e);
076: } catch (PropertyNotFoundException e) {
077: if (e instanceof JspPropertyNotFoundException)
078: throw e;
079: throw new JspPropertyNotFoundException(this .mark, e);
080: } catch (ELException e) {
081: if (e instanceof JspELException)
082: throw e;
083: throw new JspELException(this .mark, e);
084: }
085: }
086:
087: public boolean equals(Object obj) {
088: return this .target.equals(obj);
089: }
090:
091: public int hashCode() {
092: return this .target.hashCode();
093: }
094:
095: public String getExpressionString() {
096: return this .target.getExpressionString();
097: }
098:
099: public boolean isLiteralText() {
100: return this .target.isLiteralText();
101: }
102:
103: public void writeExternal(ObjectOutput out) throws IOException {
104: out.writeUTF(this .mark);
105: out.writeObject(this .target);
106: }
107:
108: public void readExternal(ObjectInput in) throws IOException,
109: ClassNotFoundException {
110: this .mark = in.readUTF();
111: this .target = (MethodExpression) in.readObject();
112: }
113:
114: }
|