Skip to content

Method: ensureDatatype(OWLDataRange)

1: package cz.cvut.kbss.jopa.owl2java;
2:
3: import org.semanticweb.owlapi.model.OWLClass;
4: import org.semanticweb.owlapi.model.OWLClassExpression;
5: import org.semanticweb.owlapi.model.OWLDataProperty;
6: import org.semanticweb.owlapi.model.OWLDataPropertyExpression;
7: import org.semanticweb.owlapi.model.OWLDataRange;
8: import org.semanticweb.owlapi.model.OWLDatatype;
9: import org.semanticweb.owlapi.model.OWLObjectProperty;
10: import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
11:
12: public class Utils {
13:
14: static OWLDatatype ensureDatatype(final OWLDataRange r)
15: throws UnsupportedICException {
16:• if (!r.isDatatype()) {
17: throw new UnsupportedICException("Data ranges not supported: " + r);
18: }
19:
20:• if (!r.asOWLDatatype().isBuiltIn()) {
21: throw new UnsupportedICException(
22: "Only built in datatypes are supported: " + r);
23: }
24:
25: return r.asOWLDatatype();
26: }
27:
28: static OWLClass ensureClass(final OWLClassExpression r) {
29: if (!r.isAnonymous()) {
30: return r.asOWLClass();
31: }
32: throw new UnsupportedICException("Only named classes are supported: " + r);
33: }
34:
35: static OWLDataProperty ensureDataProperty(final OWLDataPropertyExpression e) {
36: if (e.isAnonymous()) {
37: throw new UnsupportedICException(
38: "Data property expressions not supported: " + e);
39: }
40:
41: return e.asOWLDataProperty();
42: }
43:
44: static OWLObjectProperty ensureObjectProperty(
45: final OWLObjectPropertyExpression e) throws UnsupportedICException {
46: if (e.isAnonymous()) {
47: throw new UnsupportedICException(
48: "Object property expressions not supported: " + e);
49: }
50:
51: return e.asOWLObjectProperty();
52: }
53: }