1 10 package com.hp.hpl.jena.reasoner.transitiveReasoner; 11 12 import com.hp.hpl.jena.rdf.model.*; 13 import com.hp.hpl.jena.reasoner.*; 14 import com.hp.hpl.jena.graph.*; 15 import com.hp.hpl.jena.vocabulary.RDFS; 16 import com.hp.hpl.jena.vocabulary.ReasonerVocabulary; 17 18 33 public class TransitiveReasoner implements Reasoner { 34 35 36 protected TransitiveGraphCache subClassCache; 37 38 39 protected TransitiveGraphCache subPropertyCache; 40 41 42 protected Finder tbox = null; 43 44 45 public static Node directSubPropertyOf; 46 47 48 public static Node directSubClassOf; 49 50 51 public static Node subPropertyOf; 52 53 54 public static Node subClassOf; 55 56 57 protected Capabilities capabilities; 58 59 static { 61 directSubPropertyOf = ReasonerRegistry.makeDirect(RDFS.subPropertyOf.getNode()); 62 directSubClassOf = ReasonerRegistry.makeDirect(RDFS.subClassOf.getNode()); 63 subPropertyOf = RDFS.subPropertyOf.getNode(); 64 subClassOf = RDFS.subClassOf.getNode(); 65 } 66 67 68 public TransitiveReasoner() { 69 subClassCache = new TransitiveGraphCache(directSubClassOf, subClassOf); 70 subPropertyCache = new TransitiveGraphCache(directSubPropertyOf, subPropertyOf); 71 } 72 73 77 protected TransitiveReasoner(Finder tbox, 78 TransitiveGraphCache subClassCache, 79 TransitiveGraphCache subPropertyCache) { 80 this.tbox = tbox; 81 this.subClassCache = subClassCache; 82 this.subPropertyCache = subPropertyCache; 83 } 84 85 91 public Model getReasonerCapabilities() { 92 return TransitiveReasonerFactory.theInstance().getCapabilities(); 93 } 94 95 101 public void addDescription(Model configSpec, Resource base) { 102 } 104 105 112 public boolean supportsProperty(Property property) { 113 ReasonerFactory rf = TransitiveReasonerFactory.theInstance(); 114 Model caps = rf.getCapabilities(); 115 Resource root = caps.getResource(rf.getURI()); 116 return caps.contains(root, ReasonerVocabulary.supportsP, property); 117 } 118 119 128 public Reasoner bindSchema(Graph tbox) throws ReasonerException { 129 return bindSchema(new FGraph(tbox)); 130 } 131 132 141 public Reasoner bindSchema(Model tbox) throws ReasonerException { 142 return bindSchema(new FGraph(tbox.getGraph())); 143 } 144 145 146 155 Reasoner bindSchema(Finder tbox) throws ReasonerException { 156 if (this.tbox != null) { 157 throw new ReasonerException("Attempt to bind multiple rulesets - disallowed for now"); 158 } 159 TransitiveGraphCache sCc = new TransitiveGraphCache(directSubClassOf, subClassOf); 160 TransitiveGraphCache sPc = new TransitiveGraphCache(directSubPropertyOf, subPropertyOf); 161 TransitiveEngine.cacheSubPropUtility(tbox, sPc); 162 TransitiveEngine.cacheSubClassUtility(tbox, sPc, sCc); 163 164 return new TransitiveReasoner(tbox, sCc, sPc); 165 } 166 167 177 public InfGraph bind(Graph data) throws ReasonerException { 178 return new TransitiveInfGraph(data, this); 179 } 180 181 189 public void setDerivationLogging(boolean logOn) { 190 } 192 193 202 public void setParameter(Property parameter, Object value) { 203 throw new IllegalParameterException(parameter.toString()); 204 } 205 206 210 public TransitiveGraphCache getSubPropertyCache() { 211 return subPropertyCache; 212 } 213 214 218 public TransitiveGraphCache getSubClassCache() { 219 return subClassCache; 220 } 221 222 226 public Finder getTbox() { 227 return tbox; 228 } 229 230 234 public Capabilities getGraphCapabilities() { 235 if (capabilities == null) { 236 capabilities = new BaseInfGraph.InfFindSafeCapabilities(); 237 } 238 return capabilities; 239 } 240 241 } 242 243 272 273 | Popular Tags |