1 package org.oddjob.state; 2 3 import java.io.ObjectStreamException ; 4 import java.io.Serializable ; 5 6 7 12 13 public class JobState implements Serializable { 14 private static final long serialVersionUID = 20050926; 15 16 20 public final static JobState READY = new JobState("READY"); 21 22 25 public final static JobState EXECUTING = new JobState("EXECUTING"); 26 27 30 public final static JobState COMPLETE = new JobState("COMPLETE"); 31 32 37 public final static JobState NOT_COMPLETE = new JobState("NOT COMPLETE"); 38 39 43 public final static JobState EXCEPTION = new JobState("EXCEPTION"); 44 45 48 private final String text; 49 50 private static int nextOrdinal = 0; 51 52 private final int ordinal = nextOrdinal++; 53 54 private static final JobState[] allValues = { 55 READY, EXECUTING, 56 COMPLETE, NOT_COMPLETE, 57 EXCEPTION }; 58 59 64 65 private JobState(String text) { 66 67 this.text = text; 68 } 69 70 73 74 public String toString() { 75 76 return text; 77 } 78 79 private Object readResolve() throws ObjectStreamException { 80 81 return allValues[ordinal]; 82 } 83 84 90 public static JobState stateFor(String state) { 91 state = state.toUpperCase(); 92 for (int i = 0; i < allValues.length; ++i) { 93 if (allValues[i].text.equals(state)) { 94 return allValues[i]; 95 } 96 } 97 return null; 98 } 99 } 100 101 | Popular Tags |