1 16 package org.outerj.daisy.doctaskrunner; 17 18 public class DocumentExecutionState { 19 private String name; 20 private String code; 21 22 private DocumentExecutionState(String name, String code) { 23 this.name = name; 24 this.code = code; 25 } 26 27 public String toString() { 28 return name; 29 } 30 31 public String getCode() { 32 return code; 33 } 34 35 public static DocumentExecutionState getByCode(String code) { 36 if (code.equals("W")) 37 return WAITING; 38 else if (code.equals("D")) 39 return DONE; 40 else if (code.equals("E")) 41 return ERROR; 42 else 43 throw new RuntimeException ("DocumentExecutionState: unrecognized code: \"" + code + "\""); 44 } 45 46 public static DocumentExecutionState fromString(String name) { 47 if (WAITING.name.equals(name)) 48 return WAITING; 49 else if (DONE.name.equals(name)) 50 return DONE; 51 else if (ERROR.name.equals(name)) 52 return ERROR; 53 else 54 throw new RuntimeException ("DocumentExecutionState: unrecognized name: \"" + name + "\""); 55 } 56 57 public static final DocumentExecutionState WAITING = new DocumentExecutionState("waiting", "W"); 58 public static final DocumentExecutionState DONE = new DocumentExecutionState("done", "D"); 59 public static final DocumentExecutionState ERROR = new DocumentExecutionState("error", "E"); 60 } 61 | Popular Tags |