1 10 package com.hp.hpl.jena.reasoner.rulesys; 11 12 13 import com.hp.hpl.jena.rdf.model.*; 14 import com.hp.hpl.jena.reasoner.*; 15 import com.hp.hpl.jena.reasoner.rulesys.impl.*; 16 import com.hp.hpl.jena.vocabulary.ReasonerVocabulary; 17 import com.hp.hpl.jena.graph.*; 18 19 import java.util.*; 20 21 30 public class LPBackwardRuleReasoner implements Reasoner { 31 32 33 protected ReasonerFactory factory; 34 35 36 protected List rules; 37 38 39 protected LPRuleStore ruleStore; 40 41 42 protected Graph schemaGraph; 43 44 45 protected boolean recordDerivations = false; 46 47 48 boolean traceOn = false; 49 50 51 protected Capabilities capabilities; 52 53 58 public LPBackwardRuleReasoner(List rules) { 59 this.rules = rules; 60 ruleStore = new LPRuleStore(rules); 61 } 62 63 68 public LPBackwardRuleReasoner(List rules, ReasonerFactory factory) { 69 this.rules = rules; 70 this.factory = factory; 71 ruleStore = new LPRuleStore(rules); 72 } 73 74 78 protected LPBackwardRuleReasoner(LPBackwardRuleReasoner parent, Graph schemaGraph) { 79 rules = parent.rules; 80 ruleStore = parent.ruleStore; 81 this.schemaGraph = schemaGraph; 82 this.factory = parent.factory; 83 } 84 85 91 public Model getReasonerCapabilities() { 92 if (factory != null) { 93 return factory.getCapabilities(); 94 } else { 95 return null; 96 } 97 } 98 99 105 public void addDescription(Model configSpec, Resource base) { 106 } 108 109 113 public synchronized void tablePredicate(Node predicate) { 114 ruleStore.tablePredicate(predicate); 115 } 116 117 118 125 public boolean supportsProperty(Property property) { 126 if (factory == null) return false; 127 Model caps = factory.getCapabilities(); 128 Resource root = caps.getResource(factory.getURI()); 129 return caps.contains(root, ReasonerVocabulary.supportsP, property); 130 } 131 132 136 public Reasoner bindSchema(Graph tbox) throws ReasonerException { 137 return new LPBackwardRuleReasoner(this, tbox); 138 } 139 140 144 public Reasoner bindSchema(Model tbox) throws ReasonerException { 145 return new LPBackwardRuleReasoner(this, tbox.getGraph()); 146 } 147 148 159 public InfGraph bind(Graph data) throws ReasonerException { 160 LPBackwardRuleInfGraph graph = new LPBackwardRuleInfGraph(this, ruleStore, data, schemaGraph); 161 graph.setDerivationLogging(recordDerivations); 162 return graph; 163 } 164 165 169 public List getRules() { 170 return rules; 171 } 172 173 181 public void setDerivationLogging(boolean logOn) { 182 recordDerivations = logOn; 183 } 184 185 189 public void setTraceOn(boolean state) { 190 traceOn = state; 191 } 192 193 202 public void setParameter(Property parameter, Object value) { 203 throw new IllegalParameterException(parameter.toString()); 204 } 205 206 210 public Capabilities getGraphCapabilities() { 211 if (capabilities == null) { 212 capabilities = new BaseInfGraph.InfCapabilities(); 213 } 214 return capabilities; 215 } 216 217 } 218 219 220 221 | Popular Tags |