Package org.openrdf.rio

Examples of org.openrdf.rio.RDFWriter


            }

            conn.add(result);          
            conn.commit();

            RDFWriter writer = Rio.createWriter(format, outputStream);
            conn.export(writer);
            conn.close();
            repository.shutDown();

            outputStream.flush();
View Full Code Here


     * @throws RDFHandlerException
     */
    private InputStream writeJSONLD(Model statements) throws RDFHandlerException {
        final StringWriter writer = new StringWriter();

        final RDFWriter jsonldWriter = new SesameJSONLDWriter(writer);
        jsonldWriter.startRDF();
        for (final Statement nextStatement : statements) {
            jsonldWriter.handleStatement(nextStatement);
        }
        jsonldWriter.endRDF();

        // System.out.println(writer.toString());

        return new ByteArrayInputStream(writer.toString().getBytes(Charset.forName("UTF-8")));
    }
View Full Code Here

        final Statement st4 = vf.createStatement(uri1, uri2, litWithNewline);
        final Statement st5 = vf.createStatement(uri1, uri2, litWithSingleQuotes);
        final Statement st6 = vf.createStatement(uri1, uri2, litWithDoubleQuotes);

        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final RDFWriter rdfWriter = rdfWriterFactory.getWriter(out);
        final WriterConfig writerConfig = rdfWriter.getWriterConfig();
        writerConfig.set(BasicWriterSettings.RDF_LANGSTRING_TO_LANG_LITERAL, true);
        writerConfig.set(BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL, true);
        rdfWriter.handleNamespace("ex", ex);
        rdfWriter.startRDF();
        rdfWriter.handleStatement(st1);
        rdfWriter.handleStatement(st2);
        rdfWriter.handleStatement(st3);
        rdfWriter.handleStatement(st4);
        rdfWriter.handleStatement(st5);
        rdfWriter.handleStatement(st6);
        rdfWriter.endRDF();

        final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        final RDFParser rdfParser = rdfParserFactory.getParser();
        final ParserConfig config = new ParserConfig();
        config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
View Full Code Here

TOP

Related Classes of org.openrdf.rio.RDFWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.