/** * 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) { 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); context.remove(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"); } } }
/** * 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) { 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); context.remove(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"); } } }