KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ApplicationVersion.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 Application Version
29  *
30  * @author Peter Williams
31  */

32 public final class ApplicationVersion extends J2EEBaseVersion {
33     
34     /** Represents application version 1.3
35      */

36     public static final ApplicationVersion APPLICATION_1_3 = new ApplicationVersion(
37         "1.3", 1300, // NOI18N
38
"1.3", 1300, // NOI18N
39
DTDRegistryLink.SUN_APPLICATION_130_DTD_PUBLIC_ID,
40         DTDRegistryLink.SUN_APPLICATION_130_DTD_SYSTEM_ID);
41     
42     /** Represents application version 1.4
43      */

44     public static final ApplicationVersion APPLICATION_1_4 = new ApplicationVersion(
45         "1.4", 1400, // NOI18N
46
"1.4", 1400, // NOI18N
47
DTDRegistryLink.SUN_APPLICATION_140_DTD_PUBLIC_ID,
48         DTDRegistryLink.SUN_APPLICATION_140_DTD_SYSTEM_ID);
49
50     /** Represents application version 5.0
51      */

52     public static final ApplicationVersion APPLICATION_5_0 = new ApplicationVersion(
53         "5.0", 5000, // NOI18N
54
"5.0", 5000, // NOI18N
55
DTDRegistryLink.SUN_APPLICATION_500_DTD_PUBLIC_ID,
56         DTDRegistryLink.SUN_APPLICATION_500_DTD_SYSTEM_ID);
57     
58     /** -----------------------------------------------------------------------
59      * Implementation
60      */

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

64     private ApplicationVersion(String JavaDoc version, int nv, String JavaDoc specVersion, int nsv, String JavaDoc pubId, String JavaDoc sysId) {
65         super(version, nv, specVersion, nsv, pubId, sysId);
66     }
67
68     /** Comparator implementation that works only on ApplicationVersion objects
69      *
70      * @param obj ApplicationVersion 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 ApplicationVersion object.
74      */

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