1 10 package com.hp.hpl.jena.reasoner.rulesys.builtins; 11 12 import com.hp.hpl.jena.reasoner.TriplePattern; 13 import com.hp.hpl.jena.reasoner.rulesys.*; 14 import com.hp.hpl.jena.graph.*; 15 16 22 public class Remove extends BaseBuiltin { 23 24 28 public String getName() { 29 return "remove"; 30 } 31 32 41 public void headAction(Node[] args, int length, RuleContext context) { 42 boolean ok = false; 43 for (int i = 0; i < length; i++) { 44 Node clauseN = getArg(i, args, context); 45 if (Util.isNumeric(clauseN)) { 46 int clauseIndex = Util.getIntValue(clauseN); 47 Object clause = context.getRule().getBodyElement(clauseIndex); 48 if (clause instanceof TriplePattern) { 49 Triple t = context.getEnv().instantiate((TriplePattern)clause); 50 context.remove(t); 51 } else { 52 throw new BuiltinException(this, context, "illegal triple to remove non-triple clause"); 53 } 54 } else { 55 throw new BuiltinException(this, context, "illegal arg to remove (" + clauseN + "), must be an integer"); 56 } 57 } 58 } 59 } 60 61 | Popular Tags |