Beispiel #1
0
 private RDFWriter createWriter(StringWriter writer) {
   RDFWriter result = null;
   if (format.equals(Format.TURTLE)) {
     result = new TurtlePrettyPrinter(new MemValueFactory().createURI(baseURI.toString()), writer);
   } else {
     RDFWriterRegistry registry = RDFWriterRegistry.getInstance();
     RDFFormat rawFormat = Rio.getWriterFormatForMIMEType(format.getMime(), RDFFormat.RDFXML);
     RDFWriterFactory factory = registry.get(rawFormat);
     result = factory.getWriter(writer);
     if (format.equals(Format.JSON_LD)) {
       result.getWriterConfig().set(JSONLDSettings.JSONLD_MODE, JSONLDMode.FLATTEN);
       result.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, true);
     }
   }
   return result;
 }
Beispiel #2
0
 private RDFFormat getFormat() {
   return Rio.getWriterFormatForMIMEType(format.getMime(), RDFFormat.TURTLE);
 }