简体   繁体   English

如何在耶拿创建自定义的内置函数?

[英]How can I create customized builtins in Jena?

I just wondering how I can create new custom builtins for Jena. 我只是想知道如何为Jena创建新的自定义内置函数。 I know that for this purpose it should be used both the class "BaseBuiltin" and the class "BuiltinRegistry" (but how ?). 我知道,为此,应同时使用“ BaseBuiltin”类和“ BuiltinRegistry”类(但是如何使用)。

I have also found out a plugin for Eclipse which is called "SADL" but I am not sure if I can use if for this purpose. 我还找到了一个名为“ SADL”的Eclipse插件,但是我不确定是否可以将if用于此目的。 If I can...which method is better and why ? 如果可以...哪种方法更好,为什么?

Could anyone of you explain me which way I should take ? 你们谁能解释我该采取哪种方式?

Cheers! 干杯!

In a follow-up to a later question of yours , I provide code demonstrating the answer to this question, as well. 后续问题中 ,我还将提供代码来说明该问题的答案。

I've duplicated it here for the sake of people who need a quick reference. 为了方便需要快速参考的人,我在这里复制了它。 This builtin has the name example and delegates the majority of it's functionality to BaseBuiltin as per writing Jena builtin-ins and the Official Documentation . 该内建函数具有名称example并根据编写Jena内建函数和官方文档的方式将其大部分功能委托给BaseBuiltin Thanks to JT for the reference to his previous question. 感谢JT提及他先前的问题。

BuiltinRegistry.theRegistry.register( new BaseBuiltin() {
    @Override
    public String getName() {
        return "example";
    }
    @Override
    public void headAction( final Node[] args, final int length, final RuleContext context ) {
        System.out.println("Head Action: "+Arrays.toString(args));
    }
} );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM