1 19 20 package com.hp.hpl.jena.ontology.impl; 23 24 25 import com.hp.hpl.jena.vocabulary.*; 28 import com.hp.hpl.jena.enhanced.*; 29 import com.hp.hpl.jena.graph.*; 30 import com.hp.hpl.jena.ontology.*; 31 import com.hp.hpl.jena.rdf.model.*; 32 33 import java.util.*; 34 35 36 37 46 public class OWLProfile 47 extends AbstractProfile 48 { 49 52 53 56 57 60 61 64 public String NAMESPACE() { return OWL.getURI(); } 65 66 public Resource CLASS() { return OWL.Class; } 67 public Resource RESTRICTION() { return OWL.Restriction; } 68 public Resource THING() { return OWL.Thing; } 69 public Resource NOTHING() { return OWL.Nothing; } 70 public Resource PROPERTY() { return RDF.Property; } 71 public Resource OBJECT_PROPERTY() { return OWL.ObjectProperty; } 72 public Resource DATATYPE_PROPERTY() { return OWL.DatatypeProperty; } 73 public Resource TRANSITIVE_PROPERTY() { return OWL.TransitiveProperty; } 74 public Resource SYMMETRIC_PROPERTY() { return OWL.SymmetricProperty; } 75 public Resource FUNCTIONAL_PROPERTY() { return OWL.FunctionalProperty; } 76 public Resource INVERSE_FUNCTIONAL_PROPERTY() { return OWL.InverseFunctionalProperty; } 77 public Resource ALL_DIFFERENT() { return OWL.AllDifferent; } 78 public Resource ONTOLOGY() { return OWL.Ontology; } 79 public Resource DEPRECATED_CLASS() { return OWL.DeprecatedClass; } 80 public Resource DEPRECATED_PROPERTY() { return OWL.DeprecatedProperty; } 81 public Resource ANNOTATION_PROPERTY() { return OWL.AnnotationProperty; } 82 public Resource ONTOLOGY_PROPERTY() { return OWL.OntologyProperty; } 83 public Resource LIST() { return RDF.List; } 84 public Resource NIL() { return RDF.nil; } 85 public Resource DATARANGE() { return OWL.DataRange; } 86 87 88 public Property EQUIVALENT_PROPERTY() { return OWL.equivalentProperty; } 89 public Property EQUIVALENT_CLASS() { return OWL.equivalentClass; } 90 public Property DISJOINT_WITH() { return OWL.disjointWith; } 91 public Property SAME_INDIVIDUAL_AS() { return null; } 92 public Property SAME_AS() { return OWL.sameAs; } 93 public Property DIFFERENT_FROM() { return OWL.differentFrom; } 94 public Property DISTINCT_MEMBERS() { return OWL.distinctMembers; } 95 public Property UNION_OF() { return OWL.unionOf; } 96 public Property INTERSECTION_OF() { return OWL.intersectionOf; } 97 public Property COMPLEMENT_OF() { return OWL.complementOf; } 98 public Property ONE_OF() { return OWL.oneOf; } 99 public Property ON_PROPERTY() { return OWL.onProperty; } 100 public Property ALL_VALUES_FROM() { return OWL.allValuesFrom; } 101 public Property HAS_VALUE() { return OWL.hasValue; } 102 public Property SOME_VALUES_FROM() { return OWL.someValuesFrom; } 103 public Property MIN_CARDINALITY() { return OWL.minCardinality; } 104 public Property MAX_CARDINALITY() { return OWL.maxCardinality; } 105 public Property CARDINALITY() { return OWL.cardinality; } 106 public Property INVERSE_OF() { return OWL.inverseOf; } 107 public Property IMPORTS() { return OWL.imports; } 108 public Property PRIOR_VERSION() { return OWL.priorVersion; } 109 public Property BACKWARD_COMPATIBLE_WITH() { return OWL.backwardCompatibleWith; } 110 public Property INCOMPATIBLE_WITH() { return OWL.incompatibleWith; } 111 public Property SUB_PROPERTY_OF() { return RDFS.subPropertyOf; } 112 public Property SUB_CLASS_OF() { return RDFS.subClassOf; } 113 public Property DOMAIN() { return RDFS.domain; } 114 public Property RANGE() { return RDFS.range; } 115 public Property FIRST() { return RDF.first; } 116 public Property REST() { return RDF.rest; } 117 public Property MIN_CARDINALITY_Q() { return null; } public Property MAX_CARDINALITY_Q() { return null; } 119 public Property CARDINALITY_Q() { return null; } 120 public Property HAS_CLASS_Q() { return null; } 121 122 public Property VERSION_INFO() { return OWL.versionInfo; } 124 public Property LABEL() { return RDFS.label; } 125 public Property COMMENT() { return RDFS.comment; } 126 public Property SEE_ALSO() { return RDFS.seeAlso; } 127 public Property IS_DEFINED_BY() { return RDFS.isDefinedBy; } 128 129 130 protected Resource[][] aliasTable() { 131 return new Resource[][] { 132 }; 133 } 134 135 136 public Iterator getAxiomTypes() { 137 return Arrays.asList( 138 new Resource[] { 139 OWL.AllDifferent 140 } 141 ).iterator(); 142 } 143 144 145 public Iterator getAnnotationProperties() { 146 return Arrays.asList( 147 new Resource[] { 148 OWL.versionInfo, 149 RDFS.label, 150 RDFS.seeAlso, 151 RDFS.comment, 152 RDFS.isDefinedBy 153 } 154 ).iterator(); 155 } 156 157 public Iterator getClassDescriptionTypes() { 158 return Arrays.asList( 159 new Resource[] { 160 OWL.Class, 161 OWL.Restriction 162 } 163 ).iterator(); 164 } 165 166 167 182 public boolean isSupported( Node n, EnhGraph g, Class type ) { 183 if (g instanceof OntModel) { 184 OntModel m = (OntModel) g; 185 186 if (!m.strictMode()) { 187 return true; 189 } 190 else { 191 SupportsCheck check = (SupportsCheck) getCheckTable().get( type ); 193 194 return (check != null) && check.doCheck( n, g ); 196 } 197 } 198 else { 199 return false; 200 } 201 } 202 203 209 public String getLabel() { 210 return "OWL Full"; 211 } 212 213 216 217 221 222 protected static class SupportsCheck 223 { 224 public boolean doCheck( Node n, EnhGraph g ) { 225 return true; 226 } 227 } 228 229 230 233 private static Object [][] s_supportsCheckData = new Object [][] { 234 { AllDifferent.class, new SupportsCheck() { 236 public boolean doCheck( Node n, EnhGraph g ) { 237 return g.asGraph().contains( n, RDF.type.asNode(), OWL.AllDifferent.asNode() ); 238 } 239 } 240 }, 241 { AnnotationProperty.class, new SupportsCheck() { 242 public boolean doCheck( Node n, EnhGraph g ) { 243 for (Iterator i = ((OntModel) g).getProfile().getAnnotationProperties(); i.hasNext(); ) { 244 if (((Resource) i.next()).asNode().equals( n )) { 245 return true; 247 } 248 } 249 return g.asGraph().contains( n, RDF.type.asNode(), OWL.AnnotationProperty.asNode() ); 250 } 251 } 252 }, 253 { OntClass.class, new SupportsCheck() { 254 public boolean doCheck( Node n, EnhGraph g ) { 255 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Class.asNode() ) || 256 g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) || 257 g.asGraph().contains( n, RDF.type.asNode(), RDFS.Class.asNode() ) || 258 n.equals( OWL.Thing.asNode() ) || 260 n.equals( OWL.Nothing.asNode() ) || 261 g.asGraph().contains( Node.ANY, RDFS.domain.asNode(), n ) || 262 g.asGraph().contains( Node.ANY, RDFS.range.asNode(), n ) 263 ; 264 } 265 } 266 }, 267 { DatatypeProperty.class, new SupportsCheck() { 268 public boolean doCheck( Node n, EnhGraph g ) { 269 return g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 270 } 271 } 272 }, 273 { ObjectProperty.class, new SupportsCheck() { 274 public boolean doCheck( Node n, EnhGraph g ) { 275 return g.asGraph().contains( n, RDF.type.asNode(), OWL.ObjectProperty.asNode() ) || 276 g.asGraph().contains( n, RDF.type.asNode(), OWL.TransitiveProperty.asNode() ) || 277 g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) || 278 g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ) 279 ; 280 } 281 } 282 }, 283 { FunctionalProperty.class, new SupportsCheck() { 284 public boolean doCheck( Node n, EnhGraph g ) { 285 return g.asGraph().contains( n, RDF.type.asNode(), OWL.FunctionalProperty.asNode() ); 286 } 287 } 288 }, 289 { InverseFunctionalProperty.class, new SupportsCheck() { 290 public boolean doCheck( Node n, EnhGraph g ) { 291 return g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ); 292 } 293 } 294 }, 295 { RDFList.class, new SupportsCheck() { 296 public boolean doCheck( Node n, EnhGraph g ) { 297 return n.equals( RDF.nil.asNode() ) || 298 g.asGraph().contains( n, RDF.type.asNode(), RDF.List.asNode() ); 299 } 300 } 301 }, 302 { OntProperty.class, new SupportsCheck() { 303 public boolean doCheck( Node n, EnhGraph g ) { 304 return g.asGraph().contains( n, RDF.type.asNode(), RDF.Property.asNode() ) || 305 g.asGraph().contains( n, RDF.type.asNode(), OWL.ObjectProperty.asNode() ) || 306 g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ) || 307 g.asGraph().contains( n, RDF.type.asNode(), OWL.AnnotationProperty.asNode() ) || 308 g.asGraph().contains( n, RDF.type.asNode(), OWL.TransitiveProperty.asNode() ) || 309 g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) || 310 g.asGraph().contains( n, RDF.type.asNode(), OWL.FunctionalProperty.asNode() ) || 311 g.asGraph().contains( n, RDF.type.asNode(), OWL.InverseFunctionalProperty.asNode() ); 312 } 313 } 314 }, 315 { Ontology.class, new SupportsCheck() { 316 public boolean doCheck( Node n, EnhGraph g ) { 317 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Ontology.asNode() ); 318 } 319 } 320 }, 321 { Restriction.class, new SupportsCheck() { 322 public boolean doCheck( Node n, EnhGraph g ) { 323 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ); 324 } 325 } 326 }, 327 { HasValueRestriction.class, new SupportsCheck() { 328 public boolean doCheck( Node n, EnhGraph g ) { 329 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 330 containsSome( g,n, OWL.hasValue ) && 331 containsSome( g,n, OWL.onProperty ); 332 } 333 } 334 }, 335 { AllValuesFromRestriction.class, new SupportsCheck() { 336 public boolean doCheck( Node n, EnhGraph g ) { 337 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 338 containsSome( g, n, OWL.allValuesFrom ) && 339 containsSome( g, n, OWL.onProperty ); 340 } 341 } 342 }, 343 { SomeValuesFromRestriction.class, new SupportsCheck() { 344 public boolean doCheck( Node n, EnhGraph g ) { 345 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 346 containsSome( g,n, OWL.someValuesFrom ) && 347 containsSome( g,n, OWL.onProperty ); 348 } 349 } 350 }, 351 { CardinalityRestriction.class, new SupportsCheck() { 352 public boolean doCheck( Node n, EnhGraph g ) { 353 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 354 containsSome( g, n, OWL.cardinality ) && 355 containsSome( g, n, OWL.onProperty ); 356 } 357 } 358 }, 359 { MinCardinalityRestriction.class, new SupportsCheck() { 360 public boolean doCheck( Node n, EnhGraph g ) { 361 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 362 containsSome( g, n, OWL.minCardinality ) && 363 containsSome( g, n, OWL.onProperty ); 364 } 365 } 366 }, 367 { MaxCardinalityRestriction.class, new SupportsCheck() { 368 public boolean doCheck( Node n, EnhGraph g ) { 369 return g.asGraph().contains( n, RDF.type.asNode(), OWL.Restriction.asNode() ) && 370 containsSome( g, n, OWL.maxCardinality ) && 371 containsSome( g, n, OWL.onProperty ); 372 } 373 } 374 }, 375 { SymmetricProperty.class, new SupportsCheck() { 376 public boolean doCheck( Node n, EnhGraph g ) { 377 return g.asGraph().contains( n, RDF.type.asNode(), OWL.SymmetricProperty.asNode() ) && 378 !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 379 } 380 } 381 }, 382 { TransitiveProperty.class, new SupportsCheck() { 383 public boolean doCheck( Node n, EnhGraph g ) { 384 return g.asGraph().contains( n, RDF.type.asNode(), OWL.TransitiveProperty.asNode() ) && 385 !g.asGraph().contains( n, RDF.type.asNode(), OWL.DatatypeProperty.asNode() ); 386 } 387 } 388 }, 389 { Individual.class, new SupportsCheck() { 390 public boolean doCheck( Node n, EnhGraph g ) { 391 return n instanceof Node_URI || n instanceof Node_Blank; 392 } 393 } 394 }, 395 { DataRange.class, new SupportsCheck() { 396 public boolean doCheck( Node n, EnhGraph g ) { 397 return n instanceof Node_Blank && 398 g.asGraph().contains( n, RDF.type.asNode(), OWL.DataRange.asNode() ); 399 } 400 } 401 }}; 402 403 public static boolean containsSome( EnhGraph g, Node n, Property p ) { 405 return AbstractProfile.containsSome( g, n, p ); 406 } 407 408 409 412 413 private static HashMap s_supportsChecks = new HashMap(); 414 415 static { 416 for (int i = 0; i < s_supportsCheckData.length; i++) { 418 s_supportsChecks.put( s_supportsCheckData[i][0], s_supportsCheckData[i][1] ); 419 } 420 } 421 422 protected Map getCheckTable() { 423 return s_supportsChecks; 424 } 425 } 426 427 428 429 430 459 460 | Popular Tags |