use of org.apache.jena.reasoner.TriplePattern in project jena by apache.
the class Drop method headAction.
/**
* This method is invoked when the builtin is called in a rule head.
* Such a use is only valid in a forward rule.
* @param args the array of argument values for the builtin, this is an array
* of Nodes.
* @param length the length of the argument list, may be less than the length of the args array
* for some rule engines
* @param context an execution context giving access to other relevant data
*/
@Override
public void headAction(Node[] args, int length, RuleContext context) {
InfGraph inf = context.getGraph();
Graph raw = inf.getRawGraph();
Graph deductions = inf.getDeductionsGraph();
for (int i = 0; i < length; i++) {
Node clauseN = getArg(i, args, context);
if (Util.isNumeric(clauseN)) {
int clauseIndex = Util.getIntValue(clauseN);
Object clause = context.getRule().getBodyElement(clauseIndex);
if (clause instanceof TriplePattern) {
Triple t = context.getEnv().instantiate((TriplePattern) clause);
raw.delete(t);
deductions.delete(t);
} else {
throw new BuiltinException(this, context, "illegal triple to remove non-triple clause");
}
} else {
throw new BuiltinException(this, context, "illegal arg to remove (" + clauseN + "), must be an integer");
}
}
}
Aggregations