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.PropertyNotFoundException;
023: import javax.el.PropertyNotWritableException;
024: import javax.el.ValueExpression;
025:
026: import com.sun.facelets.tag.TagAttribute;
027:
028: /**
029: *
030: *
031: * @author Jacob Hookom
032: * @version $Id: TagValueExpression.java,v 1.6 2005/08/24 04:38:57 jhook Exp $
033: */
034: public final class TagValueExpression extends ValueExpression implements
035: Externalizable {
036:
037: private static final long serialVersionUID = 1L;
038:
039: private ValueExpression orig;
040:
041: private String attr;
042:
043: public TagValueExpression() {
044: super ();
045: }
046:
047: public TagValueExpression(TagAttribute attr, ValueExpression orig) {
048: this .attr = attr.toString();
049: this .orig = orig;
050: }
051:
052: public Class getExpectedType() {
053: return this .orig.getExpectedType();
054: }
055:
056: public Class getType(ELContext context) {
057: try {
058: return this .orig.getType(context);
059: } catch (PropertyNotFoundException pnfe) {
060: throw new PropertyNotFoundException(this .attr + ": "
061: + pnfe.getMessage(), pnfe.getCause());
062: } catch (ELException e) {
063: throw new ELException(this .attr + ": " + e.getMessage(), e
064: .getCause());
065: }
066: }
067:
068: public Object getValue(ELContext context) {
069: try {
070: return this .orig.getValue(context);
071: } catch (PropertyNotFoundException pnfe) {
072: throw new PropertyNotFoundException(this .attr + ": "
073: + pnfe.getMessage(), pnfe.getCause());
074: } catch (ELException e) {
075: throw new ELException(this .attr + ": " + e.getMessage(), e
076: .getCause());
077: }
078: }
079:
080: public boolean isReadOnly(ELContext context) {
081: try {
082: return this .orig.isReadOnly(context);
083: } catch (PropertyNotFoundException pnfe) {
084: throw new PropertyNotFoundException(this .attr + ": "
085: + pnfe.getMessage(), pnfe.getCause());
086: } catch (ELException e) {
087: throw new ELException(this .attr + ": " + e.getMessage(), e
088: .getCause());
089: }
090: }
091:
092: public void setValue(ELContext context, Object value) {
093: try {
094: this .orig.setValue(context, value);
095: } catch (PropertyNotFoundException pnfe) {
096: throw new PropertyNotFoundException(this .attr + ": "
097: + pnfe.getMessage(), pnfe.getCause());
098: } catch (PropertyNotWritableException pnwe) {
099: throw new PropertyNotWritableException(this .attr + ": "
100: + pnwe.getMessage(), pnwe.getCause());
101: } catch (ELException e) {
102: throw new ELException(this .attr + ": " + e.getMessage(), e
103: .getCause());
104: }
105: }
106:
107: public boolean equals(Object obj) {
108: return this .orig.equals(obj);
109: }
110:
111: public String getExpressionString() {
112: return this .orig.getExpressionString();
113: }
114:
115: public int hashCode() {
116: return this .orig.hashCode();
117: }
118:
119: public boolean isLiteralText() {
120: return this .orig.isLiteralText();
121: }
122:
123: public void readExternal(ObjectInput in) throws IOException,
124: ClassNotFoundException {
125: this .orig = (ValueExpression) in.readObject();
126: this .attr = in.readUTF();
127: }
128:
129: public void writeExternal(ObjectOutput out) throws IOException {
130: out.writeObject(this .orig);
131: out.writeUTF(this .attr);
132: }
133:
134: public String toString() {
135: return this .attr + ": " + this.orig;
136: }
137: }
|