1 23 24 package javax.enterprise.deploy.shared; 25 26 32 public class StateType 33 { 34 private int value; 36 39 public static final StateType RUNNING = new StateType (0); 40 43 public static final StateType COMPLETED = new StateType (1); 44 47 public static final StateType FAILED = new StateType (2); 48 51 public static final StateType RELEASED = new StateType (3); 52 53 54 private static final String [] stringTable = { 55 "running", 56 "completed", 57 "failed", 58 "released", 59 }; 60 61 private static final StateType [] enumValueTable = { 62 RUNNING, 63 COMPLETED, 64 FAILED, 65 RELEASED, 66 }; 67 68 73 protected StateType(int value) 74 { this.value = value; 75 } 76 77 81 public int getValue() 82 { return value; 83 } 84 85 88 protected String [] getStringTable() 89 { 90 return stringTable; 91 } 92 93 96 protected StateType [] getEnumValueTable() 97 { 98 return enumValueTable; 99 } 100 101 105 public static StateType getStateType(int value) 106 { return enumValueTable[value]; 107 } 108 109 113 public String toString() 114 { 115 String [] 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 130 protected int getOffset() 131 { return 0; 132 } 133 } 134 | Popular Tags |