[Mulgara-svn] r768 - branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter
pag at mulgara.org
pag at mulgara.org
Thu Apr 10 23:19:59 UTC 2008
Author: pag
Date: 2008-04-10 16:19:58 -0700 (Thu, 10 Apr 2008)
New Revision: 768
Modified:
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/TestContext.java
Log:
Added functionality to include nulls as bound objects. These represent unbound values.
Modified: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/TestContext.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/TestContext.java 2008-04-10 23:19:05 UTC (rev 767)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/TestContext.java 2008-04-10 23:19:58 UTC (rev 768)
@@ -23,6 +23,7 @@
/**
* A simple Context used for testing purposes.
+ * This context returns <code>null</code> for unbound values, since it is globalizing.
* @created Mar 31, 2008
* @author Paul Gearon
* @copyright © 2008 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
@@ -95,7 +96,7 @@
public Node globalize(long node) throws QueryException {
Node n = globalizer.get(node);
if (n == null) throw new QueryException("Unable to globalize id <" + node + ">");
- return n;
+ return n != Null.NULL ? n : null;
}
/** @see org.mulgara.query.filter.Context#isBound(int) */
@@ -114,10 +115,18 @@
for (Node[] row: rows) {
assert row.length == columnNames.size();
for (Node v: row) {
+ if (v == null) v = Null.NULL;
Node stored = globalizer.get((long)v.hashCode());
if (stored == null) globalizer.put((long)v.hashCode(), v);
else assert stored == v : "Unexpected hash collision in test";
}
}
}
+
+ /** Testing class used for storing a symbol for <code>null</code> that is disambiguated from a missing value */
+ @SuppressWarnings("serial")
+ private static class Null implements Node {
+ public static final Null NULL = new Null();
+ public int hashCode() { return -1; }
+ }
}
More information about the Mulgara-svn
mailing list