Hi all,

I have encountered a problem with regard to the Sesame 2 driver in the 5.0.7
release. I have attempted to use the RepositoryConnection.getStatements()
method and resulted in an exception thrown complaining an invalid SPARQL
generated. The object value appears to be missing although the "^^" type
declaration can be seen.

I have delved into the code of the VirtuosoRepositoryConnection class and
the stringForValue() method looks suspicious. The problem being the String
"o" is replaced rather than appended to. Here is the patched method that has
fixed the problem

private String stringForValue(Value n) {
        if (n instanceof Resource)
            return stringForResource((Resource) n);
        else if (n instanceof Literal) {
            Literal lit = (Literal) n;
            StringBuffer o = new StringBuffer();
            o.append("\"").append(lit.stringValue()).append("\"");
            if (lit.getLanguage() != null)
                o.append("@").append(lit.getLanguage());
            else if (lit.getDatatype() != null)
                o.append("^^<").append(lit.getDatatype()).append(">");
            return o.toString();
        }
        else return "\"" + n.stringValue() + "\"";
}

Will

Reply via email to