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.repository;
17:
18: /**
19: * Enumeration of the states a {@link Version} can be in.
20: */
21: public enum VersionState {
22: DRAFT("draft", "D"), PUBLISH("publish", "P");
23:
24: private final String name;
25: private final String code;
26:
27: private VersionState(String name, String code) {
28: this .name = name;
29: this .code = code;
30: }
31:
32: public String toString() {
33: return name;
34: }
35:
36: public String getCode() {
37: return code;
38: }
39:
40: public static VersionState getByCode(String code) {
41: if (code.equals("D")) {
42: return VersionState.DRAFT;
43: } else if (code.equals("P")) {
44: return VersionState.PUBLISH;
45: } else {
46: throw new RuntimeException("Invalid VersionState code: "
47: + code);
48: }
49: }
50:
51: public static VersionState fromString(String name) {
52: if (name.equals("draft"))
53: return VersionState.DRAFT;
54: else if (name.equals("publish"))
55: return VersionState.PUBLISH;
56: else
57: throw new RuntimeException("Invalid VersionState name: "
58: + name);
59: }
60: }
|