use of org.apache.jena.riot.RDFFormat in project jena by apache.
the class TestMultipleEmbedded method graphToHttpEntity.
/** Create an HttpEntity for the graph */
protected static HttpEntity graphToHttpEntity(final Graph graph) {
final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS;
ContentProducer producer = new ContentProducer() {
@Override
public void writeTo(OutputStream out) {
RDFDataMgr.write(out, graph, syntax);
}
};
EntityTemplate entity = new EntityTemplate(producer);
ContentType ct = syntax.getLang().getContentType();
entity.setContentType(ct.getContentType());
return entity;
}
use of org.apache.jena.riot.RDFFormat in project jena by apache.
the class TestEmbeddedFuseki method graphToHttpEntity.
/** Create an HttpEntity for the graph */
protected static HttpEntity graphToHttpEntity(final Graph graph) {
final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS;
ContentProducer producer = new ContentProducer() {
@Override
public void writeTo(OutputStream out) {
RDFDataMgr.write(out, graph, syntax);
}
};
EntityTemplate entity = new EntityTemplate(producer);
ContentType ct = syntax.getLang().getContentType();
entity.setContentType(ct.getContentType());
return entity;
}
use of org.apache.jena.riot.RDFFormat in project jena by apache.
the class DatasetGraphAccessorHTTP method graphToHttpEntity.
/** Create an HttpEntity for the graph */
protected HttpEntity graphToHttpEntity(final Graph graph) {
final RDFFormat syntax = getOutboundSyntax();
ContentProducer producer = new ContentProducer() {
@Override
public void writeTo(OutputStream out) {
RDFDataMgr.write(out, graph, syntax);
}
};
EntityTemplate entity = new EntityTemplate(producer);
String ct = syntax.getLang().getContentType().getContentType();
entity.setContentType(ct);
return entity;
}
use of org.apache.jena.riot.RDFFormat in project jena by apache.
the class tdbdump method exec.
@Override
protected void exec() {
DatasetGraph dsg = super.getDatasetGraphTDB();
// Prefer stream over fully pretty output formats.
RDFFormat fmt = modLangOutput.getOutputStreamFormat();
//if ( fmt != null && StreamRDFWriter.registered(fmt) )
if (fmt == null)
fmt = modLangOutput.getOutputFormatted();
if (fmt == null)
// Default.
fmt = RDFFormat.NQUADS;
if (!RDFLanguages.isQuads(fmt.getLang()))
throw new CmdException("Databases can be dumped only in quad formats (e.g. Trig, N-Quads), not " + fmt.getLang());
RDFDataMgr.write(System.out, dsg, fmt);
}
use of org.apache.jena.riot.RDFFormat in project jena by apache.
the class TestJsonLDWriter method roundTrip.
/**
* Write a model and parse it back: you should get the same thing
* (except with frame)
*/
@Test
public final void roundTrip() {
String ns = "http://www.a.com/foo/";
Model m = simpleModel(ns);
m.setNsPrefix("ex", ns);
for (RDFFormat f : JSON_LD_FORMATS) {
if (((RDFFormat.JSONLDVariant) f.getVariant()).isFrame())
continue;
String s = toString(m, f, null);
Model m2 = parse(s);
assertTrue(m2.isIsomorphicWith(m));
}
}
Aggregations