001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    //
021    // This source code implements specifications defined by the Java
022    // Community Process. In order to remain compliant with the specification
023    // DO NOT add / change / or delete method signatures!
024    //
025    
026    package javax.enterprise.deploy.shared;
027    
028    /**
029     * Class ModuleTypes defines enumeration values for the J2EE module types.
030     *
031     * @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (Mi, 25. Okt 2006) $
032     */
033    public class ModuleType {
034        /**
035         * The module is an EAR archive.
036         */
037        public static final ModuleType EAR = new ModuleType(0);
038        /**
039         * The module is an Enterprise Java Bean archive.
040         */
041        public static final ModuleType EJB = new ModuleType(1);
042        /**
043         * The module is an Client Application archive.
044         */
045        public static final ModuleType CAR = new ModuleType(2);
046        /**
047         * The module is an Connector archive.
048         */
049        public static final ModuleType RAR = new ModuleType(3);
050        /**
051         * The module is an Web Application archive.
052         */
053        public static final ModuleType WAR = new ModuleType(4);
054    
055        private static final ModuleType[] enumValueTable = {
056            EAR,
057            EJB,
058            CAR,
059            RAR,
060            WAR,
061        };
062    
063        private static final String[] stringTable = {
064            "ear",
065            "ejb",
066            "car",
067            "rar",
068            "war",
069        };
070    
071        private static final String[] moduleExtensionTable = {
072            ".ear",
073            ".jar",
074            ".jar",
075            ".rar",
076            ".war",
077        };
078    
079        private int value;
080    
081        /**
082         * Construct a new enumeration value with the given integer value.
083         */
084        protected ModuleType(int value) {
085            this.value = value;
086        }
087    
088        /**
089         * Returns this enumeration value's integer value.
090         */
091        public int getValue() {
092            return value;
093        }
094    
095        /**
096         * Returns the string table for class ModuleType
097         */
098        protected String[] getStringTable() {
099            return stringTable;
100        }
101    
102        /**
103         * Returns the enumeration value table for class ModuleType
104         */
105        protected ModuleType[] getEnumValueTable() {
106            return enumValueTable;
107        }
108    
109        /**
110         * Return the file extension string for this enumeration.
111         */
112        public String getModuleExtension() {
113            return moduleExtensionTable[value];
114        }
115    
116        /**
117         * Return an object of the specified value.
118         *
119         * @param value a designator for the object.
120         */
121        public static ModuleType getModuleType(int value) {
122            return enumValueTable[value];
123        }
124    
125        /**
126         * Return the string name of this ModuleType or the integer value if
127         * outside the bounds of the table
128         */
129        public String toString() {
130            return (value >= 0 && value <= 4) ? stringTable[value] : String.valueOf(value);
131        }
132    
133        /**
134         * Returns the lowest integer value used by this enumeration value's
135         * enumeration class.
136         *
137         * @return the offset of the lowest enumeration value.
138         */
139        protected int getOffset() {
140            return 0;
141        }
142    }