1 10 package com.hp.hpl.jena.reasoner.rulesys.impl; 11 12 import com.hp.hpl.jena.graph.Node; 13 import com.hp.hpl.jena.graph.Triple; 14 import com.hp.hpl.jena.reasoner.*; 15 import com.hp.hpl.jena.reasoner.rulesys.*; 16 import com.hp.hpl.jena.util.iterator.ClosableIterator; 17 18 26 public class BBRuleContext implements RuleContext { 27 28 29 protected BindingEnvironment env; 30 31 32 protected Rule rule; 33 34 35 protected BackwardRuleInfGraphI graph; 36 37 41 public BBRuleContext(BackwardRuleInfGraphI graph) { 42 this.graph = graph; 43 } 44 45 48 public boolean contains(Node s, Node p, Node o) { 49 ClosableIterator i = find(s, p, o); 50 boolean result = i.hasNext(); 51 i.close(); 52 return result; 53 } 54 55 58 public boolean contains(Triple t) { 59 return contains(t.getSubject(), t.getPredicate(), t.getObject()); 60 } 61 62 65 public ClosableIterator find(Node s, Node p, Node o) { 66 return graph.findDataMatches(new TriplePattern(s, p, o)); 67 } 69 70 73 public BindingEnvironment getEnv() { 74 return env; 75 } 76 77 80 public void setEnv(BindingEnvironment env) { 81 this.env = env; 82 } 83 84 87 public InfGraph getGraph() { 88 return graph; 89 } 90 91 94 public Rule getRule() { 95 return rule; 96 } 97 98 101 public void setRule(Rule rule) { 102 this.rule = rule; 103 } 104 105 108 public void silentAdd(Triple t) { 109 ((SilentAddI)graph).silentAdd(t); 110 } 111 112 116 public void add(Triple t) { 117 ((SilentAddI)graph).silentAdd(t); 118 } 119 120 123 public void remove(Triple t) { 124 graph.delete(t); 125 } 126 127 136 public Node getTemp(Node instance, Node prop, Node pclass) { 137 return graph.getTemp(instance, prop, pclass); 138 } 139 140 } 141 142 143 144 | Popular Tags |