生成 Jena Bnode ID
有没有办法覆盖 Jena 生成匿名节点 ID 的默认方法?
理想情况下,我想向 Jena 传递一个生成 ID 的函子,以便我可以使它们全局唯一(而不仅仅是机器唯一)。 每当构造 AnonId 时都应该使用函子。
public interface IdGenerator {
public String createId() {
// create a globally unique ID
...
return uid;
}
}
这与我之前的问题有些相关。
编辑:我意识到 AnonId 有一个带有 id 参数的构造函数。 我希望避免到处调用这个构造函数,而只是告诉 Jena(一次)如何生成 ID。
编辑2:即使我不介意到处调用该构造函数,这也可能是不可能的,因为匿名节点可能是由我无权访问的库代码创建的。
Is there a way to override Jena's default method for generating anonymous node IDs?
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;
}
}
This is somewhat related to my previous question.
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jena 没有任何用于插入不同
AnonId
生成器的钩子。AnonId
的创建也不是集中在一个地方,因此也没有一种简单的方法来强制使用new AnonId(String)
。 实现目标的最佳方法是修补AnonId
源,这非常简单。FWIW,
AnonId
代码已经有两种不同的方式来生成 ID,因此将其抽象添加到 Jena 代码库可能是一个合理的想法。Jena doesn't have any hooks for plugging in a different
AnonId
generator. Creation ofAnonId
s isn't centralised in one place either, so there isn't an easy way to enforce the use ofnew AnonId(String)
either. The best way of achieving your goal would be to patch theAnonId
source, which would be straightforward enough.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.