public StreamedGraphWriter(OutputStream os) throws IOException { Writer oswriter = new OutputStreamWriter(os, "utf8"); writer = new RdfXmlWriter(oswriter); }
public String extractRDF(boolean ontology, boolean instances, boolean explicit) { SessionContext sc = getContext(); java.io.StringWriter out = new java.io.StringWriter(); RdfXmlWriter documentWriter = new RdfXmlWriter(out); try { _repository.extractRDF(documentWriter, ontology, instances, explicit, true); } catch (Exception e) { e.printStackTrace(); } return out.toString(); }
protected void _writeToFile() { try { OutputStream out = new FileOutputStream(_file); if (_compressFile) { out = new GZIPOutputStream(out, 1024); } RdfDocumentWriter docWriter = null; if (_dataFormat == RDFFormat.RDFXML) { docWriter = new RdfXmlWriter(out); } else if (_dataFormat == RDFFormat.NTRIPLES) { docWriter = new NTriplesWriter(out); } else if (_dataFormat == RDFFormat.TURTLE) { docWriter = new TurtleWriter(out); } else { throw new SailInternalException("Illegal value for data format: " + _dataFormat.toString()); } _exportData(docWriter); out.flush(); out.close(); } catch (IOException e) { throw new SailInternalException(e); } }
/** * Creates a new RdfGraphWriter that will write the received query * results to the supplied <tt>OutputStream</tt>. The <tt>rdfFormat</tt> * parameter controls the serialization format of the written RDF * * @param out The OutputStream to write the RDF to. * @param rdfFormat One of the constants defined in class <tt>RDFFormat</tt>. **/ public RdfGraphWriter(RDFFormat rdfFormat, OutputStream out) throws IOException { _out = out; if (rdfFormat == RDFFormat.RDFXML) { _rdfDocWriter = new RdfXmlWriter(out); } else if (rdfFormat == RDFFormat.NTRIPLES) { _rdfDocWriter = new NTriplesWriter(out); } else if (rdfFormat == RDFFormat.N3) { _rdfDocWriter = new N3Writer(out); } else if (rdfFormat == RDFFormat.TURTLE) { _rdfDocWriter = new TurtleWriter(out); } else { throw new IllegalArgumentException( "Unsupported value for rdfFormat: " + rdfFormat.toString()); } }
public InputStream extractRDF(RDFFormat format, boolean ontology, boolean instances, boolean explicitOnly, boolean niceOutput) throws IOException, AccessDeniedException { _ensureReadAccess(); ByteArrayOutputStream baos = new ByteArrayOutputStream(8092); RdfDocumentWriter rdfDocWriter = null; if (RDFFormat.RDFXML.equals(format)) { rdfDocWriter = new RdfXmlWriter(baos); } else if (RDFFormat.NTRIPLES.equals(format)) { rdfDocWriter = new NTriplesWriter(baos); } else if (RDFFormat.N3.equals(format)) { rdfDocWriter = new N3Writer(baos); } else if (RDFFormat.TURTLE.equals(format)) { rdfDocWriter = new TurtleWriter(baos); } extractRDF(rdfDocWriter, ontology, instances, explicitOnly, niceOutput); return new ByteArrayInputStream(baos.toByteArray()); }
httpOut.setContentType("application/rdf+xml; charset=utf-8"); Writer out = new OutputStreamWriter(httpOut, "UTF-8"); rdfDocWriter = new RdfXmlWriter(out);