use of fr.lirmm.graphik.util.DefaultURI in project graal by graphik-team.
the class DlgpWriterTest method bug76.
@Test
public void bug76() throws IOException {
Prefix p1 = new Prefix("a", "http://p#");
Prefix p2 = new Prefix("b", "http://p#p/");
Predicate p = new Predicate(new DefaultURI("http://p#p/toto"), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(p1);
writer.write(p2);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("b:toto(<A>)."));
}
use of fr.lirmm.graphik.util.DefaultURI in project graal by graphik-team.
the class DlgpWriterTest method writeURIForbiddenChars.
@Test
public void writeURIForbiddenChars() throws IOException {
Predicate p = new Predicate(new DefaultURI("/< >\"{}|^`\\/"), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
System.out.println(s);
Assert.assertEquals("</\\u003c\\u0020\\u003e\\u0022\\u007b\\u007d\\u007c\\u005e\\u0060\\u005c/>(<A>).\n", s);
}
use of fr.lirmm.graphik.util.DefaultURI in project graal by graphik-team.
the class AbstractRDFListener method handleStatement.
@Override
public void handleStatement(Statement st) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(st.toString());
}
Predicate predicate = new Predicate(new DefaultURI(st.getPredicate().toString()), 2);
Term subject = DefaultTermFactory.instance().createConstant(new DefaultURI(st.getSubject().toString()));
Term object;
fr.lirmm.graphik.util.URI datatype;
if (st.getObject() instanceof Literal) {
Literal l = (Literal) st.getObject();
if (l.getDatatype() == null) {
datatype = URIUtils.RDF_LANG_STRING;
} else {
datatype = new fr.lirmm.graphik.util.DefaultURI(l.getDatatype().getNamespace(), l.getDatatype().getLocalName());
}
String value = l.getLabel();
if (datatype.equals(URIUtils.RDF_LANG_STRING)) {
value += "@" + l.getLanguage();
}
object = DefaultTermFactory.instance().createLiteral(datatype, value);
} else {
object = DefaultTermFactory.instance().createConstant(new DefaultURI(st.getObject().toString()));
}
DefaultAtom a = new DefaultAtom(predicate, subject, object);
this.createAtom(a);
}
use of fr.lirmm.graphik.util.DefaultURI in project graal by graphik-team.
the class DlgpWriterTest method bugIllegalCharInPrefixedName.
@Test
public void bugIllegalCharInPrefixedName() throws IOException {
Prefix p1 = new Prefix("a", "http://p#");
Predicate p = new Predicate(new DefaultURI("http://p#to@to"), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(p1);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("<http://p#to@to>(<A>)."));
}
use of fr.lirmm.graphik.util.DefaultURI in project graal by graphik-team.
the class DlgpWriterTest method writeValideURI.
@Test
public void writeValideURI() throws IOException {
String uri = "/a//a///a////a/////a//////" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "´áéíóúýàèìòùỳ¨äëïöüÿâêîôûŷ" + "?¿.:,;!¡~'" + "0123456789₀₁₂₃₄₅₆₇₈₉₍₎₊₋₌ₐₑₒₓₔ⁰¹⁴⁵⁶⁷⁸⁹⁺⁽⁾⁼⁻" + "+-*%=()[]«»_—–#" + "ßæœçåÅøØĐħĦ" + "€$¤£" + "¶¦¬©®™ªº♯♮♭" + "ΑΒΔΕΦΓΗΙΘΚΛΜΝΟΠΧΡΣΤΥΩΞΨΖαβδεφγηιθκλμνοπχρστυωξψζ" + "‰≃≠≮≯≤≥≰≱≲≳Ω¼½¾ƒℓ⅓⅔⅛⅜⅝⅞⩽⩾←↑→↓↔↦⇒⇔∂∙∏∑∆∇√∞∫≈≡∀∃∈∉∪∩⊂⊃♀♂ℝℂℚℕℤℍ⊥‖∧∨⟦⟧⟨⟩∘" + // unbreakable spaces
" " + "////";
Predicate p = new Predicate(new DefaultURI(uri), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("<" + uri + ">(<A>)."));
}
Aggregations