001: /**
002: * Licensed under the Common Development and Distribution License,
003: * you may not use this file except in compliance with the License.
004: * You may obtain a copy of the License at
005: *
006: * http://www.sun.com/cddl/
007: *
008: * Unless required by applicable law or agreed to in writing, software
009: * distributed under the License is distributed on an "AS IS" BASIS,
010: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
011: * implied. See the License for the specific language governing
012: * permissions and limitations under the License.
013: */package com.sun.facelets.el;
014:
015: import java.io.Externalizable;
016: import java.io.IOException;
017: import java.io.ObjectInput;
018: import java.io.ObjectOutput;
019:
020: import javax.el.ELContext;
021: import javax.el.ELException;
022: import javax.el.MethodExpression;
023: import javax.el.MethodInfo;
024: import javax.el.MethodNotFoundException;
025: import javax.el.PropertyNotFoundException;
026:
027: import com.sun.facelets.tag.TagAttribute;
028:
029: /**
030: *
031: *
032: * @author Jacob Hookom
033: * @version $Id: TagMethodExpression.java,v 1.6 2005/08/24 04:38:57 jhook Exp $
034: */
035: public final class TagMethodExpression extends MethodExpression
036: implements Externalizable {
037:
038: private static final long serialVersionUID = 1L;
039:
040: private String attr;
041: private MethodExpression orig;
042:
043: public TagMethodExpression() {
044: super ();
045: }
046:
047: public TagMethodExpression(TagAttribute attr, MethodExpression orig) {
048: this .attr = attr.toString();
049: this .orig = orig;
050: }
051:
052: public MethodInfo getMethodInfo(ELContext context) {
053: try {
054: return this .orig.getMethodInfo(context);
055: } catch (PropertyNotFoundException pnfe) {
056: throw new PropertyNotFoundException(this .attr + ": "
057: + pnfe.getMessage(), pnfe.getCause());
058: } catch (MethodNotFoundException mnfe) {
059: throw new MethodNotFoundException(this .attr + ": "
060: + mnfe.getMessage(), mnfe.getCause());
061: } catch (ELException e) {
062: throw new ELException(this .attr + ": " + e.getMessage(), e
063: .getCause());
064: }
065: }
066:
067: public Object invoke(ELContext context, Object[] params) {
068: try {
069: return this .orig.invoke(context, params);
070: } catch (PropertyNotFoundException pnfe) {
071: throw new PropertyNotFoundException(this .attr + ": "
072: + pnfe.getMessage(), pnfe.getCause());
073: } catch (MethodNotFoundException mnfe) {
074: throw new MethodNotFoundException(this .attr + ": "
075: + mnfe.getMessage(), mnfe.getCause());
076: } catch (ELException e) {
077: throw new ELException(this .attr + ": " + e.getMessage(), e
078: .getCause());
079: }
080: }
081:
082: public String getExpressionString() {
083: return this .orig.getExpressionString();
084: }
085:
086: public boolean equals(Object obj) {
087: return this .orig.equals(obj);
088: }
089:
090: public int hashCode() {
091: return this .orig.hashCode();
092: }
093:
094: public boolean isLiteralText() {
095: return this .orig.isLiteralText();
096: }
097:
098: public void writeExternal(ObjectOutput out) throws IOException {
099: out.writeObject(this .orig);
100: out.writeUTF(this .attr);
101: }
102:
103: public void readExternal(ObjectInput in) throws IOException,
104: ClassNotFoundException {
105: this .orig = (MethodExpression) in.readObject();
106: this .attr = in.readUTF();
107: }
108:
109: public String toString() {
110: return this .attr + ": " + this.orig;
111: }
112: }
|