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.faces.FacesWrapper; |
32 | |
import javax.faces.view.Location; |
33 | |
import javax.faces.view.facelets.TagAttribute; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class ContextAwareTagValueExpression |
42 | |
extends ValueExpression |
43 | |
implements Externalizable, FacesWrapper<ValueExpression>, ContextAware |
44 | |
{ |
45 | |
|
46 | |
private static final long serialVersionUID = 1L; |
47 | |
|
48 | |
private ValueExpression _wrapped; |
49 | |
|
50 | |
private Location _location; |
51 | |
|
52 | |
private String _qName; |
53 | |
|
54 | |
public ContextAwareTagValueExpression() |
55 | |
{ |
56 | 0 | super(); |
57 | 0 | } |
58 | |
|
59 | |
public ContextAwareTagValueExpression(TagAttribute tagAttribute, ValueExpression valueExpression) |
60 | 0 | { |
61 | 0 | _location = tagAttribute.getLocation(); |
62 | 0 | _qName = tagAttribute.getQName(); |
63 | 0 | _wrapped = valueExpression; |
64 | 0 | } |
65 | |
|
66 | |
public Class<?> getExpectedType() |
67 | |
{ |
68 | 0 | return _wrapped.getExpectedType(); |
69 | |
} |
70 | |
|
71 | |
public Class<?> getType(ELContext context) |
72 | |
{ |
73 | |
try |
74 | |
{ |
75 | 0 | return _wrapped.getType(context); |
76 | |
} |
77 | 0 | catch (PropertyNotFoundException pnfe) |
78 | |
{ |
79 | 0 | throw new ContextAwarePropertyNotFoundException(getLocation(), getLocalExpressionString(), getQName(),pnfe); |
80 | |
} |
81 | 0 | catch (ELException e) |
82 | |
{ |
83 | 0 | throw new ContextAwareELException(getLocation(), getLocalExpressionString(), getQName(), e); |
84 | |
} |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
} |
91 | |
|
92 | |
public Object getValue(ELContext context) |
93 | |
{ |
94 | |
try |
95 | |
{ |
96 | 0 | return _wrapped.getValue(context); |
97 | |
} |
98 | 0 | catch (PropertyNotFoundException pnfe) |
99 | |
{ |
100 | 0 | throw new ContextAwarePropertyNotFoundException(getLocation(), getLocalExpressionString(), getQName(),pnfe); |
101 | |
} |
102 | 0 | catch (ELException e) |
103 | |
{ |
104 | 0 | throw new ContextAwareELException(getLocation(), getLocalExpressionString(), getQName(), e); |
105 | |
} |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
} |
112 | |
|
113 | |
private String getLocalExpressionString() |
114 | |
{ |
115 | 0 | String expressionString = null; |
116 | |
try |
117 | |
{ |
118 | 0 | expressionString = getExpressionString(); |
119 | |
} |
120 | 0 | catch (Throwable t) |
121 | |
{ |
122 | |
|
123 | 0 | } |
124 | 0 | return expressionString; |
125 | |
} |
126 | |
|
127 | |
public boolean isReadOnly(ELContext context) |
128 | |
{ |
129 | |
try |
130 | |
{ |
131 | 0 | return _wrapped.isReadOnly(context); |
132 | |
} |
133 | 0 | catch (PropertyNotFoundException pnfe) |
134 | |
{ |
135 | 0 | throw new ContextAwarePropertyNotFoundException(getLocation(), getLocalExpressionString(), getQName(),pnfe); |
136 | |
} |
137 | 0 | catch (ELException e) |
138 | |
{ |
139 | 0 | throw new ContextAwareELException(getLocation(), getLocalExpressionString(), getQName(), e); |
140 | |
} |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
} |
148 | |
|
149 | |
public void setValue(ELContext context, Object value) |
150 | |
{ |
151 | |
try |
152 | |
{ |
153 | 0 | _wrapped.setValue(context, value); |
154 | |
} |
155 | 0 | catch (PropertyNotFoundException pnfe) |
156 | |
{ |
157 | 0 | throw new ContextAwarePropertyNotFoundException(getLocation(), getLocalExpressionString(), getQName(),pnfe); |
158 | |
} |
159 | 0 | catch (PropertyNotWritableException pnwe) |
160 | |
{ |
161 | 0 | throw new ContextAwarePropertyNotWritableException(getLocation(), getLocalExpressionString(), |
162 | |
getQName(), pnwe); |
163 | |
} |
164 | 0 | catch (ELException e) |
165 | |
{ |
166 | 0 | throw new ContextAwareELException(getLocation(), getLocalExpressionString(), getQName(), e); |
167 | 0 | } |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | 0 | } |
174 | |
|
175 | |
public boolean equals(Object obj) |
176 | |
{ |
177 | 0 | return _wrapped.equals(obj); |
178 | |
} |
179 | |
|
180 | |
public String getExpressionString() |
181 | |
{ |
182 | 0 | return _wrapped.getExpressionString(); |
183 | |
} |
184 | |
|
185 | |
public int hashCode() |
186 | |
{ |
187 | 0 | return _wrapped.hashCode(); |
188 | |
} |
189 | |
|
190 | |
public boolean isLiteralText() |
191 | |
{ |
192 | 0 | return _wrapped.isLiteralText(); |
193 | |
} |
194 | |
|
195 | |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException |
196 | |
{ |
197 | 0 | _wrapped = (ValueExpression) in.readObject(); |
198 | 0 | _location = (Location) in.readObject(); |
199 | 0 | _qName = in.readUTF(); |
200 | 0 | } |
201 | |
|
202 | |
public void writeExternal(ObjectOutput out) throws IOException |
203 | |
{ |
204 | 0 | out.writeObject(_wrapped); |
205 | 0 | out.writeObject(_location); |
206 | 0 | out.writeUTF(_qName); |
207 | 0 | } |
208 | |
|
209 | |
public String toString() |
210 | |
{ |
211 | 0 | return _location + ": " + _wrapped; |
212 | |
} |
213 | |
|
214 | |
public ValueExpression getWrapped() |
215 | |
{ |
216 | 0 | return _wrapped; |
217 | |
} |
218 | |
|
219 | |
public Location getLocation() |
220 | |
{ |
221 | 0 | return _location; |
222 | |
} |
223 | |
|
224 | |
public String getQName() |
225 | |
{ |
226 | 0 | return _qName; |
227 | |
} |
228 | |
} |