1
2
3
4 package org.rcfaces.core.internal.contentAccessor;
5
6 import java.util.ArrayList;
7 import java.util.Iterator;
8 import java.util.List;
9
10 import org.rcfaces.core.lang.IContentFamily;
11
12
13
14
15
16
17 public class ContentFamilies {
18 private static int ORDINAL;
19
20 private static final List contentFamilies = new ArrayList(8);
21
22 public static IContentFamily getContentFamillyByOrdinal(int ordinal) {
23
24 for (Iterator it = contentFamilies.iterator(); it.hasNext();) {
25 IContentFamily contentFamily = (IContentFamily) it.next();
26
27 if (contentFamily.getOrdinal() == ordinal) {
28 return contentFamily;
29 }
30 }
31
32 return null;
33 }
34
35
36
37
38
39
40 public static class ContentTypeImpl implements IContentFamily {
41 private static final String REVISION = "$Revision: 1.2 $";
42
43 private final String id;
44
45 private final int ordinal;
46
47 public ContentTypeImpl(String id) {
48 this.id = id;
49 this.ordinal = ORDINAL++;
50
51 contentFamilies.add(this);
52 }
53
54 public String toString() {
55 return "[Content type: " + id + " ordinal='" + ordinal + "]";
56 }
57
58 public final int getOrdinal() {
59 return ordinal;
60 }
61
62 public int hashCode() {
63 return ordinal;
64 }
65
66 public boolean equals(Object obj) {
67 if (this == obj) {
68 return true;
69 }
70
71 if (obj == null || getClass() != obj.getClass()) {
72 return false;
73 }
74
75 final ContentTypeImpl other = (ContentTypeImpl) obj;
76
77 return this.ordinal == other.ordinal;
78 }
79
80 }
81
82 }