1 10 package com.hp.hpl.jena.reasoner.rulesys.builtins; 11 12 import com.hp.hpl.jena.reasoner.rulesys.*; 13 import com.hp.hpl.jena.reasoner.rulesys.impl.BBRuleContext; 14 import com.hp.hpl.jena.graph.*; 16 17 29 public class MakeInstance extends BaseBuiltin { 30 31 35 public String getName() { 36 return "makeInstance"; 37 } 38 39 49 public boolean bodyCall(Node[] args, int length, RuleContext context) { 50 if (length == 3 || length == 4) { 55 Node inst = getArg(0, args, context); 56 Node prop = getArg(1, args, context); 57 Node pclass = length == 4 ? getArg(2, args, context) : null; 58 if (context instanceof BBRuleContext) { 59 Node temp = ((BBRuleContext)context).getTemp(inst, prop, pclass); 60 return context.getEnv().bind(args[length-1], temp); 61 } else { 62 throw new BuiltinException(this, context, "builtin " + getName() + " only usable in backward/hybrid rule sets"); 63 } 64 } else { 65 throw new BuiltinException(this, context, "builtin " + getName() + " requries 3 or 4 arguments"); 66 } 67 } 68 69 } 70 71 72 | Popular Tags |