01: package com.technoetic.xplanner.domain;
02:
03: import java.text.MessageFormat;
04:
05: /**
06: * Created by IntelliJ IDEA.
07: * User: sg897500
08: * Date: Aug 9, 2005
09: * Time: 11:16:08 AM
10: * To change this template use File | Settings | File Templates.
11: */
12: public class TaskDisposition extends CharacterEnum {
13:
14: boolean original;
15:
16: public static final String PLANNED_NAME = "planned";
17: public static final String CARRIED_OVER_NAME = "carriedOver";
18: public static final String DISCOVERED_NAME = "discovered";
19: public static final String ADDED_NAME = "added";
20: public static final String OVERHEAD_NAME = "overhead";
21:
22: private static final String NAME_KEY_TEMPLATE = "task.disposition.{0}.name";
23: private static final String ABBREVIATION_KEY_TEMPLATE = "task.disposition.{0}.abbreviation";
24:
25: public static final TaskDisposition PLANNED = new TaskDisposition(
26: 'p', PLANNED_NAME, true);
27: public static final TaskDisposition CARRIED_OVER = new TaskDisposition(
28: 'c', CARRIED_OVER_NAME, true);
29: public static final TaskDisposition ADDED = new TaskDisposition(
30: 'a', ADDED_NAME, false);
31: public static final TaskDisposition DISCOVERED = new TaskDisposition(
32: 'd', DISCOVERED_NAME, false);
33: public static final TaskDisposition OVERHEAD = new TaskDisposition(
34: 'o', OVERHEAD_NAME, false);
35:
36: public static final TaskDisposition[] enums = { PLANNED,
37: CARRIED_OVER, ADDED, DISCOVERED, OVERHEAD };
38:
39: TaskDisposition(char code, String name, boolean original) {
40: super (code, name);
41: this .original = original;
42: }
43:
44: public String getAbbreviationKey() {
45: return MessageFormat.format(ABBREVIATION_KEY_TEMPLATE,
46: new String[] { name });
47: }
48:
49: public String getNameKey() {
50: return MessageFormat.format(NAME_KEY_TEMPLATE,
51: new String[] { name });
52: }
53:
54: public CharacterEnum[] listEnums() {
55: return enums;
56: }
57:
58: public boolean isOriginal() {
59: return original;
60: }
61:
62: public static TaskDisposition valueOf(String key) {
63: return (TaskDisposition) valueOf(key, enums);
64: }
65:
66: public static TaskDisposition fromNameKey(String key) {
67: return (TaskDisposition) fromNameKey(key, enums);
68: }
69:
70: public static TaskDisposition fromCode(char code) {
71: return (TaskDisposition) fromCode(code, enums);
72: }
73:
74: public static TaskDisposition fromName(String name) {
75: return (TaskDisposition) fromName(name, enums);
76: }
77:
78: }
|