KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

36     /**
37      * The action operation is running normally.
38      */

39     public static final StateType JavaDoc RUNNING = new StateType JavaDoc(0);
40     /**
41      * The action operation has completed normally.
42      */

43     public static final StateType JavaDoc COMPLETED = new StateType JavaDoc(1);
44     /**
45      * The action operation has failed.
46      */

47     public static final StateType JavaDoc FAILED = new StateType JavaDoc(2);
48     /**
49      * The DeploymentManager is running in discommected mode.
50      */

51     public static final StateType JavaDoc RELEASED = new StateType JavaDoc(3);
52
53
54     private static final String JavaDoc[] stringTable = {
55     "running",
56     "completed",
57     "failed",
58     "released",
59     };
60
61     private static final StateType JavaDoc[] enumValueTable = {
62     RUNNING,
63     COMPLETED,
64     FAILED,
65     RELEASED,
66     };
67     
68     /**
69      * Construct a new enumeration value with the given integer value.
70      *
71      * @param value Integer value.
72      */

73     protected StateType(int value)
74     { this.value = value;
75     }
76
77     /**
78      * Returns this enumeration value's integer value.
79      * @return the value
80      */

81     public int getValue()
82     { return value;
83     }
84        
85     /**
86      * Returns the string table for class StateType
87      */

88     protected String JavaDoc[] getStringTable()
89     {
90         return stringTable;
91     }
92
93     /**
94      * Returns the enumeration value table for class StateType
95      */

96     protected StateType JavaDoc[] getEnumValueTable()
97     {
98         return enumValueTable;
99     }
100
101     /**
102      * Return an object of the specified value.
103      * @param value a designator for the object.
104      */

105     public static StateType JavaDoc getStateType(int value)
106     { return enumValueTable[value];
107     }
108
109     /**
110      * Return the string name of this StateType or the
111      * integer value if outside the bounds of the table
112      */

113     public String JavaDoc toString()
114     {
115         String JavaDoc[] strTable = getStringTable();
116         int index = value - getOffset();
117         if (strTable != null && index >= 0 && index < strTable.length)
118             return strTable[index];
119         else
120             return Integer.toString (value);
121     }
122
123     /**
124      * Returns the lowest integer value used by this enumeration value's
125      * enumeration class.
126      * <P>
127      * The default implementation returns 0.
128      * @return the offset of the lowest enumeration value.
129      */

130     protected int getOffset()
131     { return 0;
132     }
133 }
134
Popular Tags