Source code: javax/enterprise/deploy/shared/StateType.java
1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 //
19 // This source code implements specifications defined by the Java
20 // Community Process. In order to remain compliant with the specification
21 // DO NOT add / change / or delete method signatures!
22 //
23
24 package javax.enterprise.deploy.shared;
25
26 /**
27 * Defines enumeration values for the various states of a deployment action.
28 *
29 * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
30 */
31 public class StateType {
32 /**
33 * The action operation is running normally.
34 */
35 public static final StateType RUNNING = new StateType(0);
36 /**
37 * The action operation has completed normally.
38 */
39 public static final StateType COMPLETED = new StateType(1);
40 /**
41 * The action operation has failed.
42 */
43 public static final StateType FAILED = new StateType(2);
44 /**
45 * The DeploymentManager is running in disconnected mode.
46 */
47 public static final StateType RELEASED = new StateType(3);
48
49 private static final StateType[] enumValueTable = {
50 RUNNING,
51 COMPLETED,
52 FAILED,
53 RELEASED,
54 };
55
56 private static final String[] stringTable = {
57 "running",
58 "completed",
59 "failed",
60 "released",
61 };
62
63 private int value;
64
65 /**
66 * Construct a new enumeration value with the given integer value.
67 */
68 protected StateType(int value) {
69 this.value = value;
70 }
71
72 /**
73 * Returns this enumeration value's integer value.
74 */
75 public int getValue() {
76 return value;
77 }
78
79 /**
80 * Returns the string table for class StateType
81 */
82 protected String[] getStringTable() {
83 return stringTable;
84 }
85
86 /**
87 * Returns the enumeration value table for class StateType
88 */
89 protected StateType[] getEnumValueTable() {
90 return enumValueTable;
91 }
92
93 /**
94 * Return an object of the specified value.
95 *
96 * @param value a designator for the object.
97 */
98 public static StateType getStateType(int value) {
99 return enumValueTable[value];
100 }
101
102 /**
103 * Return the string name of this StateType or the integer value if
104 * outside the bounds of the table
105 */
106 public String toString() {
107 return (value >= 0 && value <= 3) ? stringTable[value] : String.valueOf(value);
108 }
109
110 /**
111 * Returns the lowest integer value used by this enumeration value's
112 * enumeration class.
113 *
114 * @return the offset of the lowest enumeration value.
115 */
116 protected int getOffset() {
117 return 0;
118 }
119 }