KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > util > XModuleType


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 com.sun.enterprise.deployment.util;
25
26 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
27
28 /**
29  * Extended module types which are specific to SJSAS
30  *
31  * @author Sreenivas Munnangi
32  */

33
34 public class XModuleType extends ModuleType JavaDoc {
35
36     private static final int offset = 100;
37     public static final XModuleType LCM = new XModuleType(100);
38     public static final XModuleType CMB = new XModuleType(101);
39
40     private static final String JavaDoc[] stringTable = {
41         "lcm",
42         "cmb"
43     };
44
45     private static final XModuleType[] enumValueTable = {
46         LCM,
47         CMB
48     };
49
50     private static final String JavaDoc[] moduleExtension = {
51         ".jar",
52         ".jar"
53     };
54
55     protected XModuleType(int value) {
56         super(value);
57     }
58
59     protected String JavaDoc[] getStringTable() {
60         return this.stringTable;
61     }
62
63     protected ModuleType JavaDoc[] getEnumValueTable() {
64         return this.enumValueTable;
65     }
66
67     public String JavaDoc getModuleExtension() {
68         if (super.getValue() >= this.getOffset()) {
69             return (this.moduleExtension[super.getValue() - this.getOffset()]);
70         } else {
71             return super.getModuleExtension();
72         }
73     }
74
75     public static ModuleType JavaDoc getModuleType(int value) {
76         if (value >= offset) {
77             return enumValueTable[value-offset];
78         } else {
79             return ModuleType.getModuleType(value);
80         }
81     }
82
83     public String JavaDoc toString() {
84         String JavaDoc[] strTable = this.getStringTable();
85         int index = super.getValue() - this.getOffset();
86         if (strTable != null && index >= 0 && index < strTable.length)
87             return strTable[index];
88         else
89             super.toString();
90         return null;
91     }
92
93     protected int getOffset() {
94         return offset;
95     }
96
97 }
98
Popular Tags