1 10 package com.hp.hpl.jena.reasoner.rulesys.impl; 11 12 import com.hp.hpl.jena.reasoner.*; 13 import com.hp.hpl.jena.reasoner.rulesys.*; 14 import com.hp.hpl.jena.util.iterator.ClosableIterator; 15 import com.hp.hpl.jena.graph.*; 16 17 24 public class RETERuleContext implements RuleContext { 25 26 27 protected BindingEnvironment env; 28 29 30 protected Rule rule; 31 32 33 protected ForwardRuleInfGraphI graph; 34 35 36 protected RETEEngine engine; 37 38 42 public RETERuleContext(ForwardRuleInfGraphI graph, RETEEngine engine) { 43 this.graph = graph; 44 this.engine = engine; 45 } 46 47 51 public BindingEnvironment getEnv() { 52 return env; 53 } 54 55 59 public InfGraph getGraph() { 60 return graph; 61 } 62 63 66 public RETEEngine getEngine() { 67 return engine; 68 } 69 70 74 public Rule getRule() { 75 return rule; 76 } 77 78 82 public void setRule(Rule rule) { 83 this.rule = rule; 84 } 85 86 90 public void setEnv(BindingEnvironment env) { 91 this.env = env; 92 } 93 94 98 public boolean contains(Triple t) { 99 return contains(t.getSubject(), t.getPredicate(), t.getObject()); 101 } 102 103 107 public boolean contains(Node s, Node p, Node o) { 108 ClosableIterator it = find(s, p, o); 109 boolean result = it.hasNext(); 110 it.close(); 111 return result; 112 } 113 114 119 public ClosableIterator find(Node s, Node p, Node o) { 120 return graph.findDataMatches(s, p, o); 122 } 123 124 127 public void silentAdd(Triple t) { 128 ((SilentAddI)graph).silentAdd(t); 129 } 130 131 134 public void remove(Triple t) { 135 graph.delete(t); 136 engine.deleteTriple(t, true); 137 } 138 139 142 public void add(Triple t) { 143 engine.addTriple(t, true); 144 } 145 146 } 147 148 149 | Popular Tags |