001 /*
002 * The contents of this file are subject to the Mozilla Public License
003 * Version 1.1 (the "License"); you may not use this file except in
004 * compliance with the License. You may obtain a copy of the License at
005 * http://www.mozilla.org/MPL/
006 *
007 * Software distributed under the License is distributed on an "AS IS" basis,
008 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009 * the specific language governing rights and limitations under the License.
010 *
011 * The Original Code is Protege-2000.
012 *
013 * The Initial Developer of the Original Code is Stanford University. Portions
014 * created by Stanford University are Copyright (C) 2007. All Rights Reserved.
015 *
016 * Protege was developed by Stanford Medical Informatics
017 * (http://www.smi.stanford.edu) at the Stanford University School of Medicine
018 * with support from the National Library of Medicine, the National Science
019 * Foundation, and the Defense Advanced Research Projects Agency. Current
020 * information about Protege can be obtained at http://protege.stanford.edu.
021 *
022 */
023
024 package edu.stanford.smi.protegex.owl.model.impl;
025
026 import java.util.ArrayList;
027 import java.util.Collection;
028 import java.util.Collections;
029 import java.util.HashSet;
030 import java.util.Iterator;
031 import java.util.Set;
032
033 import javax.swing.Icon;
034 import javax.swing.ImageIcon;
035
036 import edu.stanford.smi.protege.model.Cls;
037 import edu.stanford.smi.protege.model.DefaultSlot;
038 import edu.stanford.smi.protege.model.FrameID;
039 import edu.stanford.smi.protege.model.KnowledgeBase;
040 import edu.stanford.smi.protege.model.Model;
041 import edu.stanford.smi.protege.model.Slot;
042 import edu.stanford.smi.protege.model.ValueType;
043 import edu.stanford.smi.protegex.owl.model.NamespaceUtil;
044 import edu.stanford.smi.protegex.owl.model.OWLDataRange;
045 import edu.stanford.smi.protegex.owl.model.OWLModel;
046 import edu.stanford.smi.protegex.owl.model.OWLNames;
047 import edu.stanford.smi.protegex.owl.model.OWLProperty;
048 import edu.stanford.smi.protegex.owl.model.OWLUnionClass;
049 import edu.stanford.smi.protegex.owl.model.RDFObject;
050 import edu.stanford.smi.protegex.owl.model.RDFProperty;
051 import edu.stanford.smi.protegex.owl.model.RDFResource;
052 import edu.stanford.smi.protegex.owl.model.RDFSClass;
053 import edu.stanford.smi.protegex.owl.model.RDFSDatatype;
054 import edu.stanford.smi.protegex.owl.model.RDFSLiteral;
055 import edu.stanford.smi.protegex.owl.model.RDFSNamedClass;
056 import edu.stanford.smi.protegex.owl.model.event.PropertyAdapter;
057 import edu.stanford.smi.protegex.owl.model.event.PropertyListener;
058 import edu.stanford.smi.protegex.owl.model.event.PropertyValueListener;
059 import edu.stanford.smi.protegex.owl.model.event.ResourceListener;
060 import edu.stanford.smi.protegex.owl.model.visitor.OWLModelVisitor;
061 import edu.stanford.smi.protegex.owl.ui.icons.OWLIcons;
062
063 /**
064 * The default implementation of the OWLProperty interface.
065 *
066 * @author Holger Knublauch <holger@knublauch.com>
067 */
068 public class DefaultRDFProperty extends DefaultSlot implements RDFProperty {
069 private static final long serialVersionUID = 8950825871351060966L;
070
071 public DefaultRDFProperty(KnowledgeBase kb, FrameID id) {
072 super(kb, id);
073 }
074
075
076 public DefaultRDFProperty() {
077 }
078
079
080 public void addPropertyListener(PropertyListener listener) {
081 if (!(listener instanceof PropertyAdapter)) {
082 throw new IllegalArgumentException("Listener must be subclass of PropertyAdapter");
083 }
084 addSlotListener(listener);
085 }
086
087
088 public void addSuperproperty(RDFProperty superProperty) {
089 getKnowledgeBase().addDirectSuperslot(this, superProperty);
090 }
091
092
093 public void addEquivalentProperty(RDFProperty property) {
094 Slot equivalentClassesSlot = getOWLModel().getOWLEquivalentPropertyProperty();
095 addOwnSlotValue(equivalentClassesSlot, property);
096 }
097
098
099 public void addUnionDomainClass(RDFSClass domainClass) {
100 Collection directDomain = getDirectDomain();
101 if (directDomain.isEmpty() || (directDomain.size() == 1 && directDomain.contains(getOWLModel().getOWLThingClass()))) {
102 setDomain(domainClass);
103 }
104 else {
105 OWLUnionClass unionClass = getOWLModel().createOWLUnionClass(directDomain);
106 unionClass.addOperand(domainClass);
107 setDomain(unionClass);
108 }
109 // ((Cls) domainClass).addDirectTemplateSlot(this);
110 }
111
112
113 public boolean equalsStructurally(RDFObject object) {
114 return equals(object);
115 }
116
117
118 public ImageIcon getBaseImageIcon() {
119 return OWLIcons.getImageIcon(OWLIcons.RDF_PROPERTY);
120 }
121
122
123 public RDFSClass getDomain(boolean includingSuperproperties) {
124 Collection domains = getDomains(includingSuperproperties);
125 if (domains.isEmpty()) {
126 return null;
127 }
128 return (RDFSClass) domains.iterator().next();
129 }
130
131
132 public Collection getDomains(boolean includingSuperproperties) {
133 if (includingSuperproperties) {
134 Collection values = getDirectOwnSlotValues(getOWLModel().getRDFSDomainProperty());
135 if (values.isEmpty()) {
136 Collection result = new ArrayList();
137 for (Iterator it = getSuperproperties(false).iterator(); it.hasNext();) {
138 RDFProperty superproperty = (RDFProperty) it.next();
139 Collection superDomains = superproperty.getDomains(true);
140 result.addAll(superDomains);
141 }
142 return result;
143 }
144 else {
145 return values;
146 }
147 }
148 else {
149 return getDirectOwnSlotValues(getOWLModel().getRDFSDomainProperty());
150 }
151 }
152
153
154 public Collection getEquivalentProperties() {
155 Slot equivalentClassesSlot = getOWLModel().getOWLEquivalentPropertyProperty();
156 return getOwnSlotValues(equivalentClassesSlot);
157 }
158
159
160 public RDFProperty getFirstSuperproperty() {
161 return (RDFProperty) getPropertyValue(getOWLModel().getRDFSSubPropertyOfProperty());
162 }
163
164
165 public Icon getInheritedIcon() {
166 return OWLIcons.getImageIcon(OWLIcons.RDF_PROPERTY_INHERITED);
167 }
168
169
170 @Override
171 public Icon getIcon() {
172 if (isUntyped()) {
173 return isEditable() ?
174 OWLIcons.getExternalResourceIcon() :
175 OWLIcons.getReadOnlyClsIcon(OWLIcons.getExternalResourceIcon());
176 } else {
177 return isEditable() ?
178 getBaseImageIcon() :
179 OWLIcons.getReadOnlyPropertyIcon(OWLIcons.getImageIcon(OWLIcons.RDF_PROPERTY));
180 }
181
182 }
183
184 protected boolean isUntyped() {
185 return this.hasDirectType(((AbstractOWLModel)getOWLModel()).getRDFExternalPropertyClass());
186 }
187
188
189 public String getIconName() {
190 return OWLIcons.RDF_PROPERTY;
191 }
192
193
194 public RDFProperty getInverseProperty() {
195 return (RDFProperty) getKnowledgeBase().getInverseSlot(this);
196 }
197
198
199 public RDFResource getRange() {
200 return getRange(false);
201 }
202
203
204 public RDFResource getRange(boolean includingSuperproperties) {
205 Object r = getPropertyValue(getOWLModel().getRDFSRangeProperty());
206 if (r instanceof RDFResource) {
207 return (RDFResource) r;
208 }
209 else if (r == null && includingSuperproperties) {
210 for (Iterator it = getSuperproperties(false).iterator(); it.hasNext();) {
211 RDFProperty superproperty = (RDFProperty) it.next();
212 RDFResource range = superproperty.getRange(true);
213 if (range != null) {
214 return range;
215 }
216 }
217 }
218 return null;
219 }
220
221
222 public RDFSDatatype getRangeDatatype() {
223 RDFResource range = getRange();
224 if (range instanceof RDFSDatatype) {
225 return (RDFSDatatype) range;
226 }
227 else if (range instanceof OWLDataRange) {
228 return ((OWLDataRange) range).getRDFDatatype();
229 }
230 return null;
231 }
232
233
234 public Collection getRanges(boolean includingSuperproperties) {
235 Collection ranges = getPropertyValues(getOWLModel().getRDFSRangeProperty());
236 if (ranges.isEmpty() && includingSuperproperties) {
237 for (Iterator it = getSuperproperties(false).iterator(); it.hasNext();) {
238 RDFProperty superproperty = (RDFProperty) it.next();
239 ranges = superproperty.getRanges(true);
240 if (ranges != null) {
241 return ranges;
242 }
243 }
244 }
245 return ranges;
246 }
247
248
249 public Collection getSubproperties(boolean transitive) {
250 if (transitive) {
251 return getKnowledgeBase().getSubslots(this);
252 }
253 else {
254 return getKnowledgeBase().getDirectSubslots(this);
255 }
256 }
257
258
259 public int getSubpropertyCount() {
260 return getKnowledgeBase().getDirectSubslotCount(this);
261 }
262
263
264 public Collection getSuperproperties(boolean transitive) {
265 if (transitive) {
266 return getKnowledgeBase().getSuperslots(this);
267 }
268 else {
269 return getKnowledgeBase().getDirectSuperslots(this);
270 }
271 }
272
273
274 public int getSuperpropertyCount() {
275 return getKnowledgeBase().getDirectSuperslotCount(this);
276 }
277
278
279 public Collection getUnionDomain() {
280 return getKnowledgeBase().getDirectDomain(this);
281 }
282
283
284 public Collection getUnionDomain(boolean includingSuperproperties) {
285 if (includingSuperproperties) {
286 return getKnowledgeBase().getDomain(this);
287 }
288 else {
289 return getKnowledgeBase().getDirectDomain(this);
290 }
291 }
292
293
294 public Collection getUnionRangeClasses() {
295 return AbstractOWLModel.getRDFResources(getOWLModel(),
296 getKnowledgeBase().getAllowedClses(this));
297 }
298
299
300 public boolean hasDatatypeRange() {
301 RDFResource range = getRange(true);
302 return range instanceof RDFSDatatype || range instanceof OWLDataRange;
303 }
304
305
306 public boolean hasObjectRange() {
307 RDFResource range = getRange(true);
308 return range instanceof RDFSClass;
309 }
310
311
312 public boolean hasRange(boolean includingSuperproperties) {
313 Collection ranges = getRanges(includingSuperproperties);
314 return !ranges.isEmpty();
315 }
316
317
318 public boolean isSubpropertyOf(RDFProperty superProperty, boolean transitive) {
319 if (transitive) {
320 return getKnowledgeBase().hasSuperslot(this, superProperty);
321 }
322 else {
323 return getKnowledgeBase().hasDirectSuperslot(this, superProperty);
324 }
325 }
326
327
328 public boolean isAnnotationProperty() {
329 return hasProtegeType(getOWLModel().getOWLAnnotationPropertyClass());
330 }
331
332
333 public boolean isDomainDefined() {
334 Slot directDomainSlot = getOWLModel().getSystemFrames().getDirectDomainSlot();
335 Collection values = getDirectOwnSlotValues(directDomainSlot);
336 if (values.size() > 1) {
337 return true;
338 }
339 else if (values.size() == 1 && !values.contains(getOWLModel().getRootCls())) {
340 return true;
341 }
342 else if (values.size() == 1) {
343 RDFProperty rdfsDomainProperty = getOWLModel().getRDFSDomainProperty();
344 values = getDirectOwnSlotValues(rdfsDomainProperty);
345 return !values.isEmpty();
346 }
347 return false;
348 }
349
350
351 public boolean isDomainDefined(boolean transitive) {
352 if (!transitive) {
353 return isDomainDefined();
354 }
355 else {
356 return isDomainDefined(new HashSet<RDFProperty>());
357 }
358 }
359
360
361 private boolean isDomainDefined(Set<RDFProperty> reached) {
362 reached.add(this);
363 if (isDomainDefined()) {
364 return true;
365 }
366 else {
367 for (Iterator it = getDirectSuperslots().iterator(); it.hasNext();) {
368 Slot superSlot = (Slot) it.next();
369 if (!reached.contains(superSlot) && superSlot instanceof DefaultRDFProperty) {
370 if (((DefaultRDFProperty) superSlot).isDomainDefined(reached)) {
371 return true;
372 }
373 }
374 }
375 return false;
376 }
377 }
378
379
380 public boolean isFunctional() {
381 if (hasProtegeType(getOWLModel().getOWLFunctionalPropertyClass())) {
382 return true;
383 }
384 for (Iterator it = getSuperproperties(false).iterator(); it.hasNext();) {
385 RDFProperty property = (RDFProperty) it.next();
386 if (property.isFunctional()) {
387 return true;
388 }
389 }
390 return false;
391 }
392
393
394 public boolean isRangeDefined() {
395 return getDirectOwnSlotValue(getKnowledgeBase().getSlot(Model.Slot.VALUE_TYPE)) != null;
396 }
397
398
399 public boolean isReadOnly() {
400 Slot readOnlySlot = ((OWLModel) getKnowledgeBase()).getProtegeReadOnlyProperty();
401 if (readOnlySlot != null) {
402 Object value = getDirectOwnSlotValue(readOnlySlot);
403 return Boolean.TRUE.equals(value);
404 }
405 return false;
406 }
407
408
409 public void removeEquivalentProperty(OWLProperty property) {
410 Slot equivalentClassesSlot = getOWLModel().getOWLEquivalentPropertyProperty();
411 removeOwnSlotValue(equivalentClassesSlot, property);
412 }
413
414
415 public void removePropertyListener(PropertyListener listener) {
416 if (!(listener instanceof PropertyAdapter)) {
417 throw new IllegalArgumentException("Listener must be subclass of PropertyAdapter");
418 }
419 removeSlotListener(listener);
420 }
421
422
423 public void removeSuperproperty(RDFProperty property) {
424 getKnowledgeBase().removeDirectSuperslot(this, property);
425 }
426
427
428 public void removeUnionDomainClass(RDFSClass domainClass) {
429 Collection directDomain = new ArrayList(getDirectDomain());
430 directDomain.remove(domainClass);
431 if (directDomain.isEmpty()) {
432 RDFSClass owlThing = domainClass.getOWLModel().getOWLThingClass();
433 if ((domainClass != owlThing) &&
434 (getSuperpropertyCount() == 0)) {
435 setDomain(owlThing);
436 }
437 else {
438 setDomain(null);
439 }
440 }
441 else if (directDomain.size() == 1) {
442 setDomain((RDFSClass) directDomain.iterator().next());
443 }
444 else {
445 OWLUnionClass unionClass = getOWLModel().createOWLUnionClass(directDomain);
446 setDomain(unionClass);
447 }
448 // ((Cls) domainClass).removeDirectTemplateSlot(this);
449 }
450
451
452 public void setDomainDefined(boolean value) {
453 if (value != isDomainDefined()) {
454 if (!value) {
455 setDomain(null);
456 }
457 else {
458 if (getSuperpropertyCount() > 0) {
459 setDomain(null);
460 }
461 else {
462 setDomain(getOWLModel().getOWLThingClass());
463 }
464 }
465 }
466 }
467
468
469 public void setEquivalentProperties(Collection slots) {
470 Slot equivalentClassesSlot = getOWLModel().getOWLEquivalentPropertyProperty();
471 setOwnSlotValues(equivalentClassesSlot, slots);
472 }
473
474
475 public void setFunctional(boolean value) {
476 updateRDFType(value, getOWLModel().getOWLFunctionalPropertyClass());
477 }
478
479
480 public void setInverseProperty(RDFProperty inverseProperty) {
481 getKnowledgeBase().setInverseSlot(this, inverseProperty);
482 }
483
484
485 public void setRange(RDFResource range) {
486 setPropertyValue(getOWLModel().getRDFSRangeProperty(), range);
487 }
488
489
490 public void setRanges(Collection ranges) {
491 setPropertyValues(getOWLModel().getRDFSRangeProperty(), ranges);
492 }
493
494
495 public void setRDFTypeOfSubproperties(RDFSNamedClass type) {
496 getKnowledgeBase().setDirectTypeOfSubslots(this, type);
497 }
498
499
500 public void setUnionRangeClasses(Collection classes) {
501 RDFResource newRange = null;
502 if (classes.size() == 1) {
503 newRange = (RDFResource) classes.iterator().next();
504 }
505 else if (classes.size() > 1) {
506 newRange = getOWLModel().createOWLUnionClass(classes);
507 }
508 setRange(newRange);
509 }
510
511 protected void updateRDFType(boolean value, RDFSClass metaclass) {
512 if (hasProtegeType(metaclass) != value) {
513 if (value) {
514 addProtegeType(metaclass);
515 }
516 else {
517 removeProtegeType(metaclass);
518 }
519 }
520 }
521
522 // RDFResource implementation methods --------------------------------------------------------
523
524
525 public void addComment(String comment) {
526 OWLUtil.addComment(this, comment);
527 }
528
529
530 public void addDifferentFrom(RDFResource resource) {
531 OWLUtil.addDifferentFrom(this, resource);
532 }
533
534
535 public void addIsDefinedBy(RDFResource instance) {
536 OWLUtil.addIsDefinedBy(this, instance);
537 }
538
539
540 public void addLabel(String label, String language) {
541 OWLUtil.addLabel(this, label, language);
542 }
543
544
545 public void addPropertyValue(RDFProperty property, Object value) {
546 OWLUtil.addPropertyValue(this, property, value);
547 }
548
549
550 public void addPropertyValueListener(PropertyValueListener listener) {
551 OWLUtil.addPropertyValueListener(this, listener);
552 }
553
554
555 public void addProtegeType(RDFSClass type) {
556 OWLUtil.addProtegeType(this, type);
557 }
558
559
560 public void addRDFType(RDFSClass type) {
561 OWLUtil.addRDFType(this, type);
562 }
563
564
565 public void addResourceListener(ResourceListener listener) {
566 OWLUtil.addResourceListener(this, listener);
567 }
568
569
570 public void addSameAs(RDFResource resource) {
571 OWLUtil.addSameAs(this, resource);
572 }
573
574
575 public void addVersionInfo(String versionInfo) {
576 OWLUtil.addVersionInfo(this, versionInfo);
577 }
578
579
580 public RDFResource as(Class javaInterface) {
581 return OWLUtil.as(this, javaInterface);
582 }
583
584
585 public boolean canAs(Class javaInterface) {
586 return OWLUtil.canAs(this, javaInterface);
587 }
588
589
590 public RDFResource getAllValuesFromOnTypes(RDFProperty property) {
591 return OWLUtil.getAllValuesFromOnTypes(this, property);
592 }
593
594
595 public Collection getComments() {
596 return OWLUtil.getComments(this);
597 }
598
599
600 public Collection getDifferentFrom() {
601 return OWLUtil.getDifferentFrom(this);
602 }
603
604
605 public Collection getHasValuesOnTypes(RDFProperty property) {
606 return OWLUtil.getHasValuesOnTypes(this, property);
607 }
608
609
610 public Class getIconLocation() {
611 return OWLIcons.class;
612 }
613
614
615 public RDFSClass getProtegeType() {
616 return OWLUtil.getDirectRDFType(this);
617 }
618
619
620 public Collection getProtegeTypes() {
621 return OWLUtil.getDirectRDFTypes(this);
622 }
623
624
625 @Override
626 public Collection getDocumentation() {
627 return OWLUtil.getComments(this);
628 }
629
630
631 public Collection getInferredTypes() {
632 return OWLUtil.getInferredDirectTypes(this);
633 }
634
635
636 public Collection getIsDefinedBy() {
637 return OWLUtil.getIsDefinedBy(this);
638 }
639
640
641 public Collection getLabels() {
642 return OWLUtil.getLabels(this);
643 }
644
645
646 public String getLocalName() {
647 return NamespaceUtil.getLocalName(getName());
648 }
649
650 public String getPrefixedName() {
651 return NamespaceUtil.getPrefixedName(getOWLModel(), getName());
652 }
653
654 public String getNamespace() {
655 return NamespaceUtil.getNameSpace(getName());
656 }
657
658
659 public String getNamespacePrefix() {
660 return NamespaceUtil.getPrefixForResourceName(getOWLModel(), getName());
661 }
662
663
664 public OWLModel getOWLModel() {
665 return (OWLModel) getKnowledgeBase();
666 }
667
668
669 public Collection getPossibleRDFProperties() {
670 return OWLUtil.getPossibleRDFProperties(this);
671 }
672
673
674 public Object getPropertyValue(RDFProperty property) {
675 return OWLUtil.getPropertyValue(this, property, false);
676 }
677
678
679 public RDFResource getPropertyValueAs(RDFProperty property, Class javaInterface) {
680 return OWLUtil.getPropertyValueAs(this, property, javaInterface);
681 }
682
683
684 public Object getPropertyValue(RDFProperty property, boolean includingSubproperties) {
685 return OWLUtil.getPropertyValue(this, property, includingSubproperties);
686 }
687
688
689 public int getPropertyValueCount(RDFProperty property) {
690 return OWLUtil.getPropertyValueCount(this, property);
691 }
692
693
694 public RDFSLiteral getPropertyValueLiteral(RDFProperty property) {
695 return OWLUtil.getPropertyValueLiteral(this, property);
696 }
697
698
699 public Collection getPropertyValueLiterals(RDFProperty property) {
700 return OWLUtil.getPropertyValueLiterals(this, property);
701 }
702
703
704 public Collection getPropertyValues(RDFProperty property) {
705 return OWLUtil.getPropertyValues(this, property, false);
706 }
707
708
709 public Collection getPropertyValuesAs(RDFProperty property, Class javaInterface) {
710 return OWLUtil.getPropertyValuesAs(this, property, javaInterface);
711 }
712
713
714 public Collection getPropertyValues(RDFProperty property, boolean includingSubproperties) {
715 return OWLUtil.getPropertyValues(this, property, includingSubproperties);
716 }
717
718
719 public Collection getRDFProperties() {
720 return OWLUtil.getRDFProperties(this);
721 }
722
723
724 public RDFSClass getRDFType() {
725 return OWLUtil.getRDFType(this);
726 }
727
728
729 public Collection getRDFTypes() {
730 return OWLUtil.getRDFTypes(this);
731 }
732
733
734 public Set getReferringAnonymousClasses() {
735 return OWLUtil.getReferringAnonymousClses(this);
736 }
737
738
739 public Collection getSameAs() {
740 return OWLUtil.getSameAs(this);
741 }
742
743
744 public String getURI() {
745 return getName();
746 }
747
748
749 public Collection getVersionInfo() {
750 return OWLUtil.getVersionInfo(this);
751 }
752
753
754 public boolean hasPropertyValue(RDFProperty property) {
755 return OWLUtil.hasPropertyValue(this, property);
756 }
757
758
759 public boolean hasPropertyValue(RDFProperty property, boolean includingSubproperties) {
760 return OWLUtil.hasPropertyValue(this, property, includingSubproperties);
761 }
762
763
764 public boolean hasPropertyValue(RDFProperty property, Object value) {
765 return hasPropertyValue(property, value, false);
766 }
767
768
769 public boolean hasPropertyValue(RDFProperty property, Object value, boolean includingSuperproperties) {
770 return OWLUtil.hasPropertyValue(this, property, value, includingSuperproperties);
771 }
772
773
774 public boolean hasProtegeType(RDFSClass type) {
775 return OWLUtil.hasProtegeType(this, type);
776 }
777
778
779 public boolean hasProtegeType(RDFSClass type, boolean includingSuperclasses) {
780 return OWLUtil.hasProtegeType(this, type, includingSuperclasses);
781 }
782
783
784 public boolean hasRDFType(RDFSClass type) {
785 return OWLUtil.hasRDFType(this, type);
786 }
787
788
789 public boolean hasRDFType(RDFSClass type, boolean includingSuperclasses) {
790 return OWLUtil.hasRDFType(this, type, includingSuperclasses);
791 }
792
793
794 public boolean isAnonymous() {
795 return getOWLModel().isAnonymousResourceName(getName());
796 }
797
798
799 public boolean isValidPropertyValue(RDFProperty property, Object object) {
800 return OWLUtil.isValidPropertyValue(this, property, object);
801 }
802
803
804 public Iterator listPropertyValues(RDFProperty property) {
805 return OWLUtil.listPropertyValues(this, property, false);
806 }
807
808
809 public Iterator listPropertyValuesAs(RDFProperty property, Class javaInterface) {
810 return OWLUtil.listPropertyValuesAs(this, property, javaInterface);
811 }
812
813
814 public Iterator listPropertyValues(RDFProperty property, boolean includingSubproperties) {
815 return OWLUtil.listPropertyValues(this, property, includingSubproperties);
816 }
817
818
819 public Iterator listRDFTypes() {
820 return getRDFTypes().iterator();
821 }
822
823
824 public void removeComment(String value) {
825 OWLUtil.removeComment(this, value);
826 }
827
828
829 public void removeDifferentFrom(RDFResource resource) {
830 OWLUtil.removeDifferentFrom(this, resource);
831 }
832
833
834 public void removeIsDefinedBy(RDFResource resource) {
835 OWLUtil.removeIsDefinedBy(this, resource);
836 }
837
838
839 public void removeLabel(String label, String language) {
840 OWLUtil.removeLabel(this, label, language);
841 }
842
843
844 public void removePropertyValue(RDFProperty property, Object value) {
845 OWLUtil.removePropertyValue(this, property, value);
846 }
847
848
849 public void removePropertyValueListener(PropertyValueListener listener) {
850 OWLUtil.removePropertyValueListener(this, listener);
851 }
852
853
854 public void removeProtegeType(RDFSClass type) {
855 OWLUtil.removeProtegeType(this, type);
856 }
857
858
859 public void removeRDFType(RDFSClass type) {
860 OWLUtil.removeRDFType(this, type);
861 }
862
863
864 public void removeResourceListener(ResourceListener listener) {
865 OWLUtil.removeResourceListener(this, listener);
866 }
867
868
869 public void removeSameAs(RDFResource resource) {
870 OWLUtil.removeSameAs(this, resource);
871 }
872
873
874 public void removeVersionInfo(String versionInfo) {
875 OWLUtil.removeVersionInfo(this, versionInfo);
876 }
877
878
879 public void setComment(String comment) {
880 OWLUtil.setComment(this, comment);
881 }
882
883
884 public void setComments(Collection comments) {
885 OWLUtil.setComments(this, comments);
886 }
887
888
889 public void setDomain(RDFSClass domainClass) {
890 if (domainClass == null) {
891 setDomains(Collections.EMPTY_LIST);
892 }
893 else {
894 setDomains(Collections.singleton(domainClass));
895 }
896 }
897
898
899 public void setDomains(Collection domainClasses) {
900 setDirectOwnSlotValues(getOWLModel().getRDFSDomainProperty(), domainClasses);
901 }
902
903
904 public void setInferredTypes(Collection types) {
905 OWLUtil.setInferredTypes(this, types);
906 }
907
908
909 @Override
910 public void setDocumentation(String value) {
911 OWLUtil.setComment(this, value);
912 }
913
914
915 public void setPropertyValue(RDFProperty property, Object value) {
916 OWLUtil.setPropertyValue(this, property, value);
917 }
918
919
920 public void setPropertyValues(RDFProperty property, Collection values) {
921 OWLUtil.setPropertyValues(this, property, values);
922 }
923
924
925 public void setProtegeType(RDFSClass type) {
926 OWLUtil.setProtegeType(this, type);
927 }
928
929
930 public void setProtegeTypes(Collection types) {
931 OWLUtil.setProtegeTypes(this, types);
932 }
933
934
935 public void setRDFType(RDFSClass type) {
936 OWLUtil.setRDFType(this, type);
937 }
938
939
940 public void setRDFTypes(Collection types) {
941 OWLUtil.setRDFTypes(this, types);
942 }
943
944 // Deprecatable -----------------------------------------------------------
945
946
947 public boolean isDeprecated() {
948 RDFSClass c = getOWLModel().getRDFSNamedClass(OWLNames.Cls.DEPRECATED_PROPERTY);
949 return getProtegeTypes().contains(c);
950 }
951
952
953 public void setDeprecated(boolean value) {
954 if (isDeprecated() != value) {
955 RDFSClass c = getOWLModel().getRDFSNamedClass(OWLNames.Cls.DEPRECATED_PROPERTY);
956 if (value) {
957 addProtegeType(c);
958 }
959 else {
960 removeProtegeType(c);
961 }
962 }
963 }
964
965
966 public void accept(OWLModelVisitor visitor) {
967 visitor.visitRDFProperty(this);
968 }
969
970 @Override
971 public String toString() {
972 StringBuffer buffer = new StringBuffer();
973 buffer.append(this.getClass().getSimpleName());
974 buffer.append("(");
975 buffer.append(getName());
976 buffer.append(")");
977 return buffer.toString();
978 }
979
980 }
981