Revision: 15220
http://gate.svn.sourceforge.net/gate/?rev=15220&view=rev
Author: johann_p
Date: 2012-01-25 17:40:35 +0000 (Wed, 25 Jan 2012)
Log Message:
-----------
Support retrieval of rows as strings for variables
that may be unbound because of an OPTIONAL clause.
For these variables, the empty string is returned.
Modified Paths:
--------------
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/sesame/UtilTupleQueryIterator.java
Modified:
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/sesame/UtilTupleQueryIterator.java
===================================================================
---
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/sesame/UtilTupleQueryIterator.java
2012-01-25 17:39:03 UTC (rev 15219)
+++
gate/trunk/plugins/Ontology/src/gate/creole/ontology/impl/sesame/UtilTupleQueryIterator.java
2012-01-25 17:40:35 UTC (rev 15220)
@@ -160,12 +160,14 @@
}
}
+ // TODO: make this handle optional values correctly!
public String nextFirstAsString() {
String ret = nextFirstAsValue().stringValue();
//logger.debug("QS: "+ret);
return ret;
}
+ // TODO: make this handle optional values correctly!
public LiteralOrONodeID nextFirst() {
Value v = nextFirstAsValue();
if(v instanceof BNode) {
@@ -182,6 +184,7 @@
}
+ // TODO: make this handle optional values correctly!
public Value nextFirstAsValue() {
if (mResult == null) {
throw new GateOntologyException("No prepared query available");
@@ -197,6 +200,7 @@
return ret;
}
+ // TODO: make this handle optional values correctly!
public Vector<Value> nextAsValue() {
if(!hasNext()) {
throw new GateOntologyException("No more query results but next was
called");
@@ -216,7 +220,8 @@
}
-
+ // if there are optional values the position in the vector that is not
+ // bound will return the empty string!
public Vector<String> nextAsString() {
if (!hasNext()) {
throw new GateOntologyException("No more query results but next was
called");
@@ -226,14 +231,23 @@
BindingSet bindingSet = mResult.next();
for (String bindingName : mVarnames) {
Value value = bindingSet.getValue(bindingName);
+ /* this is not necessarily an error because a binding can be null if
+ * it was part of an OPTIONAL clause
+ * In that case, null will be added to the return vector.
if(value == null) {
throw new GateOntologyException("Could not get binding for name "+
bindingName+
" for binding names "+bindingSet.getBindingNames()+
" for qeury "+mQuery);
}
- String val = value.stringValue();
- result.add(val);
+ *
+ */
+ if(value != null) {
+ String val = value.stringValue();
+ result.add(val);
+ } else {
+ result.add("");
+ }
}
} catch (QueryEvaluationException e) {
throw new GateOntologyException("Could not get next query result", e);
@@ -241,6 +255,7 @@
return result;
}
+ // TODO: make this handle optional values correctly!
public Vector<LiteralOrONodeID> next() {
if(!hasNext()) {
throw new GateOntologyException("No more query results but next was
called");
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs