KickJava   Java API By Example, From Geeks To Geeks.

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


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 CommandTypes defines enumeration values for the
28  * DeploymentStatus object.
29  *
30  * @author rsearls
31  */

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

36     /**
37      * The DeploymentManger action operation being processed
38      * is distribute.
39      */

40     public static final CommandType JavaDoc DISTRIBUTE = new CommandType JavaDoc(0);
41     /**
42      * The DeploymentManger action operation being processed is start.
43      */

44     public static final CommandType JavaDoc START = new CommandType JavaDoc(1);
45     /**
46      * The DeploymentManger action operation being processed is stop.
47      */

48     public static final CommandType JavaDoc STOP = new CommandType JavaDoc(2);
49     /**
50      * The DeploymentManger action operation being processed is undeploy.
51      */

52     public static final CommandType JavaDoc UNDEPLOY = new CommandType JavaDoc(3);
53     /**
54      * The DeploymentManger action operation being processed is redeploy.
55      */

56     public static final CommandType JavaDoc REDEPLOY = new CommandType JavaDoc(4);
57
58
59     private static final String JavaDoc[] stringTable = {
60     "distribute",
61     "start",
62     "stop",
63     "undeploy",
64     "redeploy",
65     };
66
67     private static final CommandType JavaDoc[] enumValueTable = {
68     DISTRIBUTE,
69     START,
70     STOP,
71     UNDEPLOY,
72     REDEPLOY,
73     };
74     
75     /**
76      * Construct a new enumeration value with the given integer value.
77      *
78      * @param value Integer value.
79      */

80     protected CommandType(int value)
81     {
82         this.value = value;
83     }
84        
85     /**
86      * Returns this enumeration value's integer value.
87      * @return the value
88      */

89     public int getValue()
90     { return value;
91     }
92
93     /**
94      * Returns the string table for class CommandType
95      */

96     protected String JavaDoc[] getStringTable()
97     {
98         return stringTable;
99     }
100
101     /**
102      * Returns the enumeration value table for class CommandType
103      */

104     protected CommandType JavaDoc[] getEnumValueTable()
105     {
106         return enumValueTable;
107     }
108
109     /**
110      * Return an object of the specified value.
111      * @param value a designator for the object.
112      */

113     public static CommandType JavaDoc getCommandType(int value)
114     { return enumValueTable[value];
115     }
116
117     /**
118      * Return the string name of this CommandType or the
119      * integer value if outside the bounds of the table
120      */

121     public String JavaDoc toString()
122     {
123         String JavaDoc[] strTable = getStringTable();
124         int index = value - getOffset();
125         if (strTable != null && index >= 0 && index < strTable.length)
126             return strTable[index];
127         else
128             return Integer.toString (value);
129     }
130
131     /**
132      * Returns the lowest integer value used by this enumeration value's
133      * enumeration class.
134      * <P>
135      * The default implementation returns 0.
136      * @return the offset of the lowest enumeration value.
137      */

138     protected int getOffset()
139     { return 0;
140     }
141
142 }
143
Popular Tags