| OClassImpl.java |
1 /*
2 * OClassImpl.java
3 *
4 * Copyright (c) 2002-2004, The University of Sheffield.
5 *
6 * This file is part of GATE (see http://gate.ac.uk/), and is free
7 * software, licenced under the GNU Library General Public License,
8 * Version 2, June1991.
9 *
10 * A copy of this licence is included in the distribution in the file
11 * licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
12 *
13 * Kalina Bontcheva 11/2003
14 *
15 *
16 * $Id: OClassImpl.java,v 1.12 2006/02/05 23:48:47 valyt Exp $
17 */
18 package gate.creole.ontology;
19
20 import java.util.HashSet;
21 import java.util.Set;
22
23 public class OClassImpl extends TClassImpl implements OClass {
24 private Set disjointClassesSet;
25 private Set sameClassesSet;
26
27 /**
28 * Creates a new class given id,name,comment and ontology.
29 *
30 * @param anId
31 * the id of the new class
32 * @param aName
33 * the name of the new class
34 * @param aComment
35 * the comment of the new class
36 * @param anOntology
37 * the ontology to which the new class belongs
38 */
39 public OClassImpl(String anId, String aName, String aComment,
40 Ontology anOntology) {
41 super(anId, aName, aComment, anOntology);
42 disjointClassesSet = new HashSet();
43 sameClassesSet = new HashSet();
44 setURI(ontology.getDefaultNameSpace() + name);
45 }
46
47 public void setDisjointWith(OClass theClass) {
48 if(theClass == null) return;
49 disjointClassesSet.add(theClass);
50 }
51
52 public void setSameClassAs(OClass theClass) {
53 if(theClass == null) return;
54 this.sameClassesSet.add(theClass);
55 }
56
57 public Set getDisjointClasses() {
58 if(this.disjointClassesSet.isEmpty()) return null;
59 return this.disjointClassesSet;
60 }
61
62 public Set getSameClasses() {
63 if(this.sameClassesSet.isEmpty()) return null;
64 return this.sameClassesSet;
65 }
66
67 public String toString() {
68 return this.getName();
69 }
70 }