KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > util > FacesAPI


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.util;
16
17 import javax.faces.application.Application;
18 import javax.faces.component.UIComponent;
19 import javax.faces.component.UIComponentBase;
20
21 public final class FacesAPI {
22
23     private static final int version = specifyVersion();
24     private static final Class JavaDoc[] UIC_SIG = new Class JavaDoc[] { String JavaDoc.class };
25     
26     private FacesAPI() {
27         super();
28     }
29     
30     private final static int specifyVersion() {
31         try {
32             Application.class.getMethod("getExpressionFactory", null);
33         } catch (NoSuchMethodException JavaDoc e) {
34             return 11;
35         }
36         return 12;
37     }
38     
39     public final static int getVersion() {
40         return version;
41     }
42     
43     public final static int getComponentVersion(UIComponent c) {
44         return (version >= 12 && c instanceof UIComponentBase) ? 12 : 11;
45     }
46     
47     public final static int getComponentVersion(Class JavaDoc c) {
48         return (version >= 12 && UIComponentBase.class.isAssignableFrom(c)) ? 12 : 11;
49     }
50 }
51
Popular Tags