KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > EjbJarVersion


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * EjbJarVersion.java
21  *
22  * Created on February 25, 2004, 2:36 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean;
26
27 /**
28  * Enumerated types for EjbJar Version
29  *
30  * @author Peter Williams
31  */

32 public final class EjbJarVersion extends J2EEBaseVersion {
33     
34     /** Represents ejbjar version 2.0
35      */

36     public static final EjbJarVersion EJBJAR_2_0 = new EjbJarVersion(
37         "2.0", 2000, // NOI18N
38
"1.3", 1300, // NOI18N
39
DTDRegistryLink.SUN_EJBJAR_200_DTD_PUBLIC_ID,
40         DTDRegistryLink.SUN_EJBJAR_200_DTD_SYSTEM_ID);
41     
42     /** Represents ejbjar version 2.1
43      */

44     public static final EjbJarVersion EJBJAR_2_1 = new EjbJarVersion(
45         "2.1", 2101, // NOI18N
46
"1.4", 1400, // NOI18N
47
DTDRegistryLink.SUN_EJBJAR_211_DTD_PUBLIC_ID,
48         DTDRegistryLink.SUN_EJBJAR_211_DTD_SYSTEM_ID);
49     
50     /** Represents ejbjar version 3.0
51      */

52     public static final EjbJarVersion EJBJAR_3_0 = new EjbJarVersion(
53         "3.0", 3000, // NOI18N
54
"5.0", 5000, // NOI18N
55
DTDRegistryLink.SUN_EJBJAR_300_DTD_PUBLIC_ID,
56         DTDRegistryLink.SUN_EJBJAR_300_DTD_SYSTEM_ID);
57     
58     /** -----------------------------------------------------------------------
59      * Implementation
60      */

61     
62     /** Creates a new instance of EjbJarVersion
63      */

64     private EjbJarVersion(String JavaDoc moduleVersion, int nv, String JavaDoc specVersion, int nsv, String JavaDoc pubId, String JavaDoc sysId) {
65         super(moduleVersion, nv, specVersion, nsv, pubId, sysId);
66     }
67
68     /** Comparator implementation that works only on EjbJarVersion objects
69      *
70      * @param obj EjbJarVersion to compare with.
71      * @return -1, 0, or 1 if this version is less than, equal to, or greater
72      * than the version passed in as an argument.
73      * @throws ClassCastException if obj is not a EjbJarVersion object.
74      */

75     public int compareTo(Object JavaDoc obj) {
76         EjbJarVersion target = (EjbJarVersion) obj;
77         return numericCompare(target);
78     }
79     
80     public static EjbJarVersion getEjbJarVersion(String JavaDoc version) {
81         EjbJarVersion result = null;
82         
83         if(EJBJAR_2_0.toString().equals(version)) {
84             result = EJBJAR_2_0;
85         } else if(EJBJAR_2_1.toString().equals(version)) {
86             result = EJBJAR_2_1;
87         } else if(EJBJAR_3_0.toString().equals(version)) {
88             result = EJBJAR_3_0;
89         }
90         
91         return result;
92     }
93 }
94
Popular Tags