1 23 24 package javax.enterprise.deploy.shared; 25 26 32 public class CommandType 33 { 34 private int value; 36 40 public static final CommandType DISTRIBUTE = new CommandType (0); 41 44 public static final CommandType START = new CommandType (1); 45 48 public static final CommandType STOP = new CommandType (2); 49 52 public static final CommandType UNDEPLOY = new CommandType (3); 53 56 public static final CommandType REDEPLOY = new CommandType (4); 57 58 59 private static final String [] stringTable = { 60 "distribute", 61 "start", 62 "stop", 63 "undeploy", 64 "redeploy", 65 }; 66 67 private static final CommandType [] enumValueTable = { 68 DISTRIBUTE, 69 START, 70 STOP, 71 UNDEPLOY, 72 REDEPLOY, 73 }; 74 75 80 protected CommandType(int value) 81 { 82 this.value = value; 83 } 84 85 89 public int getValue() 90 { return value; 91 } 92 93 96 protected String [] getStringTable() 97 { 98 return stringTable; 99 } 100 101 104 protected CommandType [] getEnumValueTable() 105 { 106 return enumValueTable; 107 } 108 109 113 public static CommandType getCommandType(int value) 114 { return enumValueTable[value]; 115 } 116 117 121 public String toString() 122 { 123 String [] 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 138 protected int getOffset() 139 { return 0; 140 } 141 142 } 143 | Popular Tags |