KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > doctaskrunner > DocumentExecutionState


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc name;
20     private String JavaDoc code;
21
22     private DocumentExecutionState(String JavaDoc name, String JavaDoc code) {
23         this.name = name;
24         this.code = code;
25     }
26
27     public String JavaDoc toString() {
28         return name;
29     }
30
31     public String JavaDoc getCode() {
32         return code;
33     }
34
35     public static DocumentExecutionState getByCode(String JavaDoc 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 JavaDoc("DocumentExecutionState: unrecognized code: \"" + code + "\"");
44     }
45
46     public static DocumentExecutionState fromString(String JavaDoc 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 JavaDoc("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