writing Jena built-ins

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

I'm trying to write a Jena built-in to return a value from an algorithm I have been given and then do a comparison against that value, e.g.,

String rule = "[exRule: (?d rdf:type ex:abc)" +               "<-" +               // ...extract ?a, ?b to use as inputs to the rule           "greaterThan(myBuiltIn(?a, ?b), 1)" +  // Is return value greater than 1       "]"; 

So, first the Jena documentation says that the easiest way to experiment with this is to look at the examples in the builtins directory, however I don't seem to have this in my installation, I'm using Jena 2.6.4 on Windows 7. Where can I find this? Do I need to download it from elsewhere?

Secondly, I'm unsure how to pick up the return value from my builtin. If I simply call myBuiltIn(2, 1) using hardwired values I know it's being called due to some debug output I've added to the builtin's bodyCall() method. However, if I pass it to greaterThan(), then I no longer see this. Is it still being called?

回答1:

@Joshua

I found how to implement this.

First of all, you should create a new class that extend from BaseBuiltin like this http://sadl.sourceforge.net/CustomJenaBuiltins.html

and then add it into builtinRegistry class



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