@Override public void startPrefixMapping(String prefix, String uri) { output.prefix(prefix, uri) ; }
@Override public void startPrefixMapping(String prefix, String uri) { output.prefix(prefix, uri) ; }
private void emitPrefix(String prefix, String iriStr, StreamRDF dest) { dest.prefix(prefix, iriStr); }
private final void emitPrefix(String prefix, String iriStr) { dest.prefix(prefix, iriStr) ; }
@Override public void prefix(String prefix, String iri) { other.prefix(prefix, iri) ; }
@Override public void prefix(String prefix, String iri) { wrapped.prefix(prefix, iri); }
private final void emitPrefix(String prefix, String iriStr) { dest.prefix(prefix, iriStr) ; }
@Override public void prefix(String prefix, String iri) { sink.prefix(prefix, iri) ; }
protected static void writePrefixes(StreamRDF dest, PrefixMap prefixMap) { if ( prefixMap != null ) { for ( Entry<String, String> e : prefixMap.getMappingCopyStr().entrySet()) dest.prefix(e.getKey(), e.getValue()) ; } }
/** Send a PrefixMap to a stream */ public static void sendPrefixesToStream(PrefixMap prefixMap, StreamRDF stream) { prefixMap.forEach((p,u) -> stream.prefix(p, u.toString())) ; }
public void setPrefix(int line, int column, String prefix, String iri) { /*temporary*/ getPrologue().setPrefix(prefix, iri); stream.prefix(prefix, iri); }
@Override public void visit(RDF_PrefixDecl prefixDecl) { String prefix = prefixDecl.getPrefix() ; String iriStr = prefixDecl.getUri() ; try { pmap.add(prefix, iriStr) ; } catch (RiotException ex) {} dest.prefix(prefix, iriStr) ; }
private static void serializeBlockStreamed(final RdfStream rdfStream, final OutputStream output, final RDFFormat format, final Map<String, String> nsPrefixes) { final Set<String> namespacesPresent = new HashSet<>(); final StreamRDF stream = new SynchonizedStreamRDFWrapper(getWriterStream(output, format)); stream.start(); // Must read the rdf stream before writing out ns prefixes, otherwise the prefixes come after the triples final List<Triple> tripleList = rdfStream.peek(t -> { // Collect the namespaces present in the RDF stream, using the same // criteria for where to look that jena's model.listNameSpaces() does namespacesPresent.add(t.getPredicate().getNameSpace()); if (RDF_TYPE.equals(t.getPredicate().getURI()) && t.getObject().isURI()) { namespacesPresent.add(t.getObject().getNameSpace()); } }).collect(Collectors.toList()); nsPrefixes.forEach((prefix, uri) -> { // Only add namespace prefixes if the namespace is present in the rdf stream if (namespacesPresent.contains(uri)) { stream.prefix(prefix, uri); } }); tripleList.forEach(stream::triple); stream.finish(); }
output.prefix(namespace.getKey(), namespace.getValue());
private static void bodyAsGraph(HttpAction action, StreamRDF dest) { HttpServletRequest request = action.request ; String base = ActionLib.wholeRequestURL(request) ; ContentType ct = FusekiNetLib.getContentType(request) ; Lang lang = RDFLanguages.contentTypeToLang(ct.getContentType()) ; if ( lang == null ) { ServletOps.errorBadRequest("Unknown content type for triples: " + ct) ; return ; } InputStream input = null ; try { input = request.getInputStream() ; } catch (IOException ex) { IO.exception(ex) ; } // Don't log - assemblers are typically small. // Adding this to the log confuses things. // Reserve logging for data uploads. // long len = request.getContentLengthLong() ; // if ( action.verbose ) { // if ( len >= 0 ) // alog.info(format("[%d] Body: Content-Length=%d, Content-Type=%s, Charset=%s => %s", action.id, len, // ct.getContentType(), ct.getCharset(), lang.getName())) ; // else // alog.info(format("[%d] Body: Content-Type=%s, Charset=%s => %s", action.id, ct.getContentType(), // ct.getCharset(), lang.getName())) ; // } dest.prefix("root", base+"#"); ActionLib.parse(action, dest, input, lang, base) ; } }
public void writeTurtle(String baseIRI, PrefixMapping prefixes, boolean writeBase) { // Auto-register RDF prefix so that rdf:type is displayed well // All other prefixes come from the query and should be as author intended prefixes = ensureRDFPrefix(prefixes); if (writeBase) { // Jena's streaming Turtle writers don't output base even if it is provided, // so we write it directly. IndentedWriter w = new IndentedWriter(out); RiotLib.writeBase(w, baseIRI); w.flush(); } StreamRDF writer = new WriterStreamRDFBlocks(out); if (dedupWindowSize > 0) { writer = new StreamRDFDedup(writer, dedupWindowSize); } writer.start(); writer.base(baseIRI); for (Entry<String, String> e : prefixes.getNsPrefixMap().entrySet()) { writer.prefix(e.getKey(), e.getValue()); } StreamOps.sendTriplesToStream(triples, writer); writer.finish(); }
private static void bodyAsGraph(HttpAction action, StreamRDF dest) { HttpServletRequest request = action.request ; String base = ActionLib.wholeRequestURL(request) ; ContentType ct = FusekiNetLib.getContentType(request) ; Lang lang = RDFLanguages.contentTypeToLang(ct.getContentType()) ; if ( lang == null ) { ServletOps.errorBadRequest("Unknown content type for triples: " + ct) ; return ; } InputStream input = null ; try { input = request.getInputStream() ; } catch (IOException ex) { IO.exception(ex) ; } // Don't log - assemblers are typically small. // Adding this to the log confuses things. // Reserve logging for data uploads. // long len = request.getContentLengthLong() ; // if ( action.verbose ) { // if ( len >= 0 ) // alog.info(format("[%d] Body: Content-Length=%d, Content-Type=%s, Charset=%s => %s", action.id, len, // ct.getContentType(), ct.getCharset(), lang.getName())) ; // else // alog.info(format("[%d] Body: Content-Type=%s, Charset=%s => %s", action.id, ct.getContentType(), // ct.getCharset(), lang.getName())) ; // } dest.prefix("root", base+"#"); ActionLib.parse(action, dest, input, lang, base) ; } }