Search in sources :

Example 21 with StreamRDF

use of org.apache.jena.riot.system.StreamRDF in project jena by apache.

the class NTriplesWriter method write.

@Override
public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context) {
    Iterator<Triple> iter = graph.find(null, null, null);
    if (charSpace == UTF8)
        write(out, iter);
    else {
        StreamRDF s = new WriterStreamRDFPlain(IO.wrapASCII(out), ASCII);
        write$(s, iter);
    }
}
Also used : Triple(org.apache.jena.graph.Triple) StreamRDF(org.apache.jena.riot.system.StreamRDF)

Example 22 with StreamRDF

use of org.apache.jena.riot.system.StreamRDF in project jena by apache.

the class NTriplesWriter method write.

public static void write(OutputStream out, Iterator<Triple> iter, CharSpace charSpace) {
    StreamRDF s = StreamRDFLib.writer(out, charSpace);
    write$(s, iter);
}
Also used : StreamRDF(org.apache.jena.riot.system.StreamRDF)

Example 23 with StreamRDF

use of org.apache.jena.riot.system.StreamRDF in project jena by apache.

the class TurtleWriterFlat method output.

@Override
protected void output(IndentedWriter out, Graph graph, PrefixMap prefixMap, String baseURI, Context context) {
    StreamRDF dest = new WriterStreamRDFFlat(out);
    dest.start();
    dest.base(baseURI);
    StreamOps.sendGraphToStream(graph, dest, prefixMap);
    dest.finish();
}
Also used : StreamRDF(org.apache.jena.riot.system.StreamRDF)

Example 24 with StreamRDF

use of org.apache.jena.riot.system.StreamRDF in project jena by apache.

the class TriGWriterBlocks method output.

@Override
protected void output(IndentedWriter iOut, DatasetGraph dsg, PrefixMap prefixMap, String baseURI, Context context) {
    StreamRDF dest = new WriterStreamRDFBlocks(iOut);
    dest.start();
    dest.base(baseURI);
    StreamOps.sendDatasetToStream(dsg, dest, prefixMap);
    dest.finish();
}
Also used : StreamRDF(org.apache.jena.riot.system.StreamRDF)

Example 25 with StreamRDF

use of org.apache.jena.riot.system.StreamRDF in project jena by apache.

the class REST_Quads_RW method doPutPostTxn.

private void doPutPostTxn(HttpAction action, boolean clearFirst) {
    UploadDetails details = null;
    action.beginWrite();
    try {
        DatasetGraph dsg = action.getActiveDSG();
        if (clearFirst)
            dsg.clear();
        StreamRDF dest = StreamRDFLib.dataset(dsg);
        details = Upload.incomingData(action, dest);
        action.commit();
        ServletOps.success(action);
    } catch (RiotException ex) {
        // Parse error
        action.abort();
        ServletOps.errorBadRequest(ex.getMessage());
    } catch (ActionErrorException ex) {
        action.abort();
        throw ex;
    } catch (Exception ex) {
        // Something else went wrong. Backout.
        action.abort();
        ServletOps.errorOccurred(ex.getMessage());
    } finally {
        action.endWrite();
    }
    ServletOps.uploadResponse(action, details);
}
Also used : RiotException(org.apache.jena.riot.RiotException) StreamRDF(org.apache.jena.riot.system.StreamRDF) RiotException(org.apache.jena.riot.RiotException) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Aggregations

StreamRDF (org.apache.jena.riot.system.StreamRDF)34 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)9 Graph (org.apache.jena.graph.Graph)7 RiotException (org.apache.jena.riot.RiotException)7 Test (org.junit.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 BaseTest (org.apache.jena.atlas.junit.BaseTest)3 Node (org.apache.jena.graph.Node)3 Triple (org.apache.jena.graph.Triple)3 Lang (org.apache.jena.riot.Lang)3 ContentType (org.apache.jena.atlas.web.ContentType)2 FileInputStream (java.io.FileInputStream)1 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 CmdException (jena.cmd.CmdException)1