KickJava   Java API By Example, From Geeks To Geeks.

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


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

31 public final class CompositeFunctionMapper extends FunctionMapper {
32
33     private final FunctionMapper fn0;
34
35     private final FunctionMapper fn1;
36
37     public CompositeFunctionMapper(FunctionMapper fn0, FunctionMapper fn1) {
38         this.fn0 = fn0;
39         this.fn1 = fn1;
40     }
41
42     /**
43      * @see javax.el.FunctionMapper#resolveFunction(java.lang.String, java.lang.String)
44      */

45     public Method JavaDoc resolveFunction(String JavaDoc prefix, String JavaDoc name) {
46         Method JavaDoc m = this.fn0.resolveFunction(prefix, name);
47         if (m == null) {
48             return this.fn1.resolveFunction(prefix, name);
49         }
50         return m;
51     }
52
53 }
54
Popular Tags