Save This Page
Home » glassfish-v2ur2-b04-src » javax.enterprise.deploy.shared » [javadoc | source]
    1   /*
    2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    3    * 
    4    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    5    * 
    6    * The contents of this file are subject to the terms of either the GNU
    7    * General Public License Version 2 only ("GPL") or the Common Development
    8    * and Distribution License("CDDL") (collectively, the "License").  You
    9    * may not use this file except in compliance with the License. You can obtain
   10    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   11    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   12    * language governing permissions and limitations under the License.
   13    * 
   14    * When distributing the software, include this License Header Notice in each
   15    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   16    * Sun designates this particular file as subject to the "Classpath" exception
   17    * as provided by Sun in the GPL Version 2 section of the License file that
   18    * accompanied this code.  If applicable, add the following below the License
   19    * Header, with the fields enclosed by brackets [] replaced by your own
   20    * identifying information: "Portions Copyrighted [year]
   21    * [name of copyright owner]"
   22    * 
   23    * Contributor(s):
   24    * 
   25    * If you wish your version of this file to be governed by only the CDDL or
   26    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   27    * elects to include this software in this distribution under the [CDDL or GPL
   28    * Version 2] license."  If you don't indicate a single choice of license, a
   29    * recipient has the option to distribute your version of this file under
   30    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   31    * its licensees as provided above.  However, if you add GPL Version 2 code
   32    * and therefore, elected the GPL Version 2 license, then the option applies
   33    * only if the new code is made subject to such option by the copyright
   34    * holder.
   35    */
   36   
   37   package javax.enterprise.deploy.shared;
   38   
   39   /**
   40    * Class ModuleTypes defines enumeration values for the J2EE
   41    * module types.
   42    *
   43    * @author Rebecca Searls
   44    */
   45   public class ModuleType 
   46   {
   47   	private int value; // This enumeration value's int value
   48   
   49   	/**
   50   	 * The module is an EAR archive.
   51   	 */
   52   	public static final ModuleType EAR = new ModuleType(0);
   53   	/**
   54   	 * The module is an Enterprise Java Bean archive.
   55   	 */
   56   	public static final ModuleType EJB = new ModuleType(1);
   57   	/**
   58   	 * The module is an Client Application archive.
   59   	 */
   60   	public static final ModuleType CAR = new ModuleType(2);
   61   	/**
   62   	 * The module is an Connector archive.
   63   	 */
   64   	public static final ModuleType RAR = new ModuleType(3);
   65   	/**
   66   	 * The module is an Web Application archive.
   67   	 */
   68   	public static final ModuleType WAR = new ModuleType(4);
   69   
   70   
   71   	private static final String[] stringTable = {
   72   	"ear",
   73   	"ejb",
   74   	"car",
   75   	"rar",
   76   	"war",
   77   	};
   78   
   79   	private static final ModuleType[] enumValueTable = {
   80   	EAR,
   81   	EJB,
   82   	CAR,
   83   	RAR,
   84   	WAR,
   85   	};
   86   
   87   	/*
   88   	 *  Module extensions.
   89   	 */
   90       private static final String[] moduleExtension = {
   91       ".ear",
   92   	".jar",
   93   	".jar",
   94   	".rar",
   95   	".war",
   96       };
   97           
   98   
   99       /**
  100        * Construct a new enumeration value with the given integer value.
  101        *
  102        * @param  value  Integer value.
  103        */
  104       protected ModuleType(int value)
  105       {   this.value = value;
  106       }
  107           
  108       /**
  109        * Returns this enumeration value's integer value.
  110        * @return the value
  111        */
  112       public int getValue() 
  113   	{ 	return value;
  114       }
  115   
  116           
  117   	/**
  118   	 * Returns the string table for class ModuleType
  119   	 */
  120   	protected String[] getStringTable()
  121   	{   return stringTable;
  122   	}
  123   
  124   	/**
  125   	 * Returns the enumeration value table for class ModuleType
  126   	 */
  127   	protected ModuleType[] getEnumValueTable()
  128   	{   return enumValueTable;
  129   	}
  130   
  131   	/**
  132        * Return the file extension string for this enumeration.
  133        */
  134       public String getModuleExtension()
  135       {   return (moduleExtension[getValue()]);
  136       }
  137       
  138   	/**
  139        * Return an object of the specified value.
  140        * @param value a designator for the object.
  141        */
  142       public static ModuleType getModuleType(int value)
  143       {   return enumValueTable[value];
  144       }
  145   
  146   	/**
  147   	 * Return the string name of this ModuleType or the
  148   	 * integer value if outside the bounds of the table
  149   	 */
  150       public String toString() 
  151   	{
  152       	String[] strTable = getStringTable();
  153       	int index = value - getOffset();
  154   		if (strTable != null && index >= 0 && index < strTable.length)
  155           	return strTable[index];
  156   		else
  157           	return Integer.toString (value);
  158       }
  159   
  160       /**
  161        * Returns the lowest integer value used by this enumeration value's
  162        * enumeration class.
  163        * <P>
  164        * The default implementation returns 0. If the enumeration class (a
  165        * subclass of class EnumSyntax) uses integer values starting at other than
  166   
  167        * 0, override this method in the subclass.
  168        * @return the offset of the lowest enumeration value.
  169        */
  170       protected int getOffset() 
  171   	{ 	return 0;
  172       }
  173   } 

Save This Page
Home » glassfish-v2ur2-b04-src » javax.enterprise.deploy.shared » [javadoc | source]