01: package org.obe.engine.calendar;
02:
03: import org.obe.util.AbstractEnum;
04:
05: import java.util.HashMap;
06: import java.util.List;
07: import java.util.Map;
08:
09: /**
10: * Represents ordinal numbers in the range First..Fifth.
11: */
12: public class Ordinal extends AbstractEnum {
13: public static final int FIRST_INT = 0;
14: public static final int SECOND_INT = 1;
15: public static final int THIRD_INT = 2;
16: public static final int FOURTH_INT = 3;
17: public static final int FIFTH_INT = 4;
18: public static final Ordinal FIRST = new Ordinal("First", FIRST_INT);
19: public static final Ordinal SECOND = new Ordinal("Second",
20: SECOND_INT);
21: public static final Ordinal THIRD = new Ordinal("Third", THIRD_INT);
22: public static final Ordinal FOURTH = new Ordinal("Fourth",
23: FOURTH_INT);
24: public static final Ordinal FIFTH = new Ordinal("Fifth", FIFTH_INT);
25: private static final Ordinal[] _values = { FIRST, SECOND, THIRD,
26: FOURTH, FIFTH };
27: private static final Map _tagMap = new HashMap();
28: public static final List VALUES = clinit(_values, _tagMap);
29:
30: /**
31: * Convert the specified type String to an Ordinal type object. If
32: * the specified type string can not be converted to an Ordinal
33: * object then this method will return null.
34: *
35: * @param tag The type String (PUBLIC or PRIVATE)
36: * @return The Ordinal object or null
37: */
38: public static Ordinal valueOf(String tag) {
39: Ordinal accessLevel = (Ordinal) _tagMap.get(tag);
40: if (accessLevel == null && tag != null)
41: throw new IllegalArgumentException(tag);
42: return accessLevel;
43: }
44:
45: private Ordinal(String name, int ordinal) {
46: super (name, ordinal);
47: }
48:
49: public List family() {
50: return VALUES;
51: }
52: }
|