1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.view.facelets.el;
20
21 import java.io.Externalizable;
22 import java.io.IOException;
23 import java.io.ObjectInput;
24 import java.io.ObjectOutput;
25
26 import javax.el.ELContext;
27 import javax.el.ELException;
28 import javax.el.PropertyNotFoundException;
29 import javax.el.PropertyNotWritableException;
30 import javax.el.ValueExpression;
31 import javax.el.ValueReference;
32 import javax.faces.FacesWrapper;
33 import javax.faces.view.facelets.TagAttribute;
34
35
36
37
38
39
40
41 public class TagValueExpression extends ValueExpression implements Externalizable, FacesWrapper<ValueExpression>
42 {
43
44 private static final long serialVersionUID = 1L;
45
46
47 ValueExpression orig;
48 String attr;
49
50 public TagValueExpression()
51 {
52 super();
53 }
54
55 public TagValueExpression(TagAttribute attr, ValueExpression orig)
56 {
57 this.attr = attr.toString();
58 this.orig = orig;
59 }
60
61 @Override
62 public Class<?> getExpectedType()
63 {
64 return this.orig.getExpectedType();
65 }
66
67 @Override
68 public Class<?> getType(ELContext context)
69 {
70 try
71 {
72 return this.orig.getType(context);
73 }
74 catch (PropertyNotFoundException pnfe)
75 {
76 throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
77 }
78 catch (ELException e)
79 {
80 throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
81 }
82 }
83
84 @Override
85 public Object getValue(ELContext context)
86 {
87 try
88 {
89 return this.orig.getValue(context);
90 }
91 catch (PropertyNotFoundException pnfe)
92 {
93 throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
94 }
95 catch (ELException e)
96 {
97 throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
98 }
99 }
100
101 @Override
102 public boolean isReadOnly(ELContext context)
103 {
104 try
105 {
106 return this.orig.isReadOnly(context);
107 }
108 catch (PropertyNotFoundException pnfe)
109 {
110 throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
111 }
112 catch (ELException e)
113 {
114 throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
115 }
116 }
117
118 @Override
119 public void setValue(ELContext context, Object value)
120 {
121 try
122 {
123 this.orig.setValue(context, value);
124 }
125 catch (PropertyNotFoundException pnfe)
126 {
127 throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
128 }
129 catch (PropertyNotWritableException pnwe)
130 {
131 throw new PropertyNotWritableException(this.attr + ": " + pnwe.getMessage(), pnwe.getCause());
132 }
133 catch (ELException e)
134 {
135 throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
136 }
137 }
138
139 @Override
140 public boolean equals(Object obj)
141 {
142 return this.orig.equals(obj);
143 }
144
145 @Override
146 public String getExpressionString()
147 {
148 return this.orig.getExpressionString();
149 }
150
151 @Override
152 public int hashCode()
153 {
154 return this.orig.hashCode();
155 }
156
157 @Override
158 public boolean isLiteralText()
159 {
160 return this.orig.isLiteralText();
161 }
162
163 @Override
164 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
165 {
166 this.orig = (ValueExpression) in.readObject();
167 this.attr = in.readUTF();
168 }
169
170 @Override
171 public void writeExternal(ObjectOutput out) throws IOException
172 {
173 out.writeObject(this.orig);
174 out.writeUTF(this.attr);
175 }
176
177 @Override
178 public String toString()
179 {
180 return this.attr + ": " + this.orig;
181 }
182
183 @Override
184 public ValueExpression getWrapped()
185 {
186 return orig;
187 }
188
189 @Override
190 public ValueReference getValueReference(ELContext context)
191 {
192 try
193 {
194 return this.orig.getValueReference(context);
195 }
196 catch (PropertyNotFoundException pnfe)
197 {
198 throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
199 }
200 catch (ELException e)
201 {
202 throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
203 }
204 }
205 }