public RIOResultWriter(StatusLog log, RDFFormat rdfFormat, OutputStream out) { super(log); this.out = out; this.writer = Rio.createWriter(rdfFormat, out); }
/** * Creates a new {@link RDFWriter} instance. * * @param format output format. * @param os output stream. * @return writer instance. * @throws IllegalArgumentException if format is not supported. */ public static RDFWriter getWriter(RDFFormat format, OutputStream os) { return Rio.createWriter(format, os); }
/** * Creates a new {@link RDFWriter} instance. * * @param format output format. * @param writer data output writer. * @return writer instance. * @throws IllegalArgumentException if format is not supported. */ public static RDFWriter getWriter(RDFFormat format, Writer writer) { return Rio.createWriter(format, writer); }
public RdfWriter(RDFFormat format, OutputStream output) throws UnsupportedRDFormatException { this(Rio.createWriter(format, output)); }
public NQuadsWriter(OutputStream os) { super( Rio.createWriter(RDFFormat.NQUADS, os) ); }
public RDFWriter(OutputStream os, RDFFormat format) { this.writer = Rio.createWriter(format, os); this.writer.startRDF(); } public RDFWriter(java.io.Writer writer, RDFFormat format) {
public RDFWriter(java.io.Writer writer, RDFFormat format) { this.writer = Rio.createWriter(format, writer); this.writer.startRDF(); } // /////////////////////////////////////////////////////////////////////////
public Rdf4jWriter(OutputStream outputStream, RDFFormat rdfFormat) { writer = new BufferedWriter(new OutputStreamWriter(outputStream, UTF_8)); rdfWriter = Rio.createWriter(rdfFormat, writer); this.rdfFormat = rdfFormat; valueFactory = SimpleValueFactory.getInstance(); rdfWriter.startRDF(); }
public static void main(String[] args) throws IOException, RDFParseException, RDFHandlerException, UnsupportedRDFormatException { if (args.length < 2) { System.out.println("Usage: java org.eclipse.rdf4j.rio.Rio <inputFile> <outputFile>"); System.exit(1); return; } String inputFile = args[0]; String outputFile = args[1]; try (FileOutputStream outStream = new FileOutputStream(outputFile); FileInputStream inStream = new FileInputStream(inputFile);) { createParser(getParserFormatForFileName(inputFile).orElse(RDFFormat.RDFXML)).setRDFHandler( createWriter(getWriterFormatForFileName(outputFile).orElse(RDFFormat.RDFXML), outStream)).parse(inStream, "file:" + inputFile); } }
public static void main(String[] args) throws IOException, RDFParseException, RDFHandlerException, UnsupportedRDFormatException { if (args.length < 2) { System.out.println("Usage: java org.eclipse.rdf4j.rio.Rio <inputFile> <outputFile>"); System.exit(1); return; } String inputFile = args[0]; String outputFile = args[1]; try (FileOutputStream outStream = new FileOutputStream(outputFile); FileInputStream inStream = new FileInputStream(inputFile);) { createParser(getParserFormatForFileName(inputFile).orElse(RDFFormat.RDFXML)).setRDFHandler( createWriter(getWriterFormatForFileName(outputFile).orElse(RDFFormat.RDFXML), outStream)).parse(inStream, "file:" + inputFile); } }
public static void main(String[] args) throws IOException, RDFParseException, RDFHandlerException, UnsupportedRDFormatException { if (args.length < 2) { System.out.println("Usage: java org.eclipse.rdf4j.rio.Rio <inputFile> <outputFile>"); System.exit(1); return; } String inputFile = args[0]; String outputFile = args[1]; try (FileOutputStream outStream = new FileOutputStream(outputFile); FileInputStream inStream = new FileInputStream(inputFile);) { createParser(getParserFormatForFileName(inputFile).orElse(RDFFormat.RDFXML)).setRDFHandler( createWriter(getWriterFormatForFileName(outputFile).orElse(RDFFormat.RDFXML), outStream)).parse(inStream, "file:" + inputFile); } }
/** * Writes the given single statement to the given {@link OutputStream} in the given format. * * @param st * The statement to be written. * @param output * The {@link OutputStream} to write the statement to. * @param dataFormat * The {@link RDFFormat} to use when writing the statement. * @param settings * The {@link WriterConfig} containing setting for configuring the writer. * @throws RDFHandlerException * Thrown if there is an error writing the statement. * @throws UnsupportedRDFormatException * If no {@link RDFWriter} is available for the specified RDF format. */ public static void write(Statement st, OutputStream output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException { final RDFWriter writer = Rio.createWriter(dataFormat, output); writer.setWriterConfig(settings); write(st, writer); }
@Override public void exportData(KnowledgeBase kb, RDFFormat format, OutputStream os) { if (kb.getType() != RepositoryType.LOCAL) { log.info("Not exporting non-local knowledge base: [{}]", kb.getName()); return; } try (RepositoryConnection conn = getConnection(kb)) { RDFWriter rdfWriter = Rio.createWriter(format, os); conn.export(rdfWriter); } }
private void translateRDFDocument(final InputStream in, final OutputStream out, final RDFFormat inFormat, final RDFFormat outFormat, final String baseURI) throws SailException, IOException, RDFHandlerException, RDFParseException { RDFParser p = Rio.createParser(inFormat); RDFWriter w = Rio.createWriter(outFormat, out); p.setRDFHandler(w); p.parse(in, baseURI); } }
@Override public void exportData(KnowledgeBase kb, RDFFormat format, OutputStream os) { if (kb.getType() != RepositoryType.LOCAL) { log.info("Not exporting non-local knowledge base: [{}]", kb.getName()); return; } try (RepositoryConnection conn = getConnection(kb)) { RDFWriter rdfWriter = Rio.createWriter(format, os); conn.export(rdfWriter); } }
@Override public void execute(SesamizeArgs args) throws Exception { Long totalTriples = Long.valueOf(args.nonOptions.get(1)); RDFFormat outputFormat = args.getRDFFormat(RDFFormat.RDFXML, "o", "outputFormat"); OutputStream os = System.out; RandomValueFactory rvf = new RandomValueFactory( SimpleValueFactory.getInstance()); RDFWriter writer = Rio.createWriter(outputFormat, os); writer.startRDF(); for (long l = 0L; l < totalTriples; l++) { Statement st = rvf.randomStatement(); writer.handleStatement(st); } writer.endRDF(); os.close(); } }
private void dumpNativeStoreToRDFDocument(final File nativeStoreDirectory, final File dumpFile, final RDFFormat format, final Resource... contexts) throws SailException, RepositoryException, IOException, RDFHandlerException { logger.info("dumping store at " + nativeStoreDirectory + " to file " + dumpFile); Sail sail = new NativeStore(nativeStoreDirectory); sail.initialize(); try { Repository repo = new SailRepository(sail); try (RepositoryConnection rc = repo.getConnection()) { try (OutputStream out = new FileOutputStream(dumpFile)) { RDFHandler h = Rio.createWriter(format, out); rc.export(h, contexts); } } } finally { sail.shutDown(); } } }
@Override public void write(OutputStream outputStream) throws IOException, WebApplicationException { RDFWriter writer = Rio.createWriter(getFormat(acceptHeaderParam), outputStream); SimpleValueFactory valueFactory = SimpleValueFactory.getInstance(); handleNamespaces(writer, gds); writer.startRDF(); try (Transaction tx = gds.beginTx()) { Map<String, String> mappings = getMappingsFromDB(gds); Node node = (Node) gds.getNodeById(idParam); processNodeInLPG(writer, valueFactory, mappings, node, onlyMappedInfo!=null); if (excludeContextParam == null) { processRelsOnLPG(writer, valueFactory, mappings, node, onlyMappedInfo!=null); } writer.endRDF(); }catch(NotFoundException e){ writer.endRDF(); } }
private static RDFWriter getRioWriter(OutputStream stream) throws RDFHandlerException { RDFWriter writer = Rio.createWriter(RDFFormat.JSONLD, stream); writer.handleNamespace("sp", "https://streampipes.org/vocabulary/v1/"); writer.handleNamespace("ssn", "http://purl.oclc.org/NET/ssnx/ssn#"); writer.handleNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); writer.handleNamespace("empire", "urn:clarkparsia.com:empire:"); writer.handleNamespace("spi", "urn:streampipes.org:spi:"); writer.getWriterConfig().set(JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT); writer.getWriterConfig().set(JSONLDSettings.OPTIMIZE, true); writer.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, true); return writer; }
private static RDFWriter getRioWriter(OutputStream stream) throws RDFHandlerException { RDFWriter writer = Rio.createWriter(RDFFormat.JSONLD, stream); writer.handleNamespace("sp", "https://streampipes.org/vocabulary/v1/"); writer.handleNamespace("ssn", "http://purl.oclc.org/NET/ssnx/ssn#"); writer.handleNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); writer.handleNamespace("empire", "urn:clarkparsia.com:empire:"); writer.handleNamespace("spi", "urn:streampipes.org:spi:"); writer.getWriterConfig().set(JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT); writer.getWriterConfig().set(JSONLDSettings.OPTIMIZE, true); writer.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, true); return writer; }