1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.el.convert; |
20 | |
|
21 | |
import javax.el.ELContext; |
22 | |
import javax.el.ELException; |
23 | |
import javax.el.ELResolver; |
24 | |
import javax.faces.context.FacesContext; |
25 | |
import javax.faces.el.EvaluationException; |
26 | |
import javax.faces.el.PropertyNotFoundException; |
27 | |
import javax.faces.el.PropertyResolver; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public final class ELResolverToPropertyResolver extends PropertyResolver { |
34 | |
|
35 | |
private final ELResolver elResolver; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 0 | public ELResolverToPropertyResolver(final ELResolver elResolver) { |
41 | 0 | this.elResolver = elResolver; |
42 | 0 | } |
43 | |
|
44 | |
public boolean isReadOnly(final Object base, final int index) |
45 | |
throws EvaluationException, PropertyNotFoundException { |
46 | |
|
47 | |
try { |
48 | 0 | return elResolver.isReadOnly(elContext(), base, Integer.valueOf(index)); |
49 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
50 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
51 | 0 | } catch (ELException e) { |
52 | 0 | throw new EvaluationException(e); |
53 | |
} |
54 | |
|
55 | |
} |
56 | |
|
57 | |
public boolean isReadOnly(final Object base, final Object property) |
58 | |
throws EvaluationException, PropertyNotFoundException { |
59 | |
|
60 | |
try { |
61 | 0 | return elResolver.isReadOnly(elContext(), base, property); |
62 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
63 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
64 | 0 | } catch (ELException e) { |
65 | 0 | throw new EvaluationException(e); |
66 | |
} |
67 | |
|
68 | |
} |
69 | |
|
70 | |
public Object getValue(final Object base, final int index) |
71 | |
throws EvaluationException, PropertyNotFoundException { |
72 | |
|
73 | |
try { |
74 | 0 | return elResolver.getValue(elContext(), base, Integer.valueOf(index)); |
75 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
76 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
77 | 0 | } catch (ELException e) { |
78 | 0 | throw new EvaluationException(e); |
79 | |
} |
80 | |
|
81 | |
} |
82 | |
|
83 | |
public Object getValue(final Object base, final Object property) |
84 | |
throws EvaluationException, PropertyNotFoundException { |
85 | |
|
86 | |
try { |
87 | 0 | return elResolver.getValue(elContext(), base, property); |
88 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
89 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
90 | 0 | } catch (ELException e) { |
91 | 0 | throw new EvaluationException(e); |
92 | |
} |
93 | |
} |
94 | |
|
95 | |
public Class getType(final Object base, int index) |
96 | |
throws EvaluationException, PropertyNotFoundException { |
97 | |
|
98 | |
try { |
99 | 0 | return elResolver.getType(elContext(), base, Integer.valueOf(index)); |
100 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
101 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
102 | 0 | } catch (ELException e) { |
103 | 0 | throw new EvaluationException(e); |
104 | |
} |
105 | |
} |
106 | |
|
107 | |
public Class getType(final Object base, final Object property) |
108 | |
throws EvaluationException, PropertyNotFoundException { |
109 | |
|
110 | |
try { |
111 | 0 | return elResolver.getType(elContext(), base, property); |
112 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
113 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
114 | 0 | } catch (ELException e) { |
115 | 0 | throw new EvaluationException(e); |
116 | |
} |
117 | |
} |
118 | |
|
119 | |
public void setValue(final Object base, final Object property, final Object value) |
120 | |
throws EvaluationException, PropertyNotFoundException { |
121 | |
|
122 | |
try { |
123 | 0 | elResolver.setValue(elContext(), base, property, value); |
124 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
125 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
126 | 0 | } catch (ELException e) { |
127 | 0 | throw new EvaluationException(e); |
128 | 0 | } |
129 | 0 | } |
130 | |
|
131 | |
public void setValue(final Object base, int index, final Object value) |
132 | |
throws EvaluationException, PropertyNotFoundException { |
133 | |
|
134 | |
try { |
135 | 0 | elResolver.setValue(elContext(), base, Integer.valueOf(index), value); |
136 | 0 | } catch (javax.el.PropertyNotFoundException e) { |
137 | 0 | throw new javax.faces.el.PropertyNotFoundException(e); |
138 | 0 | } catch (ELException e) { |
139 | 0 | throw new EvaluationException(e); |
140 | 0 | } |
141 | |
|
142 | 0 | } |
143 | |
|
144 | |
private ELContext elContext() { |
145 | 0 | return FacesContext.getCurrentInstance().getELContext(); |
146 | |
} |
147 | |
|
148 | |
} |