KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > el > DefaultVariableMapper


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.el;
16
17 import java.util.HashMap JavaDoc;
18 import java.util.Map JavaDoc;
19
20 import javax.el.ValueExpression;
21 import javax.el.VariableMapper;
22
23 /**
24  * Default instance of a VariableMapper backed by a Map
25  *
26  * @see javax.el.VariableMapper
27  * @see javax.el.ValueExpression
28  * @see java.util.Map
29  *
30  * @author Jacob Hookom
31  * @version $Id: DefaultVariableMapper.java,v 1.2 2005/08/24 04:38:56 jhook Exp $
32  */

33 public final class DefaultVariableMapper extends VariableMapper {
34
35     private Map JavaDoc vars;
36
37     public DefaultVariableMapper() {
38         super();
39     }
40
41     /**
42      * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
43      */

44     public ValueExpression resolveVariable(String JavaDoc name) {
45         if (this.vars != null) {
46             return (ValueExpression) this.vars.get(name);
47         }
48         return null;
49     }
50
51     /**
52      * @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
53      */

54     public ValueExpression setVariable(String JavaDoc name, ValueExpression expression) {
55         if (this.vars == null) {
56             this.vars = new HashMap JavaDoc();
57         }
58         return (ValueExpression) this.vars.put(name, expression);
59     }
60
61 }
62
Popular Tags