Search in sources :

Example 1 with RDFWriterFactory

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);
}
Also used : RDFWriterFactory(org.openrdf.rio.RDFWriterFactory) N3WriterFactory(org.openrdf.rio.n3.N3WriterFactory) RDFWriter(org.openrdf.rio.RDFWriter)

Example 2 with RDFWriterFactory

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);
}
Also used : RDFWriterFactory(org.openrdf.rio.RDFWriterFactory) RDFXMLWriterFactory(org.openrdf.rio.rdfxml.RDFXMLWriterFactory) RDFWriter(org.openrdf.rio.RDFWriter)

Example 3 with RDFWriterFactory

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();
}
Also used : RDFWriterFactory(org.openrdf.rio.RDFWriterFactory) Statement(org.openrdf.model.Statement) RDFWriter(org.openrdf.rio.RDFWriter)

Aggregations

RDFWriter (org.openrdf.rio.RDFWriter)3 RDFWriterFactory (org.openrdf.rio.RDFWriterFactory)3 Statement (org.openrdf.model.Statement)1 N3WriterFactory (org.openrdf.rio.n3.N3WriterFactory)1 RDFXMLWriterFactory (org.openrdf.rio.rdfxml.RDFXMLWriterFactory)1