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.graph.*; 14 15 22 public abstract class BaseBuiltin implements Builtin { 23 24 25 public static final String BASE_URI = "http://jena.hpl.hp.com/2003/RuleBuiltin/"; 26 27 30 public String getURI() { 31 return BASE_URI + getName(); 32 } 33 34 37 public int getArgLength() { 38 return 0; 39 } 40 41 44 public void checkArgs(int length, RuleContext context) { 45 int expected = getArgLength(); 46 if (expected > 0 && expected != length) { 47 throw new BuiltinException(this, context, "builtin " + getName() + " requires " + expected + " arguments but saw " + length); 48 } 49 } 50 51 61 public boolean bodyCall(Node[] args, int length, RuleContext context) { 62 throw new BuiltinException(this, context, "builtin " + getName() + " not usable in rule bodies"); 63 } 64 65 66 75 public void headAction(Node[] args, int length, RuleContext context) { 76 throw new BuiltinException(this, context, "builtin " + getName() + " not usable in rule heads"); 77 } 78 79 83 public boolean isSafe() { 84 return true; 86 } 87 88 92 public Node getArg(int n, Node[] args, RuleContext context) { 93 return context.getEnv().getGroundVersion(args[n]); 94 } 95 96 } 97 98 99 100 | Popular Tags |