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