use of org.openrdf.rio.RDFWriterFactory in project qi4j-sdk by Qi4j.
the class ApplicationXmlTest method writeN3.
private void writeN3(Iterable<Statement> graph) throws RDFHandlerException, IOException {
RDFWriterFactory writerFactory = new N3WriterFactory();
RDFWriter writer = writerFactory.getWriter(System.out);
writeOutput(writer, graph);
}
use of org.openrdf.rio.RDFWriterFactory in project qi4j-sdk by Qi4j.
the class ApplicationXmlTest method writeXml.
private void writeXml(Iterable<Statement> graph) throws RDFHandlerException, IOException {
RDFWriterFactory writerFactory = new RDFXMLWriterFactory();
RDFWriter writer = writerFactory.getWriter(System.out);
writeOutput(writer, graph);
}
use of org.openrdf.rio.RDFWriterFactory in project qi4j-sdk by Qi4j.
the class AbstractSerializer method serialize.
@Override
public void serialize(Iterable<Statement> graph, Writer out, String[] namespacePrefixes, String[] namespaces) throws RDFHandlerException {
RDFWriterFactory writerFactory;
try {
writerFactory = writerFactoryClass.newInstance();
} catch (InstantiationException e) {
throw new InternalError();
} catch (IllegalAccessException e) {
throw new InternalError();
}
RDFWriter writer = writerFactory.getWriter(out);
writer.startRDF();
for (int i = 0; i < namespacePrefixes.length; i++) {
String namespacePrefix = namespacePrefixes[i];
String namespace = namespaces[i];
writer.handleNamespace(namespacePrefix, namespace);
}
for (Statement st : graph) {
writer.handleStatement(st);
}
writer.endRDF();
}
Aggregations