01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
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(
44: "DocumentExecutionState: unrecognized code: \""
45: + code + "\"");
46: }
47:
48: public static DocumentExecutionState fromString(String name) {
49: if (WAITING.name.equals(name))
50: return WAITING;
51: else if (DONE.name.equals(name))
52: return DONE;
53: else if (ERROR.name.equals(name))
54: return ERROR;
55: else
56: throw new RuntimeException(
57: "DocumentExecutionState: unrecognized name: \""
58: + name + "\"");
59: }
60:
61: public static final DocumentExecutionState WAITING = new DocumentExecutionState(
62: "waiting", "W");
63: public static final DocumentExecutionState DONE = new DocumentExecutionState(
64: "done", "D");
65: public static final DocumentExecutionState ERROR = new DocumentExecutionState(
66: "error", "E");
67: }
|