1 10 package com.hp.hpl.jena.reasoner.rulesys.impl; 11 12 import com.hp.hpl.jena.graph.*; 13 import com.hp.hpl.jena.reasoner.TriplePattern; 14 15 import java.util.*; 16 17 24 public class EnvironmentFrameWithDerivation extends EnvironmentFrame { 25 26 27 Node[] argVars = new Node[RuleClauseCode.MAX_ARGUMENT_VARS]; 28 29 30 Triple[] matches; 31 32 36 public EnvironmentFrameWithDerivation(RuleClauseCode clause) { 37 super(clause); 38 if (clause.getRule() != null) { 39 matches = new Triple[clause.getRule().bodyLength()]; 40 } 41 } 42 43 44 public void noteMatch(TriplePattern pattern, int pc) { 45 Triple match = new Triple(LPInterpreter.deref(pattern.getSubject()), 46 LPInterpreter.deref(pattern.getPredicate()), 47 LPInterpreter.deref(pattern.getObject())); 48 int term = clause.termIndex(pc); 49 if (term >= 0) { 50 matches[term] = match; 51 } 52 } 53 54 57 public Triple getResult() { 58 return new Triple( 59 LPInterpreter.deref(argVars[0]), 60 LPInterpreter.deref(argVars[1]), 61 LPInterpreter.derefPossFunctor(argVars[2])); 62 } 63 64 67 public List getMatchList() { 68 ArrayList matchList = new ArrayList(); 69 for (int i = 0; i < matches.length; i++) { 70 matchList.add(matches[i]); 71 } 72 return matchList; 73 } 74 78 public void initDerivationRecord(Node[] args) { 79 System.arraycopy(args, 0, argVars, 0, RuleClauseCode.MAX_ARGUMENT_VARS); 80 } 81 82 } 83 84 85 | Popular Tags |