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.tag.jstl.core;
20
21 import java.io.Serializable;
22 import java.util.Map;
23
24 import javax.el.ELContext;
25 import javax.el.ValueExpression;
26
27
28
29
30
31 public final class MappedValueExpression extends ValueExpression
32 {
33 private final static class Entry implements Map.Entry, Serializable
34 {
35 private final Map src;
36 private final Object key;
37
38 public Entry(Map src, Object key)
39 {
40 this.src = src;
41 this.key = key;
42 }
43
44 public Object getKey()
45 {
46 return key;
47 }
48
49 public Object getValue()
50 {
51 return src.get(key);
52 }
53
54 public Object setValue(Object value)
55 {
56 return src.put(key, value);
57 }
58
59 }
60
61
62
63
64 private static final long serialVersionUID = 1L;
65
66 private final Object key;
67
68 private final ValueExpression orig;
69
70
71
72
73 public MappedValueExpression(ValueExpression orig, Map.Entry entry)
74 {
75 this.orig = orig;
76 this.key = entry.getKey();
77 }
78
79
80
81
82
83
84 public Object getValue(ELContext context)
85 {
86 Object base = this.orig.getValue(context);
87 if (base != null)
88 {
89 context.setPropertyResolved(true);
90 return new Entry((Map) base, key);
91
92 }
93 return null;
94 }
95
96
97
98
99
100
101 public void setValue(ELContext context, Object value)
102 {
103 Object base = this.orig.getValue(context);
104 if (base != null)
105 {
106 context.setPropertyResolved(false);
107 context.getELResolver().setValue(context, base, key, value);
108 }
109 }
110
111
112
113
114
115
116 public boolean isReadOnly(ELContext context)
117 {
118 Object base = this.orig.getValue(context);
119 if (base != null)
120 {
121 context.setPropertyResolved(false);
122 return context.getELResolver().isReadOnly(context, base, key);
123 }
124 return true;
125 }
126
127
128
129
130
131
132 public Class getType(ELContext context)
133 {
134 Object base = this.orig.getValue(context);
135 if (base != null)
136 {
137 context.setPropertyResolved(false);
138 return context.getELResolver().getType(context, base, key);
139 }
140 return null;
141 }
142
143
144
145
146
147
148 public Class getExpectedType()
149 {
150 return Object.class;
151 }
152
153
154
155
156
157
158 public String getExpressionString()
159 {
160 return this.orig.getExpressionString();
161 }
162
163
164
165
166
167
168 public boolean equals(Object obj)
169 {
170 return this.orig.equals(obj);
171 }
172
173
174
175
176
177
178 public int hashCode()
179 {
180
181 return 0;
182 }
183
184
185
186
187
188
189 public boolean isLiteralText()
190 {
191
192 return false;
193 }
194
195 }