How can I create customized builtins in Jena?

泄露秘密 提交于 2019-12-11 02:12:50

问题


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 ?).

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!


回答1:


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. 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));
    }
} );


来源:https://stackoverflow.com/questions/23255124/how-can-i-create-customized-builtins-in-jena

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!