--- a/src/main/scala/SparqlToSql.scala Tue Jun 15 16:11:39 2010 -0700
+++ b/src/main/scala/SparqlToSql.scala Wed Jun 16 12:08:16 2010 -0700
@@ -169,15 +169,20 @@
* <pre>stemURI + '/' (\w+) '/' (\w+) '.' (\w+) '#record'</pre>
*/
def parseObjectURI(u:sparql.Uri):NodeUri = {
- val x:String = u.s
- val uri = new URI(x)
- val path = uri.getPath().split("/").toList.filterNot(_ == "")
- val subPath = path.slice(0, path.size - 2).mkString("/")
- val rel = path(path.size - 2)
- val attrPair = path(path.size-1).split("\\.")
- val stem = uri.getScheme() + "://" + uri.getAuthority + "/" + subPath
- assert("record" == uri.getFragment)
- NodeUri(Stem(stem), Rel(rel), Attr(attrPair(0)), CellValue(attrPair(1)))
+ try {
+ val x:String = u.s
+ val uri = new URI(x)
+ val path = uri.getPath().split("/").toList.filterNot(_ == "")
+ val subPath = path.slice(0, path.size - 2).mkString("/")
+ val rel = path(path.size - 2)
+ val attrPair = path(path.size-1).split("\\.")
+ val stem = uri.getScheme() + "://" + uri.getAuthority + "/" + subPath
+ assert("record" == uri.getFragment)
+ NodeUri(Stem(stem), Rel(rel), Attr(attrPair(0)), CellValue(attrPair(1)))
+ } catch {
+ case e:java.lang.IndexOutOfBoundsException =>
+ throw new Exception("unable to parse " + u + " as an object")
+ }
}
/**
* synthesize a relvar name from a SPARQL term.