本文整理汇总了Java中com.hp.hpl.jena.reasoner.rulesys.RuleContext.getEnv方法的典型用法代码示例。如果您正苦于以下问题:Java RuleContext.getEnv方法的具体用法?Java RuleContext.getEnv怎么用?Java RuleContext.getEnv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.reasoner.rulesys.RuleContext
的用法示例。
在下文中一共展示了RuleContext.getEnv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node cos = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.cos(nv1.doubleValue());
cos = Util.makeDoubleNode(absd);
return env.bind(args[1], cos);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例2: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node asin = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.asin(nv1.doubleValue());
asin = Util.makeDoubleNode(absd);
return env.bind(args[1], asin);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例3: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node atan = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.atan(nv1.doubleValue());
atan = Util.makeDoubleNode(absd);
return env.bind(args[1], atan);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例4: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node acos = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.acos(nv1.doubleValue());
acos = Util.makeDoubleNode(absd);
return env.bind(args[1], acos);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例5: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isURI()) {
String ln = n1.getLocalName();
logger.debug("returning localname '" + ln + "'");
Node lnn = NodeFactory.createLiteral(LiteralLabelFactory.create(ln));
return env.bind(args[1], lnn);
}
else {
logger.debug("Node '" + n1.toString() + "' is not a URI, can't extract localname");
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例6: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node floor = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.floor(nv1.doubleValue());
floor = Util.makeLongNode((long) absd);
return env.bind(args[1], floor);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例7: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node tan = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.tan(nv1.doubleValue());
tan = Util.makeDoubleNode(absd);
return env.bind(args[1], tan);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例8: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node sqrtn = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double sqrtd = Math.sqrt(nv1.doubleValue());
sqrtn = Util.makeDoubleNode(sqrtd);
return env.bind(args[1], sqrtn);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例9: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node sin = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.sin(nv1.doubleValue());
sin = Util.makeDoubleNode(absd);
return env.bind(args[1], sin);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例10: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node ceiling = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
double absd = Math.ceil(nv1.doubleValue());
ceiling = Util.makeLongNode((long) absd);
return env.bind(args[1], ceiling);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例11: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
if (length < 2)
throw new BuiltinException(this, context, "Must have at least 2 arguments to " + getName());
String text = getString( getArg(0, args, context), context );
String pattern = getString( getArg(1, args, context), context );
Matcher m = Pattern.compile(pattern).matcher(text);
if ( ! m.matches()) return false;
if (length > 2) {
// bind any capture groups
BindingEnvironment env = context.getEnv();
for (int i = 0; i < Math.min(length-2, m.groupCount()); i++) {
String gm = m.group(i+1);
Node match = (gm != null) ? Node.createLiteral( gm ) : Node.createLiteral("");
if ( !env.bind(args[i+2], match) ) return false;
}
}
return true;
}
示例12: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
Node n2 = getArg(1, args, context);
if (n1.isLiteral() && n2.isLiteral()) {
Object v1 = n1.getLiteralValue();
Object v2 = n2.getLiteralValue();
Node sum = null;
if (v1 instanceof Number && v2 instanceof Number) {
Number nv1 = (Number)v1;
Number nv2 = (Number)v2;
if (v1 instanceof Float || v1 instanceof Double
|| v2 instanceof Float || v2 instanceof Double) {
sum = Util.makeDoubleNode(nv1.doubleValue() / nv2.doubleValue());
} else {
sum = Util.makeLongNode(nv1.longValue() / nv2.longValue());
}
return env.bind(args[2], sum);
}
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例13: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
return env.bind(args[1], n1);
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例14: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @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
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node n1 = getArg(0, args, context);
if (n1.isLiteral()) {
Object v1 = n1.getLiteralValue();
Node abs = null;
if (v1 instanceof Number) {
Number nv1 = (Number)v1;
if (v1 instanceof Float || v1 instanceof Double) {
double absd = Math.abs(nv1.doubleValue());
abs = Util.makeDoubleNode(absd);
} else {
long absl = (long) Math.abs(nv1.longValue());
abs = Util.makeLongNode(absl);
}
logger.debug("returning abs(" + nv1.toString() + ") = " + abs.toString());
return env.bind(args[1], abs);
}
else {
logger.debug("Node '" + v1.toString() + "' is not a Number, can't take abs()");
}
}
else {
logger.debug("Node '" + n1.toString() + "' is not a Literal, can't take abs()");
}
// Doesn't (yet) handle partially bound cases
return false;
}
示例15: bodyCall
import com.hp.hpl.jena.reasoner.rulesys.RuleContext; //导入方法依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @param context an execution context giving access to other relevant data
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
BindingEnvironment env = context.getEnv();
Node now = Node.createLiteral( LiteralLabelFactory.create(new XSDDateTime(Calendar.getInstance())) );
return env.bind(args[0], now);
}