KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.el.ValueExpression;
18 import javax.el.VariableMapper;
19
20 /**
21  * Composite VariableMapper that attempts to load the ValueExpression from the first
22  * VariableMapper, then the second if <code>null</code>.
23  *
24  * @see javax.el.VariableMapper
25  * @see javax.el.ValueExpression
26  *
27  * @author Jacob Hookom
28  * @version $Id: CompositeVariableMapper.java,v 1.2 2005/08/24 04:38:56 jhook Exp $
29  */

30 public final class CompositeVariableMapper extends VariableMapper {
31
32     private final VariableMapper var0;
33
34     private final VariableMapper var1;
35
36     public CompositeVariableMapper(VariableMapper var0, VariableMapper var1) {
37         this.var0 = var0;
38         this.var1 = var1;
39     }
40
41     /**
42      * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
43      */

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

55     public ValueExpression setVariable(String JavaDoc name, ValueExpression expression) {
56         return this.var0.setVariable(name, expression);
57     }
58
59 }
60
Popular Tags