KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > tag > jstl > core > MappedValueExpression


1 /**
2  * Licensed under the Common Development and Distribution License,
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.sun.com/cddl/
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11  * implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */

14
15 package com.sun.facelets.tag.jstl.core;
16
17 import java.util.Map JavaDoc;
18
19 import javax.el.ELContext;
20 import javax.el.ValueExpression;
21
22 /**
23  * @author Jacob Hookom
24  * @version $Id: MappedValueExpression.java,v 1.4 2005/10/19 06:39:30 jhook Exp $
25  */

26 public final class MappedValueExpression extends ValueExpression {
27
28     /**
29      *
30      */

31     private static final long serialVersionUID = 1L;
32
33     private final Object JavaDoc key;
34
35     private final ValueExpression orig;
36
37     /**
38      *
39      */

40     public MappedValueExpression(ValueExpression orig, Map.Entry JavaDoc entry) {
41         this.orig = orig;
42         this.key = entry.getKey();
43     }
44
45     /*
46      * (non-Javadoc)
47      *
48      * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
49      */

50     public Object JavaDoc getValue(ELContext context) {
51         Object JavaDoc base = this.orig.getValue(context);
52         if (base != null) {
53             context.setPropertyResolved(false);
54             return context.getELResolver().getValue(context, base, key);
55         }
56         return null;
57     }
58
59     /*
60      * (non-Javadoc)
61      *
62      * @see javax.el.ValueExpression#setValue(javax.el.ELContext,
63      * java.lang.Object)
64      */

65     public void setValue(ELContext context, Object JavaDoc value) {
66         Object JavaDoc base = this.orig.getValue(context);
67         if (base != null) {
68             context.setPropertyResolved(false);
69             context.getELResolver().setValue(context, base, key, value);
70         }
71     }
72
73     /*
74      * (non-Javadoc)
75      *
76      * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
77      */

78     public boolean isReadOnly(ELContext context) {
79         Object JavaDoc base = this.orig.getValue(context);
80         if (base != null) {
81             context.setPropertyResolved(false);
82             return context.getELResolver().isReadOnly(context, base, key);
83         }
84         return true;
85     }
86
87     /*
88      * (non-Javadoc)
89      *
90      * @see javax.el.ValueExpression#getType(javax.el.ELContext)
91      */

92     public Class JavaDoc getType(ELContext context) {
93         Object JavaDoc base = this.orig.getValue(context);
94         if (base != null) {
95             context.setPropertyResolved(false);
96             return context.getELResolver().getType(context, base, key);
97         }
98         return null;
99     }
100
101     /*
102      * (non-Javadoc)
103      *
104      * @see javax.el.ValueExpression#getExpectedType()
105      */

106     public Class JavaDoc getExpectedType() {
107         return Object JavaDoc.class;
108     }
109
110     /*
111      * (non-Javadoc)
112      *
113      * @see javax.el.Expression#getExpressionString()
114      */

115     public String JavaDoc getExpressionString() {
116         return this.orig.getExpressionString();
117     }
118
119     /*
120      * (non-Javadoc)
121      *
122      * @see javax.el.Expression#equals(java.lang.Object)
123      */

124     public boolean equals(Object JavaDoc obj) {
125         return this.orig.equals(obj);
126     }
127
128     /*
129      * (non-Javadoc)
130      *
131      * @see javax.el.Expression#hashCode()
132      */

133     public int hashCode() {
134         // TODO Auto-generated method stub
135
return 0;
136     }
137
138     /*
139      * (non-Javadoc)
140      *
141      * @see javax.el.Expression#isLiteralText()
142      */

143     public boolean isLiteralText() {
144         // TODO Auto-generated method stub
145
return false;
146     }
147
148 }
149
Popular Tags