1 14 15 package com.sun.facelets.el; 16 17 import java.io.Externalizable ; 18 import java.io.IOException ; 19 import java.io.ObjectInput ; 20 import java.io.ObjectOutput ; 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 37 public final class TagMethodExpression extends MethodExpression implements 38 Externalizable { 39 40 private static final long serialVersionUID = 1L; 41 42 private String 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 invoke(ELContext context, Object [] 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 getExpressionString() { 79 return this.orig.getExpressionString(); 80 } 81 82 public boolean equals(Object 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 out) throws IOException { 95 out.writeObject(this.orig); 96 out.writeUTF(this.attr); 97 } 98 99 public void readExternal(ObjectInput in) throws IOException , 100 ClassNotFoundException { 101 this.orig = (MethodExpression) in.readObject(); 102 this.attr = in.readUTF(); 103 } 104 105 public String toString() { 106 return this.attr + ": " + this.orig; 107 } 108 } 109 | Popular Tags |