KickJava   Java API By Example, From Geeks To Geeks.

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


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

32 public final class ServletVersion extends J2EEBaseVersion {
33     
34     /** Represents servlet version 2.3
35      */

36     public static final ServletVersion SERVLET_2_3 = new ServletVersion(
37         "2.3", 2300, // NOI18N
38
"1.3", 1300, // NOI18N
39
DTDRegistryLink.SUN_WEBAPP_230_DTD_PUBLIC_ID,
40         DTDRegistryLink.SUN_WEBAPP_230_DTD_SYSTEM_ID);
41     
42     /** Represents servlet version 2.4
43      */

44     public static final ServletVersion SERVLET_2_4 = new ServletVersion(
45         "2.4", 2401, // NOI18N
46
"1.4", 1400, // NOI18N
47
DTDRegistryLink.SUN_WEBAPP_241_DTD_PUBLIC_ID,
48         DTDRegistryLink.SUN_WEBAPP_241_DTD_SYSTEM_ID);
49     
50     /** Represents servlet version 2.5
51      */

52     public static final ServletVersion SERVLET_2_5 = new ServletVersion(
53         "2.5", 2500, // NOI18N
54
"5.0", 5000, // NOI18N
55
DTDRegistryLink.SUN_WEBAPP_250_DTD_PUBLIC_ID,
56         DTDRegistryLink.SUN_WEBAPP_250_DTD_SYSTEM_ID);
57     
58     /** -----------------------------------------------------------------------
59      * Implementation
60      */

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

64     private ServletVersion(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 ServletVersion objects
69      *
70      * @param obj ServletVersion 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 ServletVersion object.
74      */

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