KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > enterprise > deploy > shared > ModuleType


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 package javax.enterprise.deploy.shared;
25
26 /**
27  * Class ModuleTypes defines enumeration values for the J2EE
28  * module types.
29  *
30  * @author Rebecca Searls
31  */

32 public class ModuleType
33 {
34     private int value; // This enumeration value's int value
35

36     /**
37      * The module is an EAR archive.
38      */

39     public static final ModuleType JavaDoc EAR = new ModuleType JavaDoc(0);
40     /**
41      * The module is an Enterprise Java Bean archive.
42      */

43     public static final ModuleType JavaDoc EJB = new ModuleType JavaDoc(1);
44     /**
45      * The module is an Client Application archive.
46      */

47     public static final ModuleType JavaDoc CAR = new ModuleType JavaDoc(2);
48     /**
49      * The module is an Connector archive.
50      */

51     public static final ModuleType JavaDoc RAR = new ModuleType JavaDoc(3);
52     /**
53      * The module is an Web Application archive.
54      */

55     public static final ModuleType JavaDoc WAR = new ModuleType JavaDoc(4);
56
57
58     private static final String JavaDoc[] stringTable = {
59     "ear",
60     "ejb",
61     "car",
62     "rar",
63     "war",
64     };
65
66     private static final ModuleType JavaDoc[] enumValueTable = {
67     EAR,
68     EJB,
69     CAR,
70     RAR,
71     WAR,
72     };
73
74     /*
75      * Module extensions.
76      */

77     private static final String JavaDoc[] moduleExtension = {
78     ".ear",
79     ".jar",
80     ".jar",
81     ".rar",
82     ".war",
83     };
84         
85
86     /**
87      * Construct a new enumeration value with the given integer value.
88      *
89      * @param value Integer value.
90      */

91     protected ModuleType(int value)
92     { this.value = value;
93     }
94         
95     /**
96      * Returns this enumeration value's integer value.
97      * @return the value
98      */

99     public int getValue()
100     { return value;
101     }
102
103         
104     /**
105      * Returns the string table for class ModuleType
106      */

107     protected String JavaDoc[] getStringTable()
108     { return stringTable;
109     }
110
111     /**
112      * Returns the enumeration value table for class ModuleType
113      */

114     protected ModuleType JavaDoc[] getEnumValueTable()
115     { return enumValueTable;
116     }
117
118     /**
119      * Return the file extension string for this enumeration.
120      */

121     public String JavaDoc getModuleExtension()
122     { return (moduleExtension[getValue()]);
123     }
124     
125     /**
126      * Return an object of the specified value.
127      * @param value a designator for the object.
128      */

129     public static ModuleType JavaDoc getModuleType(int value)
130     { return enumValueTable[value];
131     }
132
133     /**
134      * Return the string name of this ModuleType or the
135      * integer value if outside the bounds of the table
136      */

137     public String JavaDoc toString()
138     {
139         String JavaDoc[] strTable = getStringTable();
140         int index = value - getOffset();
141         if (strTable != null && index >= 0 && index < strTable.length)
142             return strTable[index];
143         else
144             return Integer.toString (value);
145     }
146
147     /**
148      * Returns the lowest integer value used by this enumeration value's
149      * enumeration class.
150      * <P>
151      * The default implementation returns 0. If the enumeration class (a
152      * subclass of class EnumSyntax) uses integer values starting at other than
153
154      * 0, override this method in the subclass.
155      * @return the offset of the lowest enumeration value.
156      */

157     protected int getOffset()
158     { return 0;
159     }
160 }
161
Popular Tags