1
2
3
4
5
6 package org.dbe.studio.tools.ontologyviewer.metamodels.odm;
7
8 import java.util.Hashtable;
9 import java.util.Vector;
10
11 /***
12 * An ontology class provides an abstraction mechanism for grouping
13 * resources with similar characteristics. Like RDF classes, every OWL
14 * class is associated with a set of individuals, called the class extension.
15 * The individuals in the class extension are called the instances of the class
16 *
17 * Two OWL class identifiers are predefined, namely the classes
18 * owl:Thing and owl:Nothing. The class extension of owl:Thing is the set of
19 * all individuals. The class extension of owl:Nothing is the empty set.
20 * Consequently, every OWL class is a subclass of owl:Thing and owl:Nothing is
21 * a subclass of every class
22 *
23 * OWL and ODM distinguishes six types of class descriptions.
24 * Each one of those types will be represented by subclasses of
25 * this abstract class
26 *
27 */
28
29 public abstract class OdmOntologyClass {
30
31 String name;
32 String id;
33 OdmOntology ontology;
34
35 Vector objectProperties;
36 Hashtable datatypeProperties;
37 Vector classExtension;
38 Vector annotationProps;
39
40 Vector subClassOf ;
41 Hashtable superClassOf;
42 Vector equivalentClasses;
43 Vector disjointWithClasses;
44
45
46 public OdmOntologyClass() {
47
48 }
49
50 public OdmOntologyClass(OdmOntology ontology) {
51
52
53 this.ontology = ontology;
54
55 if (this instanceof OdmDataRange ) {
56 this.ontology.addDataRange((OdmDataRange)this);
57 }
58 else {
59 this.ontology.addClass(this);
60 }
61 }
62
63 public OdmOntologyClass(OdmOntology ontology, String name, String id) {
64 super();
65
66 this.ontology = ontology;
67
68
69 this.name = name;
70 this.id = id;
71
72 if (this instanceof OdmDataRange ) {
73 this.ontology.addDataRange((OdmDataRange)this);
74 }
75 else {
76 this.ontology.addClass(this);
77 }
78 }
79
80 public void addObjectProperty(OdmObjectProperty p) {
81 if (objectProperties == null) {
82 objectProperties = new Vector();
83 }
84 objectProperties.add(p);
85 }
86
87 public void removeObjectProperty(OdmObjectProperty p) {
88 if (objectProperties != null) {
89 objectProperties.remove(p);
90 }
91 }
92
93 public void addDatatypeProperty(OdmDatatypeProperty p) {
94 if (datatypeProperties == null) {
95 datatypeProperties = new Hashtable();
96 }
97 datatypeProperties.put(p.getId(),p);
98 }
99
100 public void removeDatatypeProperty(OdmDatatypeProperty p) {
101 if (datatypeProperties != null) {
102 datatypeProperties.remove(p.getId());
103 }
104 }
105
106 public void addClassInstance(OdmOntologyClassInst oci) {
107 if (classExtension == null) {
108 classExtension = new Vector();
109 }
110 classExtension.add(oci);
111 }
112
113 public void removeClassInstance(OdmOntologyClassInst oci) {
114 if (classExtension != null) {
115 classExtension.remove(oci);
116 }
117 }
118
119 public void addAnnotationProp(OdmAnnotationProperty ap) {
120 if ( annotationProps == null ) {
121 annotationProps = new Vector();
122 }
123 annotationProps.add(ap);
124
125 }
126
127 public void removeAnnotationProp(OdmAnnotationProperty ap) {
128 if (annotationProps != null) {
129 annotationProps.remove(ap);
130 }
131 }
132
133 public void addEquivalentClass(OdmOntologyClass oc) {
134 if (equivalentClasses == null) {
135 equivalentClasses = new Vector();
136 }
137 equivalentClasses.add(oc);
138 }
139
140 public void removeEquivalentClass(OdmOntologyClass oc) {
141 if (equivalentClasses != null) {
142 equivalentClasses.remove(oc);
143 }
144 }
145
146 public void addSubClass(OdmOntologyClass oc) {
147 if (subClassOf == null) {
148 subClassOf = new Vector();
149 }
150 subClassOf.add(oc);
151 }
152
153 public void removeSubClass(OdmOntologyClass oc) {
154 if (subClassOf != null) {
155 subClassOf.remove(oc);
156 }
157 }
158
159 public void addSuperClass(OdmOntologyClass oc) {
160 if (superClassOf == null) {
161 superClassOf = new Hashtable();
162 }
163 superClassOf.put(oc.getId(), oc);
164 }
165
166 public void removeSuperClass(OdmOntologyClass oc) {
167 if (superClassOf != null) {
168 superClassOf.remove(oc.getId());
169 }
170 }
171
172 public void addDisjointWithClass(OdmOntologyClass oc) {
173 if (disjointWithClasses == null) {
174 disjointWithClasses = new Vector();
175 }
176 disjointWithClasses.add(oc);
177 }
178
179 public void removeDisjointWithClass(OdmOntologyClass oc) {
180 if (disjointWithClasses != null) {
181 disjointWithClasses.remove(oc);
182 }
183 }
184
185 public void setOntology(OdmOntology ontology) {
186 this.ontology = ontology;
187 }
188 public void setName(String name) {
189 this.name = name;
190 }
191
192 public void setId( String id) {
193 this.id = id;
194 }
195
196 public void setObjectProperties(Vector properties) {
197 this.objectProperties = properties;
198 }
199
200 public void setDatatypeProperties(Hashtable properties) {
201 this.datatypeProperties = properties;
202 }
203
204 public void setClassExtension(Vector ce) {
205 classExtension = ce;
206 }
207
208 public void setAnnotationProps(Vector a) {
209 annotationProps = a;
210 }
211
212 public OdmOntology getOntology() {
213 return ontology;
214 }
215
216 public String getName() {
217 return name;
218 }
219
220 public String getId() {
221 return id;
222 }
223
224 public Vector getObjectProperties() {
225 return objectProperties;
226 }
227
228 public Hashtable getDatatypeProperties() {
229 return datatypeProperties;
230 }
231
232 public OdmDatatypeProperty findDatatypeProperty (String propID){
233 return (OdmDatatypeProperty)datatypeProperties.get(propID);
234 }
235
236 public Vector getClassExtension() {
237 return classExtension;
238 }
239
240 public Vector getAnnotationProps() {
241 return annotationProps;
242 }
243
244 public Vector getSubClassOf() {
245 return subClassOf;
246 }
247
248 public Hashtable getSuperClassOf() {
249 return superClassOf;
250 }
251
252 public Vector getEquivalentClasses() {
253 return equivalentClasses;
254 }
255
256 public Vector getDisjointWithClasses() {
257 return disjointWithClasses;
258 }
259
260 }