1
18 package gate.creole.ontology;
19
20 import java.util.HashSet;
21 import java.util.Iterator;
22 import java.util.Set;
23 import com.ontotext.gate.ontology.OntologyImpl;
24
25 public class ObjectPropertyImpl extends PropertyImpl implements ObjectProperty {
26 protected Set inversePropertiesSet;
27
28
41 public ObjectPropertyImpl(String name, String comment, OClass aDomainClass,
42 OClass aRange, Ontology anOntology) {
43 super(name, comment, aDomainClass, aRange, anOntology);
44 inversePropertiesSet = new HashSet();
45 }
46
47
61 public ObjectPropertyImpl(String name, String comment, Set aDomain,
62 Set aRange, Ontology anOntology) {
63 super(name, comment, aDomain, aRange, anOntology);
64 inversePropertiesSet = new HashSet();
65 }
66
67 public void addSuperProperty(Property property) {
68 super.addSuperProperty(property);
69 range.addAll(property.getRange());
71 OntologyImpl.reduceToMostSpecificClasses(range);
72 Iterator subPropIter = getSubProperties(TRANSITIVE_CLOSURE).iterator();
74 while(subPropIter.hasNext()) {
75 Property aSubProperty = (Property)subPropIter.next();
76 if(aSubProperty instanceof ObjectPropertyImpl) {
77 ((ObjectPropertyImpl)aSubProperty).recalculateRange();
78 }
79 }
80 }
81
82
87 public boolean isValidRange(OInstance instance) {
88 return super.isValidRange(instance);
89 }
90
91 public Set getRange() {
92 return range;
93 }
94
95 public Set getInverseProperties() {
96 return this.inversePropertiesSet;
97 }
98
99 public void setInverseOf(Property theInverse) {
100 this.inversePropertiesSet.add(theInverse);
101 }
102 }