如何在耶拿创建定制的内置函数? [英] How can I create customized builtins in Jena?
问题描述
我只是想知道如何为耶拿创建新的自定义内置函数。我知道为此,应该使用类BaseBuiltin和类BuiltinRegistry(但是如何?)。
I just wondering how I can create new custom builtins for Jena. I know that for this purpose it should be used both the class "BaseBuiltin" and the class "BuiltinRegistry" (but how ?).
我还发现了一个插件对于被称为SADL的Eclipse,但是我不知道如果为了这个目的可以使用。如果我可以...哪种方法更好,为什么?
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. 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.
我已经重复在这里为了需要快速参考的人的缘故。这个内置函数的名称为 example
,并将其大部分功能委托给 BaseBuiltin
根据写耶拿内置版和官方文档。感谢JT参考他以前的问题。
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. Thanks to JT for the reference to his previous question.
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));
}
} );
这篇关于如何在耶拿创建定制的内置函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!