当前位置: 首页>>代码示例>>Java>>正文


Java RuleContext.getEnv方法代码示例

本文整理汇总了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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Cos.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Asin.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Atan.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Acos.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:Localname.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Floor.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Tan.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Sqrt.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Sin.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:28,代码来源:Ceiling.java

示例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;
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:30,代码来源:Regex.java

示例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;
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:36,代码来源:Quotient.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:Assign.java

示例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;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:40,代码来源:Abs.java

示例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);
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:16,代码来源:Now.java


注:本文中的com.hp.hpl.jena.reasoner.rulesys.RuleContext.getEnv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。