1 19 20 package com.hp.hpl.jena.reasoner.dig; 23 24 25 26 import com.hp.hpl.jena.rdf.model.*; 29 import com.hp.hpl.jena.reasoner.*; 30 import com.hp.hpl.jena.util.ResourceUtils; 31 import com.hp.hpl.jena.vocabulary.*; 32 import com.hp.hpl.jena.vocabulary.ReasonerVocabulary; 33 34 35 36 44 public class DIGReasonerFactory 45 implements ReasonerFactory 46 { 47 48 51 52 public static final String URI = "http://jena.hpl.hp.com/2003/DIGReasoner"; 53 54 55 public static final String DEFAULT_OWL_AXIOMS = "file:etc/dig-owl-axioms.rdf"; 56 57 58 public static final String DEFAULT_DAML_AXIOMS = "file:etc/dig-daml-axioms.rdf"; 59 60 61 64 65 private static DIGReasonerFactory s_instance = new DIGReasonerFactory(); 66 67 68 71 72 private Model m_capabilities = null; 73 74 75 78 79 private DIGReasonerFactory() {} 80 81 82 85 88 public static DIGReasonerFactory theInstance() { 89 return s_instance; 90 } 91 92 93 99 public Reasoner create( Resource configuration ) { 100 return new DIGReasoner( null, this, configuration ); 101 } 102 103 104 111 public Reasoner createWithDAMLAxioms( Resource configuration ) { 112 return create( OWL.NAMESPACE, DEFAULT_DAML_AXIOMS, configuration ); 113 } 114 115 116 123 public Reasoner createWithOWLAxioms( Resource configuration ) { 124 return create( OWL.NAMESPACE, DEFAULT_OWL_AXIOMS, configuration ); 125 } 126 127 128 135 public DIGReasoner create( Resource language, String axiomsURL, Resource configuration ) { 136 Model config = ModelFactory.createDefaultModel(); 137 Resource root; 138 139 if (configuration != null) { 140 config.add( ResourceUtils.reachableClosure( configuration ) ); 141 root = (Resource) config.getRDFNode( configuration.getNode() ); 142 } 143 else { 144 root = config.createResource(); 145 } 146 147 if (axiomsURL != null && !root.hasProperty( ReasonerVocabulary.EXT_REASONER_AXIOMS )) { 148 config.add( root, ReasonerVocabulary.EXT_REASONER_AXIOMS, config.getResource( axiomsURL ) ); 149 } 150 if (language != null && !root.hasProperty( ReasonerVocabulary.EXT_REASONER_ONT_LANG )) { 151 config.add( root, ReasonerVocabulary.EXT_REASONER_ONT_LANG, language ); 152 } 153 154 return (DIGReasoner) create( root ); 155 } 156 157 158 161 public Model getCapabilities() { 162 if (m_capabilities == null) { 163 m_capabilities = ModelFactory.createDefaultModel(); 164 Resource base = m_capabilities.createResource(getURI()); 165 base.addProperty(ReasonerVocabulary.nameP, "DIG external Reasoner") 166 .addProperty(ReasonerVocabulary.descriptionP, "Adapter for external (i.e. non-Jena) DIG reasoner." ) 167 .addProperty(ReasonerVocabulary.supportsP, RDFS.subClassOf) 168 .addProperty(ReasonerVocabulary.supportsP, RDFS.subPropertyOf) 169 .addProperty(ReasonerVocabulary.supportsP, RDFS.member) 170 .addProperty(ReasonerVocabulary.supportsP, RDFS.range) 171 .addProperty(ReasonerVocabulary.supportsP, RDFS.domain) 172 173 .addProperty( ReasonerVocabulary.supportsP, ReasonerVocabulary.directSubClassOf ) 174 .addProperty( ReasonerVocabulary.supportsP, ReasonerVocabulary.directSubPropertyOf ) 175 176 .addProperty( ReasonerVocabulary.supportsP, ReasonerVocabulary.individualAsThingP ) 177 178 .addProperty(ReasonerVocabulary.versionP, "0.1"); 180 } 181 182 return m_capabilities; 183 } 184 185 188 public String getURI() { 189 return URI; 190 } 191 192 193 196 200 } 201 202 228 | Popular Tags |