1 19 20 package com.hp.hpl.jena.ontology.impl; 23 24 25 import com.hp.hpl.jena.enhanced.*; 28 import com.hp.hpl.jena.graph.*; 29 import com.hp.hpl.jena.ontology.*; 30 import com.hp.hpl.jena.rdf.model.*; 31 import com.hp.hpl.jena.vocabulary.*; 32 33 import java.util.*; 34 35 36 37 52 public class DAML_OILProfile 53 extends AbstractProfile 54 { 55 58 59 62 63 66 67 private Model m_vocabModel = ModelFactory.createDefaultModel(); 68 69 private Resource m_class = m_vocabModel.createResource( DAML_OIL.Class.getURI() ); 71 private Resource m_restriction = m_vocabModel.createResource( DAML_OIL.Restriction.getURI() ); 72 private Resource m_thing = m_vocabModel.createResource( DAML_OIL.Thing.getURI() ); 73 private Resource m_nothing = m_vocabModel.createResource( DAML_OIL.Nothing.getURI() ); 74 private Resource m_property = m_vocabModel.createResource( DAML_OIL.Property.getURI() ); 75 private Resource m_objectProperty = m_vocabModel.createResource( DAML_OIL.ObjectProperty.getURI() ); 76 private Resource m_datatypeProperty = m_vocabModel.createResource( DAML_OIL.DatatypeProperty.getURI() ); 77 private Resource m_transitiveProperty = m_vocabModel.createResource( DAML_OIL.TransitiveProperty.getURI() ); 78 private Resource m_symmetricProperty = null; 79 private Resource m_functionalProperty = m_vocabModel.createResource( DAML_OIL.UniqueProperty.getURI() ); 80 private Resource m_inverseFunctionalProperty = m_vocabModel.createResource( DAML_OIL.UnambiguousProperty.getURI() ); 81 private Resource m_allDifferent = null; 82 private Resource m_ontology = m_vocabModel.createResource( DAML_OIL.Ontology.getURI() ); 83 private Resource m_deprecatedClass = null; 84 private Resource m_deprecatedProperty = null; 85 private Resource m_annotationProperty = null; 86 private Resource m_ontologyProperty = null; 87 private Resource m_list = m_vocabModel.createResource( DAML_OIL.List.getURI() ); 88 private Resource m_nil = m_vocabModel.createResource( DAML_OIL.nil.getURI() ); 89 private Resource m_datarange = null; 90 91 private Property m_equivalentProperty = m_vocabModel.createProperty( DAML_OIL.samePropertyAs.getNameSpace(), DAML_OIL.samePropertyAs.getLocalName() ); 92 private Property m_equivalentClass = m_vocabModel.createProperty( DAML_OIL.sameClassAs.getNameSpace(), DAML_OIL.sameClassAs.getLocalName() ); 93 private Property m_disjointWith = m_vocabModel.createProperty( DAML_OIL.disjointWith.getNameSpace(), DAML_OIL.disjointWith.getLocalName() ); 94 private Property m_sameIndividualAs = m_vocabModel.createProperty( DAML_OIL.sameIndividualAs.getNameSpace(), DAML_OIL.sameIndividualAs.getLocalName() ); 95 private Property m_sameAs = m_vocabModel.createProperty( DAML_OIL.equivalentTo.getNameSpace(), DAML_OIL.equivalentTo.getLocalName() ); 96 private Property m_differentFrom = m_vocabModel.createProperty( DAML_OIL.differentIndividualFrom.getNameSpace(), DAML_OIL.differentIndividualFrom.getLocalName() ); 97 private Property m_distinctMembers = null; 98 private Property m_unionOf = m_vocabModel.createProperty( DAML_OIL.unionOf.getNameSpace(), DAML_OIL.unionOf.getLocalName() ); 99 private Property m_intersectionOf = m_vocabModel.createProperty( DAML_OIL.intersectionOf.getNameSpace(), DAML_OIL.intersectionOf.getLocalName() ); 100 private Property m_complementOf = m_vocabModel.createProperty( DAML_OIL.complementOf.getNameSpace(), DAML_OIL.complementOf.getLocalName() ); 101 private Property m_oneOf = m_vocabModel.createProperty( DAML_OIL.oneOf.getNameSpace(), DAML_OIL.oneOf.getLocalName() ); 102 private Property m_onProperty = m_vocabModel.createProperty( DAML_OIL.onProperty.getNameSpace(), DAML_OIL.onProperty.getLocalName() ); 103 private Property m_allValuesFrom = m_vocabModel.createProperty( DAML_OIL.toClass.getNameSpace(), DAML_OIL.toClass.getLocalName() ); 104 private Property m_hasValue = m_vocabModel.createProperty( DAML_OIL.hasValue.getNameSpace(), DAML_OIL.hasValue.getLocalName() ); 105 private Property m_someValuesFrom = m_vocabModel.createProperty( DAML_OIL.hasClass.getNameSpace(), DAML_OIL.hasClass.getLocalName() ); 106 private Property m_minCardinality = m_vocabModel.createProperty( DAML_OIL.minCardinality.getNameSpace(), DAML_OIL.minCardinality.getLocalName() ); 107 private Property m_maxCardinality = m_vocabModel.createProperty( DAML_OIL.maxCardinality.getNameSpace(), DAML_OIL.maxCardinality.getLocalName() ); 108 private Property m_cardinality = m_vocabModel.createProperty( DAML_OIL.cardinality.getNameSpace(), DAML_OIL.cardinality.getLocalName() ); 109 private Property m_inverseOf = m_vocabModel.createProperty( DAML_OIL.inverseOf.getNameSpace(), DAML_OIL.inverseOf.getLocalName() ); 110 private Property m_imports = m_vocabModel.createProperty( DAML_OIL.imports.getNameSpace(), DAML_OIL.imports.getLocalName() ); 111 private Property m_versionInfo = m_vocabModel.createProperty( DAML_OIL.versionInfo.getNameSpace(), DAML_OIL.versionInfo.getLocalName() ); 112 private Property m_priorVersion = null; 113 private Property m_backwardsCompatibleWith = null; 114 private Property m_incompatibleWith = null; 115 private Property m_subPropertyOf = m_vocabModel.createProperty( RDFS.subPropertyOf.getURI() ); 116 private Property m_subClassOf = m_vocabModel.createProperty( RDFS.subClassOf.getURI() ); 117 private Property m_domain = m_vocabModel.createProperty( RDFS.domain.getURI() ); 118 private Property m_range = m_vocabModel.createProperty( RDFS.range.getURI() ); 119 private Property m_first = m_vocabModel.createProperty( DAML_OIL.first.getNameSpace(), DAML_OIL.first.getLocalName() ); 120 private Property m_rest = m_vocabModel.createProperty( DAML_OIL.rest.getNameSpace(), DAML_OIL.rest.getLocalName() ); 121 private Property m_minCardinalityQ = m_vocabModel.createProperty( DAML_OIL.minCardinalityQ.getNameSpace(), DAML_OIL.minCardinalityQ.getLocalName() ); 122 private Property m_maxCardinalityQ = m_vocabModel.createProperty( DAML_OIL.maxCardinalityQ.getNameSpace(), DAML_OIL.maxCardinalityQ.getLocalName() ); 123 private Property m_cardinalityQ = m_vocabModel.createProperty( DAML_OIL.cardinalityQ.getNameSpace(), DAML_OIL.cardinalityQ.getLocalName() ); 124 private Property m_hasClassQ = m_vocabModel.createProperty( DAML_OIL.hasClassQ.getNameSpace(), DAML_OIL.hasClassQ.getLocalName() ); 125 126 129 130 133 140 public static String _NAMESPACE() { return "http://www.daml.org/2001/03/daml+oil#"; } 141 142 143 public String NAMESPACE() { return DAML_OILProfile._NAMESPACE(); } 144 145 public Resource CLASS() { return m_class; } 146 public Resource RESTRICTION() { return m_restriction; } 147 public Resource THING() { return m_thing; } 148 public Resource NOTHING() { return m_nothing; } 149 public Resource PROPERTY() { return m_property; } 150 public Resource OBJECT_PROPERTY() { return m_objectProperty; } 151 public Resource DATATYPE_PROPERTY() { return m_datatypeProperty; } 152 public Resource TRANSITIVE_PROPERTY() { return m_transitiveProperty; } 153 public Resource SYMMETRIC_PROPERTY() { return m_symmetricProperty; } 154 public Resource FUNCTIONAL_PROPERTY() { return m_functionalProperty; } 155 public Resource INVERSE_FUNCTIONAL_PROPERTY() { return m_inverseFunctionalProperty; } 156 public Resource ALL_DIFFERENT() { return m_allDifferent; } 157 public Resource ONTOLOGY() { return m_ontology; } 158 public Resource DEPRECATED_CLASS() { return m_deprecatedClass; } 159 public Resource DEPRECATED_PROPERTY() { return m_deprecatedProperty; } 160 public Resource ANNOTATION_PROPERTY() { return m_annotationProperty; } 161 public Resource ONTOLOGY_PROPERTY() { return m_ontologyProperty; } 162 public Resource LIST() { return m_list; } 163 public Resource NIL() { return m_nil; } 164 public Resource DATARANGE() { return m_datarange; } 165 166 public Property EQUIVALENT_PROPERTY() { return m_equivalentProperty; } 167 public Property EQUIVALENT_CLASS() { return m_equivalentClass; } 168 public Property DISJOINT_WITH() { return m_disjointWith; } 169 public Property SAME_INDIVIDUAL_AS() { return m_sameIndividualAs; } 170 public Property SAME_AS() { return m_sameAs; } 171 public Property DIFFERENT_FROM() { return m_differentFrom; } 172 public Property DISTINCT_MEMBERS() { return m_distinctMembers; } 173 public Property UNION_OF() { return m_unionOf; } 174 public Property INTERSECTION_OF() { return m_intersectionOf; } 175 public Property COMPLEMENT_OF() { return m_complementOf; } 176 public Property ONE_OF() { return m_oneOf; } 177 public Property ON_PROPERTY() { return m_onProperty; } 178 public Property ALL_VALUES_FROM() { return m_allValuesFrom; } 179 public Property HAS_VALUE() { return m_hasValue; } 180 public Property SOME_VALUES_FROM() { return m_someValuesFrom; } 181 public Property MIN_CARDINALITY() { return m_minCardinality; } 182 public Property MAX_CARDINALITY() { return m_maxCardinality; } 183 public Property CARDINALITY() { return m_cardinality; } 184 public Property INVERSE_OF() { return m_inverseOf; } 185 public Property IMPORTS() { return m_imports; } 186 public Property PRIOR_VERSION() { return m_priorVersion; } 187 public Property BACKWARD_COMPATIBLE_WITH() { return m_backwardsCompatibleWith; } 188 public Property INCOMPATIBLE_WITH() { return m_incompatibleWith; } 189 public Property SUB_CLASS_OF() { return m_subClassOf; } 190 public Property SUB_PROPERTY_OF() { return m_subPropertyOf; } 191 public Property DOMAIN() { return m_domain; } 192 public Property RANGE() { return m_range; } 193 public Property FIRST() { return m_first; } 194 public Property REST() { return m_rest; } 195 public Property MIN_CARDINALITY_Q() { return m_minCardinalityQ; } 196 public Property MAX_CARDINALITY_Q() { return m_maxCardinalityQ; } 197 public Property CARDINALITY_Q() { return m_cardinalityQ; } 198 public Property HAS_CLASS_Q() { return m_hasClassQ; } 199 200 201 public Property VERSION_INFO() { return m_versionInfo; } 203 public Property LABEL() { return RDFS.label; } 204 public Property COMMENT() { return RDFS.comment; } 205 public Property SEE_ALSO() { return RDFS.seeAlso; } 206 public Property IS_DEFINED_BY() { return RDFS.isDefinedBy; } 207 208 protected Resource[][] aliasTable() { 209 return new Resource[][] { 210 {DAML_OIL.subClassOf, RDFS.subClassOf}, 211 {DAML_OIL.Literal, RDFS.Literal}, 212 {DAML_OIL.Property, RDF.Property}, 213 {DAML_OIL.type, RDF.type}, 214 {DAML_OIL.value, RDF.value}, 215 {DAML_OIL.subPropertyOf, RDFS.subPropertyOf}, 216 {DAML_OIL.domain, RDFS.domain}, 217 {DAML_OIL.range, RDFS.range}, 218 {DAML_OIL.label, RDFS.label}, 219 {DAML_OIL.comment, RDFS.comment}, 220 {DAML_OIL.seeAlso, RDFS.seeAlso}, 221 {DAML_OIL.isDefinedBy, RDFS.isDefinedBy}, 222 }; 223 } 224 225 226 public Iterator getAxiomTypes() { 227 return Arrays.asList( 228 new Resource[] { 229 } 230 ).iterator(); 231 } 232 233 234 public Iterator getAnnotationProperties() { 235 return Arrays.asList( 236 new Resource[] { 237 } 238 ).iterator(); 239 } 240 241 public Iterator getClassDescriptionTypes() { 242 return Arrays.asList( 243 new Resource[] { 244 DAML_OIL.Class, 245 DAML_OIL.Restriction 246 } 247 ).iterator(); 248 } 249 250 251 252 267 public boolean isSupported( Node n, EnhGraph g, Class type ) { 268 if (g instanceof OntModel) { 269 OntModel m = (OntModel) g; 270 271 if (type == null) { 272 return false; 275 } 276 else if (!m.strictMode()) { 277 return true; 279 } 280 else { 281 SupportsCheck check = (SupportsCheck) s_supportsChecks.get( type ); 283 284 return (check == null) || check.doCheck( n, g ); 285 } 286 } 287 else { 288 return false; 289 } 290 } 291 292 293 299 public String getLabel() { 300 return "DAML+OIL"; 301 } 302 303 304 305 308 309 313 314 protected static class SupportsCheck 315 { 316 public boolean doCheck( Node n, EnhGraph g ) { 317 return true; 318 } 319 } 320 321 322 325 private static Object [][] s_supportsCheckTable = new Object [][] { 326 { OntClass.class, new SupportsCheck() { 328 public boolean doCheck( Node n, EnhGraph g ) { 329 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Class.asNode() ) || 330 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) || 331 g.asGraph().contains( n, RDF.type.asNode(), RDFS.Class.asNode() ) || 332 n.equals( DAML_OIL.Thing.asNode() ) || 334 n.equals( DAML_OIL.Nothing.asNode() ) || 335 g.asGraph().contains( Node.ANY, RDFS.domain.asNode(), n ) || 336 g.asGraph().contains( Node.ANY, RDFS.range.asNode(), n ) 337 ; 338 } 339 } 340 }, 341 { DatatypeProperty.class, new SupportsCheck() { 342 public boolean doCheck( Node n, EnhGraph g ) { 343 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.DatatypeProperty.asNode() ); 344 } 345 } 346 }, 347 { ObjectProperty.class, new SupportsCheck() { 348 public boolean doCheck( Node n, EnhGraph g ) { 349 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.ObjectProperty.asNode() ) || 350 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.TransitiveProperty.asNode() ) || 351 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UnambiguousProperty.asNode() ); 352 } 353 } 354 }, 355 { FunctionalProperty.class, new SupportsCheck() { 356 public boolean doCheck( Node n, EnhGraph g ) { 357 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UniqueProperty.asNode() ); 359 } 360 } 361 }, 362 { InverseFunctionalProperty.class, new SupportsCheck() { 363 public boolean doCheck( Node n, EnhGraph g ) { 364 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UnambiguousProperty.asNode() ); 366 } 367 } 368 }, 369 { RDFList.class, new SupportsCheck() { 370 public boolean doCheck( Node n, EnhGraph g ) { 371 return n.equals( DAML_OIL.nil.asNode() ) || 372 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.List.asNode() ); 373 } 374 } 375 }, 376 { Ontology.class, new SupportsCheck() { 377 public boolean doCheck( Node n, EnhGraph g ) { 378 return n.equals( RDF.nil.asNode() ) || 379 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Ontology.asNode() ); 380 } 381 } 382 }, 383 { OntProperty.class, new SupportsCheck() { 384 public boolean doCheck( Node n, EnhGraph g ) { 385 return g.asGraph().contains( n, RDF.type.asNode(), RDF.Property.asNode() ) || 386 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Property.asNode() ) || 387 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.ObjectProperty.asNode() ) || 388 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.DatatypeProperty.asNode() ) || 389 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.TransitiveProperty.asNode() ) || 390 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UnambiguousProperty.asNode() ) || 391 g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.UniqueProperty.asNode() ) 392 ; 393 } 394 } 395 }, 396 { Restriction.class, new SupportsCheck() { 397 public boolean doCheck( Node n, EnhGraph g ) { 398 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ); 399 } 400 } 401 }, 402 { HasValueRestriction.class, new SupportsCheck() { 403 public boolean doCheck( Node n, EnhGraph g ) { 404 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 405 containsSome( g, n, DAML_OIL.hasValue ) && 406 containsSome( g, n, DAML_OIL.onProperty ); 407 } 408 } 409 }, 410 { AllValuesFromRestriction.class, new SupportsCheck() { 411 public boolean doCheck( Node n, EnhGraph g ) { 412 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 413 containsSome( g, n, DAML_OIL.toClass ) && 414 containsSome( g, n, DAML_OIL.onProperty ); 415 } 416 } 417 }, 418 { SomeValuesFromRestriction.class, new SupportsCheck() { 419 public boolean doCheck( Node n, EnhGraph g ) { 420 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 421 containsSome( g, n, DAML_OIL.hasClass ) && 422 containsSome( g, n, DAML_OIL.onProperty ); 423 } 424 } 425 }, 426 { CardinalityRestriction.class, new SupportsCheck() { 427 public boolean doCheck( Node n, EnhGraph g ) { 428 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 429 containsSome( g, n, DAML_OIL.cardinality ) && 430 containsSome( g, n, DAML_OIL.onProperty ); 431 } 432 } 433 }, 434 { MinCardinalityRestriction.class, new SupportsCheck() { 435 public boolean doCheck( Node n, EnhGraph g ) { 436 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 437 containsSome( g, n, DAML_OIL.minCardinality ) && 438 containsSome( g, n, DAML_OIL.onProperty ); 439 } 440 } 441 }, 442 { MaxCardinalityRestriction.class, new SupportsCheck() { 443 public boolean doCheck( Node n, EnhGraph g ) { 444 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 445 containsSome( g, n, DAML_OIL.maxCardinality ) && 446 containsSome( g, n, DAML_OIL.onProperty ); 447 } 448 } 449 }, 450 { TransitiveProperty.class, new SupportsCheck() { 451 public boolean doCheck( Node n, EnhGraph g ) { 452 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.TransitiveProperty.asNode() ) && 453 !g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.DatatypeProperty.asNode() ); 454 } 455 } 456 }, 457 { QualifiedRestriction.class, new SupportsCheck() { 458 public boolean doCheck( Node n, EnhGraph g ) { 459 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 460 g.asGraph().contains( n, DAML_OIL.hasClassQ.asNode(), Node.ANY ); 461 } 462 } 463 }, 464 { CardinalityQRestriction.class, new SupportsCheck() { 465 public boolean doCheck( Node n, EnhGraph g ) { 466 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 467 g.asGraph().contains( n, DAML_OIL.cardinalityQ.asNode(), Node.ANY ); 468 } 469 } 470 }, 471 { MinCardinalityQRestriction.class, new SupportsCheck() { 472 public boolean doCheck( Node n, EnhGraph g ) { 473 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 474 g.asGraph().contains( n, DAML_OIL.minCardinalityQ.asNode(), Node.ANY ); 475 } 476 } 477 }, 478 { MaxCardinalityQRestriction.class, new SupportsCheck() { 479 public boolean doCheck( Node n, EnhGraph g ) { 480 return g.asGraph().contains( n, RDF.type.asNode(), DAML_OIL.Restriction.asNode() ) && 481 g.asGraph().contains( n, DAML_OIL.maxCardinalityQ.asNode(), Node.ANY ); 482 } 483 } 484 }, 485 }; 486 487 488 489 public static boolean containsSome( EnhGraph g, Node n, Property p ) { 490 return AbstractProfile.containsSome( g, n, p ); 491 } 492 493 496 497 protected static HashMap s_supportsChecks = new HashMap(); 498 499 static { 500 for (int i = 0; i < s_supportsCheckTable.length; i++) { 502 s_supportsChecks.put( s_supportsCheckTable[i][0], s_supportsCheckTable[i][1] ); 503 } 504 } 505 506 } 507 508 509 510 511 540 541 | Popular Tags |