生成Jena Bnode ID [英] Generating Jena Bnode IDs

查看:81
本文介绍了生成Jena Bnode ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以覆盖Jena的用于生成匿名节点ID的默认方法?

Is there a way to override Jena's default method for generating anonymous node IDs?

理想情况下,我想将一个生成ID的函子传递给Jena,这样我就可以使它们在全局范围内唯一(而不是仅对于计算机唯一).构造AnonId时应使用函子.

Ideally, I'd like to pass Jena a functor that would generate IDs so that I can make them globally unique (rather than just unique to the machine). The functor should be used whenever an AnonId is constructed.

public interface IdGenerator {
   public String createId() {
      // create a globally unique ID
      ...
      return uid;
   }
}

这与我之前的问题有关.

编辑:我意识到AnonId具有使用id参数的构造函数.我希望避免在整个地方调用此构造函数,而只是告诉Jena(一次)如何生成ID.

Edit: I realize that AnonId has a constructor that takes an id parameter. I'm hoping to avoid invoking this constructor all over the place, and instead simply tell Jena (once) how to generate IDs.

编辑2 :即使我不介意在各处调用该构造函数,也可能无法实现,因为匿名节点可能是由我无权访问的库代码创建的

Edit 2: Even if I didn't mind invoking that constructor all over the place, it may not be possible because anonymous nodes may be created by library code that I don't have access to.

推荐答案

Jena没有用于插入其他AnonId生成器的钩子. AnonId的创建也不是集中在一个地方,因此也没有一种简单的方法来强制使用new AnonId(String).实现目标的最佳方法是修补AnonId源,这很简单.

Jena doesn't have any hooks for plugging in a different AnonId generator. Creation of AnonIds isn't centralised in one place either, so there isn't an easy way to enforce the use of new AnonId(String) either. The best way of achieving your goal would be to patch the AnonId source, which would be straightforward enough.

FWIW,AnonId代码已经具有两种不同的生成ID的方式,因此在Jena代码库中添加对此的抽象可能是一个合理的想法.

FWIW, the AnonId code already has two different ways of generating the IDs, so adding an abstraction for this to the Jena codebase might be a reasonable idea.

这篇关于生成Jena Bnode ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆