Commit 6b274671 authored by Christian Willms's avatar Christian Willms
Browse files

added unicode handling for toExpandedString method

parent 68eb49f9
......@@ -1788,10 +1788,10 @@ public final class TupleStore {
// distinguish between URIs vs. XSD atoms or blank nodes
literal = getObject(tuple[i]);
if (TupleStore.isAtom(literal) || TupleStore.isBlankNode(literal))
sb.append(literal.replace("xsd:", this.namespace.getLongForm("xsd")) + " ");
sb.append(toUnicode(literal.replace("xsd:", this.namespace.getLongForm("xsd")) + " "));
else
// a URI
sb.append(this.namespace.expandUri(literal) + " ");
sb.append(toUnicode(this.namespace.expandUri(literal) + " "));
}
sb.append(".");
return sb.toString();
......
......@@ -7,4 +7,6 @@
<test:a7> <test:value> "f<oo>"^^<xsd:string> .
<test:a8> <test:value> "f<"o"o"^^<xsd:string> .
<test:a9> <test:value> "fo<o"^^<xsd:string> .
<test:a10> <test:value> "f<"">o"o"^^<xsd:string> .
\ No newline at end of file
<test:a10> <test:value> "f<"">o"o"^^<xsd:string> .
<test:a11> <test:value> "f<"">o^o"^^<xsd:string> .
<test:a12> <test:value> "f<"">o^^"o"^^<xsd:string> .
......@@ -194,7 +194,7 @@ public class TupleStoreTest {
objectToTest.readTuples(getTestResource("ReadTest", "testAtoms.nt"));
assertEquals("Expected 10 tuples but was " + objectToTest.getAllTuples().size(),
10, objectToTest.getAllTuples().size());
12, objectToTest.getAllTuples().size());
String[][] expected = {
{"\"foo\"^^<xsd:string>"},
{"\"fo\\o\"^^<xsd:string>"},
......@@ -205,7 +205,9 @@ public class TupleStoreTest {
{"\"f<oo>\"^^<xsd:string>"},
{"\"f<\"o\"o\"^^<xsd:string>"},
{"\"fo<o\"^^<xsd:string>"},
{"\"f<\"\">o\"o\"^^<xsd:string>"}
{"\"f<\"\">o\"o\"^^<xsd:string>"},
{"\"f<\"\">o^o\"^^<xsd:string>"},
{"\"f<\"\">o^^\"o\"^^<xsd:string>"}
};
Query q = new Query(objectToTest);
BindingTable bt = q.query("SELECT ?o WHERE ?s <test:value> ?o");
......@@ -233,6 +235,17 @@ public class TupleStoreTest {
for (int[] tuple : objectToTest.getAllTuples()) {
expectedOutput.remove(objectToTest.toString(tuple));
}
bt = q.query("SELECT ?o WHERE ?s <test:value> ?o");
checkResult(expected, bt, "?o");
expectedOutput = new HashSet<String>() {{
add("<test:a1> <test:value> \"Hello foo!\"^^<http://www.w3.org/2001/XMLSchema#string> .");
add("<test:a1> <test:value> \"Hello foo\"^^<http://www.w3.org/2001/XMLSchema#string> .");
add("<test:a2> <test:value> \"\\u00fc foo\"^^<http://www.w3.org/2001/XMLSchema#string> .");
}};
for (int[] tuple : objectToTest.getAllTuples()) {
System.out.println(objectToTest.toExpandedString(tuple));
expectedOutput.remove(objectToTest.toExpandedString(tuple));
}
assertEquals(0, expectedOutput.size());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment