/** Write the DatasetGraph to the output stream in the default serialization for the language. * @param out OutputStream * @param dataset DatasetGraph to write * @param lang Language for the serialization. */ public static void write(OutputStream out, DatasetGraph dataset, Lang lang) { RDFFormat serialization = langToFormatOrException(lang); write(out, dataset, serialization); }
/** Write the DatasetGraph to the output stream in the default serialization for the language. * @param out StringWriter * @param dataset DatasetGraph to write * @param lang Language for the serialization. */ public static void write(StringWriter out, DatasetGraph dataset, Lang lang) { RDFFormat serialization = langToFormatOrException(lang); write(out, dataset, serialization); }
@Override public void writeTo(OutputStream out) { RDFDataMgr.write(out, graph, syntax) ; } } ;
/** Write the model to the output stream in the default serialization for the language. * @param out OutputStream * @param model Graph to write * @param lang Language for the serialization. */ public static void write(OutputStream out, Model model, Lang lang) { write(out, model.getGraph(), lang); }
/** Write the graph to the output stream in the default serialization for the language. * @param out OutputStream * @param model Model to write * @param serialization Serialization format * @deprecated Use of writers is deprecated - use an OutputStream */ @Deprecated public static void write(Writer out, Model model, RDFFormat serialization) { write(out, model.getGraph(), serialization); }
/** Write the graph to the output stream in the default serialization for the language. * @param out OutputStream * @param dataset Dataset to write * @param serialization Serialization format */ public static void write(OutputStream out, Dataset dataset, RDFFormat serialization) { write(out, dataset.asDatasetGraph(), serialization); }
/** Write the graph to the output stream in the default serialization for the language. * @param out Writer * @param model Model to write * @param lang Serialization format * @deprecated Use of writers is deprecated - use an OutputStream */ @Deprecated public static void write(Writer out, Model model, Lang lang) { write(out, model.getGraph(), lang); }
/** Write the graph to the output stream in the default serialization for the language. * @param out OutputStream * @param graph Graph to write * @param lang Language for the serialization. */ public static void write(OutputStream out, Graph graph, Lang lang) { RDFFormat serialization = langToFormatOrException(lang); write(out, graph, serialization); }
/** Write the Dataset to the output stream in the default serialization for the language. * @param out OutputStream * @param dataset Dataset to write * @param lang Language for the serialization. */ public static void write(OutputStream out, Dataset dataset, Lang lang) { write(out, dataset.asDatasetGraph(), lang); }
@Override public void writeTo(OutputStream out) { RDFDataMgr.write(out, graph, syntax) ; } } ;
private ByteArrayOutputStream serializeAsJSON (Graph graph) { ByteArrayOutputStream bout = new ByteArrayOutputStream() ; RDFDataMgr.write(bout, graph, Lang.RDFJSON) ; return bout ; }
@SuppressWarnings("deprecation") @Override protected void writeOutput(Writer writer) { RDFDataMgr.write(writer, this.g, RDFWriterRegistry.defaultSerialization(this.getRdfLanguage())); }
void printFailedDatasetTest(Query query, Dataset expected, Dataset results) { System.out.println("=======================================") ; System.out.println("Failure: "+description()) ; RDFDataMgr.write(System.out, results, Lang.TRIG); System.out.println("---------------------------------------") ; RDFDataMgr.write(System.out, expected, Lang.TRIG); System.out.println() ; }
public static void backup(Location location, OutputStream backupfile) { Dataset ds = TDBFactory.createDataset(location) ; StoreConnection sConn = StoreConnection.make(location) ; DatasetGraphTxn dsg = sConn.begin(TxnType.READ, "backup") ; RDFDataMgr.write(backupfile, dsg, Lang.NQUADS) ; dsg.end(); } }
@SuppressWarnings("deprecation") @Override protected final long writeOutput(Writer writer) { if (this.g.size() == 0) return 0; RDFDataMgr.write(writer, this.g, this.getRdfLanguage()); this.g.clear(); return this.g.size(); }
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
/** Create an HttpEntity for the dataset */ protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
private static void assertNullOrEmpty(Graph graph) { if ( graph == null ) return ; if ( ! graph.isEmpty() ) { System.out.println("----") ; RDFDataMgr.write(System.out, graph, Lang.TTL) ; } assertTrue(graph.isEmpty()) ; }
@Test public void labels_01() { Graph graph = GraphFactory.createGraphMem(); //LabelToNode.createUseLabelEncoded() ; builder() .labelToNode(LabelToNode.createUseLabelAsGiven()) .parse(graph); assertEquals(1, graph.size()); StringWriter sw = new StringWriter(); RDFDataMgr.write(sw, graph, Lang.NT); String s = sw.toString(); assertTrue(s.contains("_:Bb")); }
@Test public void bnode_cycles() { Model m = RDFDataMgr.loadModel("testing/DAWG-Final/construct/data-ident.ttl"); Assert.assertTrue(m.size() > 0); ByteArrayOutputStream output = new ByteArrayOutputStream(); RDFDataMgr.write(output, m, Lang.TURTLE); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); Model m2 = ModelFactory.createDefaultModel(); RDFDataMgr.read(m2, input, Lang.TURTLE); Assert.assertTrue(m2.size() > 0); Assert.assertTrue(m.isIsomorphicWith(m2)); }