Clone URL (Committers only): https://cms.apache.org/redirect?new=stain;action=diff;uri=http://jena.apache.org/documentation%2Fio%2Fstreaming-io.mdtext
The code examples were wrong.. also I added some Javadoc links. Check - does the table headers render correctly with my patch?cms.apache.org preview didn't render the original table correct either so I can't tell. -- Stian Soiland-Reyes [email protected] Index: trunk/content/documentation/io/streaming-io.mdtext =================================================================== --- trunk/content/documentation/io/streaming-io.mdtext (revision 1655891) +++ trunk/content/documentation/io/streaming-io.mdtext (working copy) @@ -15,49 +15,33 @@ ## `StreamRDF` -The central abstraction is `StreamRDF` which is an interface for streamed +The central abstraction is +[StreamRDF](/documentation/javadoc/arq/org/apache/jena/riot/system/StreamRDF.html) +which is an interface for streamed RDF data. It covers triples and quads, and also parser events such as prefix settings and base URI declarations. - public interface StreamRDF { - /** Start parsing */ - public void start() ; - - /** Triple emitted */ - public void triple(Triple triple) ; - - /** Quad emitted */ - public void quad(Quad quad) ; - - /** base declaration seen */ - public void base(String base) ; - - /** prefix declaration seen */ - public void prefix(String prefix, String iri) ; - - /** Finish parsing */ - public void finish() ; - } - There are utilities to help: -* `StreamRDFLib` -- create `StreamRDF` objects -* `StreamOps` -- helpers for sending RDF data to `StreamRDF` objects +* [StreamRDFLib](/documentation/javadoc/arq/org/apache/jena/riot/system/StreamRDFLib.html) -- create `StreamRDF` objects +* [StreamOps](/documentation/javadoc/arq/org/apache/jena/riot/system/StreamOps.html) -- helpers for sending RDF data to `StreamRDF` objects ## Reading data -All parses of RDF syntaxes provided by RIOT are streaming with the -exception of JSON-LD. A JSON object can have members in any order so the -parser may need the whole top-level object in order to have the information -needed for parsing. +All parses of RDF syntaxes provided by RIOT are streaming, except JSON-LD +(the parser may need the whole top-level object as +a JSON document can list members in any order). -The `parse` functions of `RDFDataMgr` direct the output of the parser to a +The [parse functions](/documentation/javadoc/arq/org/apache/jena/riot/RDFDataMgr.html#parse%28org.apache.jena.riot.system.StreamRDF,%20java.io.InputStream,%20org.apache.jena.riot.Lang%29) + of +[RDFDataMgr](/documentation/javadoc/arq/org/apache/jena/riot/RDFDataMgr.html) +direct the output of the parser to a `StreamRDF`. For example: - StreamRDF destinination = ... + StreamRDF destination = ... RDFDataMgr.parse(destination, "http://example/data.ttl") ; -reads the remote URL, with content negotiation, and send the triples to the +The above code reads the remote URL, with content negotiation, and send the triples to the `destination`. ## Writing data @@ -73,20 +57,23 @@ See ["Streamed Block Formats"](rdf-output.html#streamed-block-formats) for details. -The `StreamRDFWriter` class has functions that write graphs and datasets +The [StreamRDFWriter](/documentation/javadoc/arq/org/apache/jena/riot/system/StreamRDFWriter.html) +class has functions that write graphs and datasets using a streaming writer and also provides for the creation of -an`StreamRDF` backed by a stream-based writer +an `StreamRDF` backed by a stream-based writer: - StreamWriter.write(output, model.getGraph(), lang) ; + StreamRDFWriter.write(output, model.getGraph(), lang) ; which can be done as: - StreamRDF writer = StreamWriter.getWriterStream(output, lang) ; - StreamOps.graphToStream(writer, model.getGraph()) ; + StreamRDF writer = StreamRDFWriter.getWriterStream(output, lang) ; + StreamOps.graphToStream(model.getGraph(), writer) ; N-Triples and N-Quads are always written as a stream. -| RDFFormat | Lang shortcut | +## RDFFormat and Lang + +| [RDFFormat](/documentation/javadoc/arq/org/apache/jena/riot/RDFFormat.html) | [Lang](/documentation/javadoc/arq/org/apache/jena/riot/Lang.html) shortcut | |----------------------------|------------------| | `RDFFormat.TURTLE_BLOCKS` | `Lang.TURTLE` | | `RDFFormat.TURTLE_FLAT` | |
