1 10 package com.hp.hpl.jena.reasoner.rulesys.impl.oldCode; 11 12 import com.hp.hpl.jena.rdf.model.*; 13 import com.hp.hpl.jena.reasoner.*; 14 import com.hp.hpl.jena.reasoner.rulesys.impl.RuleStore; 15 import com.hp.hpl.jena.vocabulary.ReasonerVocabulary; 16 import com.hp.hpl.jena.graph.*; 17 18 import java.util.*; 19 20 29 public class BasicBackwardRuleReasoner implements Reasoner { 30 31 32 protected ReasonerFactory factory; 33 34 35 protected List rules; 36 37 38 protected RuleStore ruleStore; 39 40 41 protected Graph schemaGraph; 42 43 44 protected boolean recordDerivations = false; 45 46 47 boolean traceOn = false; 48 49 50 protected Capabilities capabilities; 51 52 57 public BasicBackwardRuleReasoner(List rules) { 58 this.rules = rules; 59 ruleStore = new RuleStore(rules); 60 } 61 62 67 public BasicBackwardRuleReasoner(List rules, ReasonerFactory factory) { 68 this.rules = rules; 69 this.factory = factory; 70 ruleStore = new RuleStore(rules); 71 } 72 73 77 protected BasicBackwardRuleReasoner(BasicBackwardRuleReasoner parent, Graph schemaGraph) { 78 rules = parent.rules; 79 ruleStore = parent.ruleStore; 80 this.schemaGraph = schemaGraph; 81 this.factory = parent.factory; 82 } 83 84 90 public Model getReasonerCapabilities() { 91 if (factory != null) { 92 return factory.getCapabilities(); 93 } else { 94 return null; 95 } 96 } 97 98 104 public void addDescription(Model configSpec, Resource base) { 105 } 107 108 115 public boolean supportsProperty(Property property) { 116 if (factory == null) return false; 117 Model caps = factory.getCapabilities(); 118 Resource root = caps.getResource(factory.getURI()); 119 return caps.contains(root, ReasonerVocabulary.supportsP, property); 120 } 121 122 126 public Reasoner bindSchema(Graph tbox) throws ReasonerException { 127 return new BasicBackwardRuleReasoner(this, tbox); 128 } 129 130 134 public Reasoner bindSchema(Model tbox) throws ReasonerException { 135 return new BasicBackwardRuleReasoner(this, tbox.getGraph()); 136 } 137 138 149 public InfGraph bind(Graph data) throws ReasonerException { 150 BasicBackwardRuleInfGraph graph = new BasicBackwardRuleInfGraph(this, ruleStore, data, schemaGraph); 151 graph.setDerivationLogging(recordDerivations); 152 return graph; 153 } 154 155 159 public List getRules() { 160 return rules; 161 } 162 163 171 public void setDerivationLogging(boolean logOn) { 172 recordDerivations = logOn; 173 } 174 175 179 public void setTraceOn(boolean state) { 180 traceOn = state; 181 } 182 183 192 public void setParameter(Property parameter, Object value) { 193 throw new IllegalParameterException(parameter.toString()); 194 } 195 196 200 public Capabilities getGraphCapabilities() { 201 if (capabilities == null) { 202 capabilities = new BaseInfGraph.InfCapabilities(); 203 } 204 return capabilities; 205 } 206 207 } 208 209 210 211 240 241 | Popular Tags |