KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > SpecVersionMapper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.enterprise.tools.verifier;
26
27 import com.sun.enterprise.util.LocalStringManagerImpl;
28
29 /**
30  * This class is responsible for mapping Java EE platform version to
31  * various component spec versions.
32  * @author Sanjeeb.Sahoo@Sun.COM
33  */

34 public class SpecVersionMapper {
35
36     private static LocalStringManagerImpl smh =
37                                 StringManagerHelper.getLocalStringsManager();
38
39     public static final String JavaDoc JavaEEVersion_1_2 = "1.2"; // NOI18N
40

41     public static final String JavaDoc JavaEEVersion_1_3 = "1.3"; // NOI18N
42

43     public static final String JavaDoc JavaEEVersion_1_4 = "1.4"; // NOI18N
44

45     public static final String JavaDoc JavaEEVersion_5 = "5"; // NOI18N
46

47     private static String JavaDoc[][] PlatformVersionToEJBVersionMap = {
48         {JavaEEVersion_1_2, "1.1"}, // NOI18N
49
{JavaEEVersion_1_3, "2.0"}, // NOI18N
50
{JavaEEVersion_1_4, "2.1"}, // NOI18N
51
{JavaEEVersion_5, "3.0"} // NOI18N
52
};
53
54     private static String JavaDoc[][] PlatformVersionToAppClientVersionMap = {
55         {JavaEEVersion_1_2, "1.2"}, // NOI18N
56
{JavaEEVersion_1_3, "1.3"}, // NOI18N
57
{JavaEEVersion_1_4, "1.4"}, // NOI18N
58
{JavaEEVersion_5, "5"} // NOI18N
59
};
60
61     private static String JavaDoc[][] PlatformVersionToJCAVersionMap = {
62         {JavaEEVersion_1_3, "1.0"}, // NOI18N
63
{JavaEEVersion_1_4, "1.5"}, // NOI18N
64
{JavaEEVersion_5, "1.5"} // NOI18N
65
};
66
67     private static String JavaDoc[][] PlatformVersionToWebAppVersionMap = {
68         {JavaEEVersion_1_2, "2.2"}, // NOI18N
69
{JavaEEVersion_1_3, "2.3"}, // NOI18N
70
{JavaEEVersion_1_4, "2.4"}, // NOI18N
71
{JavaEEVersion_5, "2.5"} // NOI18N
72
};
73
74     private static String JavaDoc[][] PlatformVersionToWebServiceVersionMap = {
75         {JavaEEVersion_1_4, "1.1"}, // NOI18N
76
{JavaEEVersion_5, "1.2"} // NOI18N
77
};
78
79     private static String JavaDoc[][] PlatformVersionToWebServiceClientVersionMap = {
80         {JavaEEVersion_1_4, "1.1"}, // NOI18N
81
{JavaEEVersion_5, "1.2"} // NOI18N
82
};
83     
84     private static String JavaDoc throwException (String JavaDoc platformVersion)
85             throws IllegalArgumentException JavaDoc {
86         throw new IllegalArgumentException JavaDoc(
87                 smh.getLocalString("com.sun.enterprise.tools.verifier.SpecVersionMapper.exception", // NOI18N
88
"Not able to map platform version [ {0} ] component version.", // NOI18N
89
new Object JavaDoc[] {platformVersion}));
90     }
91
92     public static String JavaDoc getEJBVersion(String JavaDoc platformVersion)
93             throws IllegalArgumentException JavaDoc {
94         for (String JavaDoc[] row : PlatformVersionToEJBVersionMap) {
95             if (row[0].equals(platformVersion)) {
96                 return row[1];
97             }
98         }
99         return throwException(platformVersion);
100     }
101
102     public static String JavaDoc getJCAVersion(String JavaDoc platformVersion)
103             throws IllegalArgumentException JavaDoc {
104         for (String JavaDoc[] row : PlatformVersionToJCAVersionMap) {
105             if (row[0].equals(platformVersion)) {
106                 return row[1];
107             }
108         }
109         return throwException(platformVersion);
110     }
111
112     public static String JavaDoc getWebAppVersion(String JavaDoc platformVersion)
113             throws IllegalArgumentException JavaDoc {
114         for (String JavaDoc[] row : PlatformVersionToWebAppVersionMap) {
115             if (row[0].equals(platformVersion)) {
116                 return row[1];
117             }
118         }
119         return throwException(platformVersion);
120     }
121
122     public static String JavaDoc getAppClientVersion(String JavaDoc platformVersion)
123             throws IllegalArgumentException JavaDoc {
124         for (String JavaDoc[] row : PlatformVersionToAppClientVersionMap) {
125             if (row[0].equals(platformVersion)) {
126                 return row[1];
127             }
128         }
129         return throwException(platformVersion);
130     }
131
132     public static String JavaDoc getWebServiceVersion(String JavaDoc platformVersion)
133             throws IllegalArgumentException JavaDoc {
134         for (String JavaDoc[] row : PlatformVersionToWebServiceVersionMap) {
135             if (row[0].equals(platformVersion)) {
136                 return row[1];
137             }
138         }
139         return throwException(platformVersion);
140     }
141
142     public static String JavaDoc getWebServiceClientVersion(String JavaDoc platformVersion) {
143         for (String JavaDoc[] row : PlatformVersionToWebServiceClientVersionMap) {
144             if (row[0].equals(platformVersion)) {
145                 return row[1];
146             }
147         }
148         return throwException(platformVersion);
149     }
150 }
151
Popular Tags