2

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!

user3563844
  • 113
  • 1
  • 8
  • 1
    Have you seen the [writing Jena built-ins](http://stackoverflow.com/q/12139978/1281433) question (it's not a great question, and the answer doesn't help all that much, in my opinion, but it's relevant). – Joshua Taylor Apr 23 '14 at 21:08
  • What do you want your builtin to do? They're not too hard to implement, but some specific requirements would make it easier to craft an example. – Joshua Taylor Apr 23 '14 at 21:10
  • Also, have you looked at the source to any of the builtins in Jena that extend BaseBuiltin. E.g., [addOne](http://grepcode.com/file/repo1.maven.org/maven2/org.apache.jena/jena-core/2.7.3/com/hp/hpl/jena/reasoner/rulesys/builtins/AddOne.java)? – Joshua Taylor Apr 23 '14 at 21:14

1 Answers1

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));
    }
} );
Community
  • 1
  • 1
Rob Hall
  • 2,693
  • 16
  • 22