[redland-dev] Patch for Model class in JAVA bindings
Attilio Fiandrotti
fiandro at tiscali.it
Sat Jun 17 11:51:35 BST 2006
Hi
i noticed that when i call Model.getTarget() with an unexisting target,
a new Node is created even if librdf_model_get_target() returned null,
and so it's not possible for the user detecting if a target was found or
not.
With the attached patch ( that i guess should be applied also to
getSource(), getArc(), getFeature() ) the user is able to detect a
search with no results with something like
Node obj = model.getTarget( <my source> ,<my arc> );
if ( obj == null ) {
//manage missing target
}
Attilio
ps
any chance to fix the other bug [1] i reported some times ago?
[1] http://lists.gnomehack.com/pipermail/redland-dev/2006-June/001336.html
Index: java/org/librdf/redland/Model.java
===================================================================
--- java/org/librdf/redland/Model.java (revisione 10984)
+++ java/org/librdf/redland/Model.java (copia locale)
@@ -181,7 +181,11 @@
public Node getTarget(Node source, Node arc)
{
- return new Node(this.world,
core.librdf_model_get_target(this.object, source.__get_object(),
arc.__get_object()), true);+ long node =
core.librdf_model_get_target(this.object, source.__get_object(),
arc.__get_object());
+ if (node == 0)
+ return null;
+ else
+ return new Node(this.world, node);
}
public Node getFeature(URI feature)
More information about the redland-dev
mailing list