You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/09/20 09:33:35 UTC

[2/2] jena git commit: Rename RIOT examples to make them easier to browse.

Rename RIOT examples to make them easier to browse.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/1669b75f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/1669b75f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/1669b75f

Branch: refs/heads/master
Commit: 1669b75fdbffef99d93f4cc6350e043d7c7ccb58
Parents: 7ae0b7f
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Sep 20 10:33:10 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Sep 20 10:33:27 2018 +0100

----------------------------------------------------------------------
 .../arq/examples/riot/ExJsonLD.java             | 380 -------------------
 .../arq/examples/riot/ExRIOT1_ReadModel.java    |  52 +++
 .../arq/examples/riot/ExRIOT2_ReadDataset.java  |  45 +++
 .../arq/examples/riot/ExRIOT3_RDFParser.java    |  57 +++
 .../examples/riot/ExRIOT4_StreamRDF_Filter.java |  64 ++++
 .../examples/riot/ExRIOT5_StreamRDFCollect.java |  48 +++
 .../arq/examples/riot/ExRIOT6_AddNewReader.java | 117 ++++++
 .../arq/examples/riot/ExRIOT7_ParserPiped.java  |  73 ++++
 .../arq/examples/riot/ExRIOT_1.java             |  52 ---
 .../arq/examples/riot/ExRIOT_2.java             |  57 ---
 .../arq/examples/riot/ExRIOT_3.java             |  45 ---
 .../arq/examples/riot/ExRIOT_4.java             |  80 ----
 .../arq/examples/riot/ExRIOT_5.java             | 117 ------
 .../arq/examples/riot/ExRIOT_6.java             |  73 ----
 .../arq/examples/riot/ExRIOT_7.java             |  48 ---
 .../arq/examples/riot/ExRIOT_out1.java          |  48 ---
 .../arq/examples/riot/ExRIOT_out2.java          |  47 ---
 .../arq/examples/riot/ExRIOT_out3.java          | 107 ------
 .../arq/examples/riot/ExRIOTw1_writeModel.java  |  48 +++
 .../arq/examples/riot/ExRIOTw2_writeRDF.java    |  47 +++
 .../examples/riot/ExRIOTw3_AddNewWriter.java    | 107 ++++++
 .../arq/examples/riot/Ex_WriteJsonLD.java       | 380 +++++++++++++++++++
 22 files changed, 1038 insertions(+), 1054 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExJsonLD.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExJsonLD.java b/jena-arq/src-examples/arq/examples/riot/ExJsonLD.java
deleted file mode 100644
index 21e5d67..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExJsonLD.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StringReader;
-
-import com.github.jsonldjava.core.JsonLdOptions;
-
-import org.apache.jena.query.DatasetFactory;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.riot.JsonLDWriteContext;
-import org.apache.jena.riot.RDFDataMgr;
-import org.apache.jena.riot.RDFFormat;
-import org.apache.jena.riot.WriterDatasetRIOT;
-import org.apache.jena.riot.system.PrefixMap;
-import org.apache.jena.riot.system.RiotLib;
-import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.util.Context;
-import org.apache.jena.vocabulary.RDF;
-import org.apache.jena.vocabulary.RDFS;
-
-/** Example writing as JSON-LD */
-public class ExJsonLD
-{
-    public static void main(String[] args) {
-        (new ExJsonLD()).doIt();
-    }
-
-    void doIt() {
-        doSimpleStuff();
-        moreControl();
-    }
-
-    /**
-     * Simple stuff.
-     * 
-     * output using defaults, 
-     * in "expanded"", compacted" or "flattened" format
-     * (framed is more difficult, not handled here)
-     */
-    void doSimpleStuff() {
-        Model m = aSimpleModel();
-
-        // to get a default output: just do like for any other lang
-        System.out.println("--- DEFAULT ---");
-        m.write(System.out, "JSON-LD");
-
-        // same thing, using the more modern RDFDataMgr, and specifying the RDFFormat
-        System.out.println("\n--- DEFAULT ---");
-        RDFDataMgr.write(System.out, m, RDFFormat.JSONLD);
-
-        // output can be pretty (with line breaks), or not
-        System.out.println("\n--- DEFAULT, PRETTY (same as above, BTW) ---");
-        RDFDataMgr.write(System.out, m, RDFFormat.JSONLD_PRETTY);
-
-        System.out.println("\n--- DEFAULT, FLAT ---");
-        RDFDataMgr.write(System.out, m, RDFFormat.JSONLD_FLAT);
-
-        // all these default outputs use the JsonLD "Compact" format
-        // (note the "@context" node in the output)
-
-        // if prefixes are defined in the model,
-        // they are used in computing the @context,
-        // and corresponding values are displayed as prefix:localname
-        // (note something nice wrt prefixes in jsonld: look in the output at the value of "seeAlso")
-        m.setNsPrefix("ex", "http://www.ex.com/");
-        m.setNsPrefix("sh", "http://schema.org/");
-        System.out.println("\n--- DEFAULT, model including prefix mappings ---");
-        RDFDataMgr.write(System.out, m, RDFFormat.JSONLD_PRETTY);
-
-        // Besides "Compact", JSON-LD defines the following kinds of outputs: expanded, flattened, and framed
-        // For each of them, there is a dedicated RDFFormat -- actually, 2 of them (one pretty, one flat)
-        // As previously seen, RDFFormat.JSONLD is just an alias of RDFFormat.JSONLD_COMPACT_PRETYY
-        // Let's try the other ones:
-
-        // Expand is the fastest one
-        // no @context in it
-        System.out.println("\n--- EXPAND ---");
-        RDFDataMgr.write(System.out, m, RDFFormat.JSONLD_EXPAND_PRETTY);
-
-        // flatten has an @context node
-        System.out.println("\n--- FLATTEN ---");
-        RDFDataMgr.write(System.out, m, RDFFormat.JSONLD_FLATTEN_PRETTY);
-
-        // framed requires some more parameters to run, we'll get back to it later
-    }
-
-
-    /**
-     * To get more control about the output,
-     * we have to use a mechanism provided by jena to pass information
-     * to the writing process
-     * 
-     * This requires a few lines of code, see {@link #write(DatasetGraph, RDFFormat, Context)}
-     * 
-     * Here we use this write method to see what can be customized.
-     */
-    public void moreControl() {
-        Model m = aSimpleModel();
-        m.setNsPrefix("ex", "http://www.ex.com/");
-        m.setNsPrefix("sh", "http://schema.org/");
-
-        // the write method takes a DatasetGraph as input to represent the data that we want to output
-        // Let's create one from our model:
-        DatasetGraph g = DatasetFactory.wrap(m).asDatasetGraph();
-
-        // and let's use the write method to output the data in json-ld compact format,
-        // passing a null Context for the moment
-        // (remember, "Context" here is not to be confused with "@context" in JSON-LD,
-        // see {@link #write(DatasetGraph, RDFFormat, Context)})
-        System.out.println("\n--- COMPACT with a null Context: same result as default ---");
-        write(g, RDFFormat.JSONLD_COMPACT_PRETTY, null);
-
-        // A Context is just a way to pass implementation-specific parameters as named values
-        // to a given general interface (the WriterDatasetRIOT, in this case).
-        // In order to make it easier to define the named values relevant here,
-        // there is a subclass of Context that defines setters for the values:
-        // the JsonLDWriteContext class
-
-        // so, the way to proceed is:
-        // JsonLDWriteContext ctx = new JsonLDWriteContext();       
-        // ctx.setSomething(...)
-        // write(g, RDFFormat.JSONLD_COMPACT_PRETTY, ctx);
-
-        // let's see now what can be customized with the JsonLDWriteContext object
-
-        controllingAtContext();
-        settingAtContextToURI();
-        frame();
-        controllingJsonLDApiOptions();
-    }
-
-
-    /**
-     * Shows how to customize the "@context" in "compacted" and "flattened" format.
-     * 
-     * To set it to the URI of a vocab, {@link #settingAtContextToURI()}
-     */
-    void controllingAtContext() {
-        Model m = aSimpleModel();
-        m.setNsPrefix("ex", "http://www.ex.com/");
-        m.setNsPrefix("sh", "http://schema.org/");
-        DatasetGraph g = DatasetFactory.wrap(m).asDatasetGraph();
-        JsonLDWriteContext ctx = new JsonLDWriteContext();
-
-        // When no value for the "@context" is provided, 
-        // Jena computes one from the defined prefixes, and from the RDF content.
-        // This default is probably good enough in most of the cases, 
-        // but you may want to customize it. 
-        // Or, if it is always the same one, you may consider that computing it again and again
-        // (each time that you output data), is a waste of time.
-        // (the computing of the "@context" implies to loop through all the triples).
-        // You may therefore want to compute it once for all, and to pass it to the output process
-
-        // To pass a given "@context" to the writing process,
-        // you pass the corresponding value as a JSON string
-        // using the setJsonLDContext(String) method.
-        // (Alternatively, you can directly pass the object expected by the JSON-LD API)
-
-        // For instance, we can pass a simple context 
-        // that uses jsonld "@vocab" keyord to set the "default vocabulary"
-        // to schema.org.
-        String atContextAsJson = "{\"@vocab\":\"http://schema.org/\"}";
-        ctx.setJsonLDContext(atContextAsJson);
-        System.out.println("\n--- COMPACT using a Context that defines @vocab ---");
-        write(g, RDFFormat.JSONLD_COMPACT_PRETTY, ctx);
-    }
-
-    /**
-     * Shows how to set "@context" to a URI.
-     */
-    void settingAtContextToURI() {
-        // One thing you'll probably want to do is to set the "@context" to the URL of a file
-        // containing the actual JSON-LD context.
-
-        // Let's take one Model that only uses schema.org terms,
-        // and let's try to set the "@Context" to the URL of schema.org 
-        // "@context" : "http://schema.org/"
-
-        Model m = aModelThatOnlyUsesSchemaDotOrg();
-        DatasetGraph g = DatasetFactory.wrap(m).asDatasetGraph();
-        JsonLDWriteContext ctx = new JsonLDWriteContext();
-
-        // The following should work, but unfortunately it doesn't (with JSONLD-java 0.8.3):
-        ctx.setJsonLDContext("\"http://schema.org/\"");
-        System.out.println("\n--- Setting the context to a URI, WRONG WAY: it's slow, and the output is not JSON-LD. Sorry about that. ---");
-        write(g, RDFFormat.JSONLD_COMPACT_PRETTY, ctx);
-
-        // But don't worry (be happy): 
-        // - there is a solution
-        // - and what we tried is not what we would want to do, anyway.
-        
-        // The output process needs to have the content of the "@context" at hand
-        // in order to compute the output. So, if passing the URL of the vocab,
-        // the output process must download the vocab before anything.
-        // (that's why the previous attempt was slow)
-        // -> that would not be an very efficient way to output your data.
-        // -> it doesn't work, (with JSONLD-java 0.8.3), but no regret.
-
-        // To achieve the expected result,
-        // you have to do 2 things:
-
-        // 1)
-        // you have to pass the dereferenced content of http://schema.org/
-        // - or the relevant subset of it (as we only use very few terms).
-        // Here it is:
-        String atContextAsJson = "{\"name\":{\"@id\":\"http://schema.org/name\"},\"Person\": {\"@id\": \"http://schema.org/Person\"}}";
-        ctx.setJsonLDContext(atContextAsJson);
-        // Alternatively, we could just pass "null":
-        // ctx.setJsonLDContext(null);
-        // and let jena compute the context (as the model only uses schema.org vocab)
-
-        // 2)
-        // and then you pass the schema.org url using:
-        ctx.setJsonLDContextSubstitution("\"http://schema.org/\"");
-
-        // To summarize:
-        // - ctx.setJsonLDContext allows to define the @context used to compute the output
-        // - ctx.setJsonLDContextSubstitution allows to change the value of the "@context" in the output
-        System.out.println("\n--- COMPACT with @context replaced by schema.org URI ---");
-        write(g, RDFFormat.JSONLD_COMPACT_PRETTY, ctx);
-
-        // Final note: BEWARE when replacing the context:
-        // if you let some things undefined, the output will be json, not jsonld
-
-    }
-
-    /**
-     * Shows how to apply a frame to the output RDF data
-     */
-    void frame() {
-        // a "frame" is a specific graph layout that is applied to output data
-        // It can be used to filter the output data.
-        // In this example, we show how to output only the resources of a givn rdf:type
-        
-        Model m = ModelFactory.createDefaultModel();
-        String ns = "http://schema.org/";
-        Resource person = m.createResource(ns + "Person");
-        Resource s = m.createResource();
-        m.add(s, m.createProperty(ns + "name"), "Jane Doe");
-        m.add(s, m.createProperty(ns + "url"), "http://www.janedoe.com");
-        m.add(s, m.createProperty(ns + "jobTitle"), "Professor");
-        m.add(s, RDF.type, person);
-        s = m.createResource();
-        m.add(s, m.createProperty(ns + "name"), "Gado Salamatou");
-        m.add(s, m.createProperty(ns + "url"), "http://www.salamatou.com");
-        m.add(s, RDF.type, person);
-        s = m.createResource();
-        m.add(s, m.createProperty(ns + "name"), "Not a person");
-        m.add(s, RDF.type, m.createResource(ns + "Event"));
-
-        DatasetGraph g = DatasetFactory.wrap(m).asDatasetGraph();
-        JsonLDWriteContext ctx = new JsonLDWriteContext();
-
-        // only output the persons using a frame
-        
-        String frame = "{\"@type\" : \"http://schema.org/Person\"}";
-        ctx.setFrame(frame);
-        System.out.println("\n--- Using frame to select resources to be output: only output persons ---");
-        write(g, RDFFormat.JSONLD_FRAME_PRETTY, ctx);
-    }
-
-    /**
-     *  the JSON-LD java API (that jena uses for JSON-LD I/O) defines a set of options
-     *  that can be customized
-     */
-    void controllingJsonLDApiOptions() {
-        Model m = aSimpleModel();
-        m.setNsPrefix("ex", "http://www.ex.com/");
-        m.setNsPrefix("sh", "http://schema.org/");
-        DatasetGraph g = DatasetFactory.wrap(m).asDatasetGraph();
-        JsonLDWriteContext ctx = new JsonLDWriteContext();
-        JsonLdOptions opts = new JsonLdOptions();
-        ctx.setOptions(opts);
-        opts.setCompactArrays(false); // default is true
-        System.out.println("\n--- COMPACT with CompactArrays false: there is an @graph node");
-        write(g, RDFFormat.JSONLD_COMPACT_PRETTY, ctx);
-    }
-
-    /**
-     * Write RDF data as JSON-LD.
-     * 
-     * To get more control about the output,
-     * we have to use a mechanism provided by jena to pass information
-     * to the writing process (cf. org.apache.jena.riot.WriterDatasetRIOT and the "Context" mechanism).
-     * For that, we have to create a WriterDatasetRIOT (a one-time use object)
-     * and we pass a "Context" object (not to be confused with the "@context" in JSON-LD) as argument to its write method
-     * 
-     * @param out
-     * @param f RDFFormat of the output, eg. RDFFormat.JSONLD_COMPACT_PRETTY
-     * @param g the data that we want to output as JSON-LD
-     * @param ctx the object that allows to control the writing process (a set of parameters)
-     */
-    void write(OutputStream out, DatasetGraph g, RDFFormat f, Context ctx) {
-        // create a WriterDatasetRIOT with the RDFFormat
-        WriterDatasetRIOT w = RDFDataMgr.createDatasetWriter(f) ;
-        PrefixMap pm = RiotLib.prefixMap(g);
-        String base = null;
-        w.write(out, g, pm, base, ctx) ;     
-    }
-
-    /** Write RDF data to the console */
-    private void write(DatasetGraph g, RDFFormat f, Context ctx) {
-        write(System.out, g, f, ctx);
-    }
-
-    // following 2 methods: if you want to test
-    // that everything is OK in a roundtrip: model -> jsonld -> model
-    // something like:
-    // String jsonld = write2String(g, RDFFormat.JSONLD_COMPACT_PRETTY, ctx);
-    // Model m2 = parse(jsonld);
-    // System.out.println("ISO : " + m.isIsomorphicWith(m2));
-
-    /** Write RDF data into a String */
-    private String write2String(DatasetGraph g, RDFFormat f, Context ctx) {
-        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-            write(out, g, f, ctx);
-            out.flush();
-            return out.toString("UTF-8");
-        } catch (IOException e) { throw new RuntimeException(e); }
-    }
-
-    /** Parse a jsonld string into a Model */
-    private Model parse(String jsonld) {
-        Model m = ModelFactory.createDefaultModel();
-        StringReader reader = new StringReader(jsonld);
-        m.read(reader, null, "JSON-LD");
-        return m;
-    }
-
-    private Model aSimpleModel() {
-        Model m = ModelFactory.createDefaultModel();
-        String ns = "http://schema.org/";
-        Resource person = m.createResource(ns + "Person");
-        Resource s;
-        s = m.createResource("http://www.ex.com/janedoe");
-        m.add(s, m.createProperty(ns + "name"), "Jane Doe");
-        m.add(s, RDF.type, person);
-        m.add(s, RDFS.seeAlso, m.createResource("http://www.ex.com/janedoe/moreinfo"));
-        //        m.add(s, m.createProperty(ns + "url"), "http://www.janedoe.com");
-        //        m.add(s, m.createProperty(ns + "jobTitle"), "Professor");
-        //        s = m.createResource();
-        //        m.add(s, m.createProperty(ns + "name"), "Salamatou Gado");
-        //        m.add(s, m.createProperty(ns + "url"), "http://www.salamatou.com");
-        return m;
-    }
-
-    private Model aModelThatOnlyUsesSchemaDotOrg() {
-        Model m = ModelFactory.createDefaultModel();
-        String ns = "http://schema.org/";
-        Resource person = m.createResource(ns + "Person");
-        Resource s;
-        s = m.createResource("http://www.ex.com/janedoe");
-        m.add(s, m.createProperty(ns + "name"), "Jane Doe");
-        m.add(s, RDF.type, person);
-        return m;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT1_ReadModel.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT1_ReadModel.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT1_ReadModel.java
new file mode 100644
index 0000000..0de67c9
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT1_ReadModel.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.riot.RDFLanguages ;
+
+/** Example of using RIOT with Jena readers.
+ * An application can use model.read or RDFDataMgr.
+ */
+public class ExRIOT1_ReadModel
+{
+    public static void main(String...argv)
+    {
+        Model m = ModelFactory.createDefaultModel() ;
+        // read into the model.
+        m.read("data.ttl") ;
+        
+        // Alternatively, use the RDFDataMgr, which reads from the web,
+        // with content negotiation.  Plain names are assumed to be 
+        // local files where file extension indicates the syntax.  
+        
+        Model m2 = RDFDataMgr.loadModel("data.ttl") ;
+        
+        // read in more data, the remote server serves up the data
+        // with the right MIME type.
+        RDFDataMgr.read(m2, "http://host/some-published-data") ;
+        
+        
+        // Read some data but also give a hint for the synatx if it is not
+        // discovered by inspecting the file or by HTTP content negotiation.  
+        RDFDataMgr.read(m2, "some-more-data.out", RDFLanguages.TURTLE) ;
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT2_ReadDataset.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT2_ReadDataset.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT2_ReadDataset.java
new file mode 100644
index 0000000..5697013
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT2_ReadDataset.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import static org.apache.jena.riot.RDFLanguages.TRIG ;
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.riot.RDFDataMgr ;
+
+/** Example of using RIOT : reading data into datasets. */
+public class ExRIOT2_ReadDataset
+{
+    public static void main(String...argv)
+    {
+        Dataset ds = null ;
+        
+        // Read a TriG file into quad storage in-memory.
+        ds = RDFDataMgr.loadDataset("data.trig") ;
+        
+        // read some (more) data into a dataset graph.
+        RDFDataMgr.read(ds, "data2.trig") ;
+        
+        // Create a dataset,
+        Dataset ds2 = DatasetFactory.createTxnMem() ;
+        // read in data, indicating the syntax in case the remote end does not
+        // correctly provide the HTTP content type.
+        RDFDataMgr.read(ds2, "http://host/data2.unknown", TRIG) ;
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT3_RDFParser.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT3_RDFParser.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT3_RDFParser.java
new file mode 100644
index 0000000..ff447f1
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT3_RDFParser.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import java.io.FileInputStream ;
+import java.io.IOException ;
+import java.io.InputStream ;
+
+import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.riot.RDFParser ;
+import org.apache.jena.riot.system.ErrorHandlerFactory ;
+import org.apache.jena.riot.system.StreamRDF ;
+import org.apache.jena.riot.system.StreamRDFLib ;
+
+/** Example of using RIOT directly.
+ * 
+ * The parsers produce a stream of triples and quads so processing does not need
+ * to hold everything in memory at the same time. See also {@code ExRIOT_4}
+ */
+public class ExRIOT3_RDFParser
+{
+    public static void main(String...argv) throws IOException
+    {
+        // ---- Parse to a Sink.
+        StreamRDF noWhere = StreamRDFLib.sinkNull() ;
+
+        // --- Or create a parser and do the parsing with detailed setup.
+        String baseURI = "http://example/base" ;
+        
+        // It is always better to use an InputStream, rather than a Java Reader.
+        // The parsers will do the necessary character set conversion.  
+        try (InputStream in = new FileInputStream("data.trig")) {
+            RDFParser.create()
+                .source(in)
+                .lang(RDFLanguages.TRIG)
+                .errorHandler(ErrorHandlerFactory.errorHandlerStrict)
+                .base("http://example/base")
+                .parse(noWhere);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT4_StreamRDF_Filter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT4_StreamRDF_Filter.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT4_StreamRDF_Filter.java
new file mode 100644
index 0000000..567d0de
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT4_StreamRDF_Filter.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.riot.RDFParser;
+import org.apache.jena.riot.system.StreamRDF;
+import org.apache.jena.riot.system.StreamRDFLib;
+import org.apache.jena.riot.system.StreamRDFWrapper;
+import org.apache.jena.sparql.vocabulary.FOAF;
+
+/** Example of using RIOT : extract only certain properties from a parser run */
+public class ExRIOT4_StreamRDF_Filter {
+    public static void main(String...argv) {
+        String filename = "data.ttl";
+
+        // Write a stream out. 
+        StreamRDF output = StreamRDFLib.writer(System.out);
+        
+        // Wrap in a filter.
+        StreamRDF filtered = new FilterSinkRDF(output, FOAF.name, FOAF.knows);
+
+        // Call the parsing process.
+        RDFParser.source(filename).parse(filtered);
+    }
+
+    // The filtering StreamRDF
+    static class FilterSinkRDF extends StreamRDFWrapper {
+        private final Node[] properties;
+
+        FilterSinkRDF(StreamRDF dest, Property...properties) {
+            super(dest);
+            this.properties = new Node[properties.length];
+            for ( int i = 0 ; i < properties.length ; i++ )
+                this.properties[i] = properties[i].asNode();
+        }
+
+        @Override
+        public void triple(Triple triple) {
+            for ( Node p : properties ) {
+                if ( triple.getPredicate().equals(p) )
+                    super.triple(triple);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT5_StreamRDFCollect.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT5_StreamRDFCollect.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT5_StreamRDFCollect.java
new file mode 100644
index 0000000..da71275
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT5_StreamRDFCollect.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.riot.RDFParser ;
+import org.apache.jena.riot.lang.CollectorStreamBase;
+import org.apache.jena.riot.lang.CollectorStreamTriples;
+
+/**
+ * Example of using RIOT for streaming RDF to be stored into a Collection.
+ * 
+ * Suitable for single-threaded parsing, for use with small data or distributed 
+ * computing frameworks (e.g. Hadoop) where the overhead of creating many threads
+ * is significant. 
+ * 
+ * @see CollectorStreamBase
+ */
+public class ExRIOT5_StreamRDFCollect {
+
+    public static void main(String... argv) {
+        final String filename = "data.ttl";
+        
+        CollectorStreamTriples inputStream = new CollectorStreamTriples();
+        RDFParser.source(filename).parse(inputStream);
+
+        for (Triple triple : inputStream.getCollected()) {
+        	System.out.println(triple);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT6_AddNewReader.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT6_AddNewReader.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT6_AddNewReader.java
new file mode 100644
index 0000000..0c24a59
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT6_AddNewReader.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Iterator;
+
+import org.apache.jena.atlas.logging.LogCtl;
+import org.apache.jena.atlas.web.ContentType;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.LangBuilder;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFLanguages;
+import org.apache.jena.riot.RDFParserRegistry;
+import org.apache.jena.riot.ReaderRIOT;
+import org.apache.jena.riot.ReaderRIOTFactory;
+import org.apache.jena.riot.adapters.RDFReaderRIOT;
+import org.apache.jena.riot.system.ErrorHandler;
+import org.apache.jena.riot.system.ErrorHandlerFactory;
+import org.apache.jena.riot.system.ParserProfile;
+import org.apache.jena.riot.system.StreamRDF;
+import org.apache.jena.sparql.sse.Item;
+import org.apache.jena.sparql.sse.SSE;
+import org.apache.jena.sparql.sse.builders.BuilderGraph;
+import org.apache.jena.sparql.util.Context;
+
+/** Example of using RIOT : register a new input language */
+public class ExRIOT6_AddNewReader
+{
+    static { LogCtl.setCmdLogging(); }
+    
+    public static void main(String... argv) {
+        Lang lang = LangBuilder.create("SSE", "text/x-sse").addFileExtensions("rsse").build();
+        // This just registers the name, not the parser.
+        RDFLanguages.register(lang);
+
+        // Register the parser factory.
+        ReaderRIOTFactory factory = new SSEReaderFactory();
+        RDFParserRegistry.registerLangTriples(lang, factory);
+
+        // use it ... inline data
+        String x = "(graph (<s> <p1> 123) (<s> <p2> 456) )"; 
+        // Model.read( , "SSE")
+        Model model = ModelFactory.createDefaultModel();
+        RDFDataMgr.read(model, new StringReader(x), "http://example/", lang);
+        // print results.
+        RDFDataMgr.write(System.out, model, Lang.TTL);      
+    }
+
+    static class SSEReaderFactory implements ReaderRIOTFactory
+    {
+        @Override
+        public ReaderRIOT create(Lang language, ParserProfile profile) {
+            return new SSEReader();
+        }
+    }
+
+    static class SSEReader implements ReaderRIOT
+    {
+        private ErrorHandler errorHandler = ErrorHandlerFactory.getDefaultErrorHandler();
+        
+        // This is just an example - it reads a graph in
+        // http://jena.apache.org/documentation/notes/sse.html
+        // format. It is not a streaming parser; it creates some triples,
+        // then send them to the output. This style might be useful for creating
+        // triples from a converter process or program.
+
+        @Override
+        public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context) {
+            Item item = SSE.parse(in);
+            read(item, baseURI, ct, output, context);
+        }
+
+        @Override
+        public void read(Reader in, String baseURI, ContentType ct, StreamRDF output, Context context) {
+            Item item = SSE.parse(in);
+            read(item, baseURI, ct, output, context);
+        }
+
+        private void read(Item item, String baseURI, ContentType ct, StreamRDF output, Context context) {
+            Graph graph = BuilderGraph.buildGraph(item);
+            Iterator<Triple> iter = graph.find(null, null, null);
+            for (; iter.hasNext(); )
+                output.triple(iter.next());
+        }
+    }
+
+    // Model.read adapter - must be public.
+    public static class RDFReaderSSE extends RDFReaderRIOT
+    {
+        public RDFReaderSSE() {
+            super("SSE");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT7_ParserPiped.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT7_ParserPiped.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT7_ParserPiped.java
new file mode 100644
index 0000000..0581fed
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOT7_ParserPiped.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import java.util.concurrent.ExecutorService ;
+import java.util.concurrent.Executors ;
+
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.riot.RDFParser ;
+import org.apache.jena.riot.lang.PipedRDFIterator ;
+import org.apache.jena.riot.lang.PipedRDFStream ;
+import org.apache.jena.riot.lang.PipedTriplesStream ;
+
+/**
+ * Example of using RIOT : iterate over output of parser run using a
+ * {@link PipedRDFStream} and a {@link PipedRDFIterator}
+ * 
+ */
+public class ExRIOT7_ParserPiped {
+
+    public static void main(String... argv) {
+        final String filename = "data.ttl";
+
+        // Create a PipedRDFStream to accept input and a PipedRDFIterator to
+        // consume it
+        // You can optionally supply a buffer size here for the
+        // PipedRDFIterator, see the documentation for details about recommended
+        // buffer sizes
+        PipedRDFIterator<Triple> iter = new PipedRDFIterator<>();
+        final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);
+
+        // PipedRDFStream and PipedRDFIterator need to be on different threads
+        ExecutorService executor = Executors.newSingleThreadExecutor();
+
+        // Create a runnable for our parser thread
+        Runnable parser = new Runnable() {
+
+            @Override
+            public void run() {
+                RDFParser.source(filename).parse(inputStream);
+            }
+        };
+
+        // Start the parser on another thread
+        executor.submit(parser);
+
+        // We will consume the input on the main thread here
+
+        // We can now iterate over data as it is parsed, parsing only runs as
+        // far ahead of our consumption as the buffer size allows
+        while (iter.hasNext()) {
+            Triple next = iter.next();
+            // Do something with each triple
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_1.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_1.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_1.java
deleted file mode 100644
index afec982..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_1.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.riot.RDFLanguages ;
-
-/** Example of using RIOT with Jena readers.
- * An application can use model.read or RDFDataMgr.
- */
-public class ExRIOT_1
-{
-    public static void main(String...argv)
-    {
-        Model m = ModelFactory.createDefaultModel() ;
-        // read into the model.
-        m.read("data.ttl") ;
-        
-        // Alternatively, use the RDFDataMgr, which reads from the web,
-        // with content negotiation.  Plain names are assumed to be 
-        // local files where file extension indicates the syntax.  
-        
-        Model m2 = RDFDataMgr.loadModel("data.ttl") ;
-        
-        // read in more data, the remote server serves up the data
-        // with the right MIME type.
-        RDFDataMgr.read(m2, "http://host/some-published-data") ;
-        
-        
-        // Read some data but also give a hint for the synatx if it is not
-        // discovered by inspectying the file or by HTTP content negotiation.  
-        RDFDataMgr.read(m2, "some-more-data.out", RDFLanguages.TURTLE) ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_2.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_2.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_2.java
deleted file mode 100644
index 34ba514..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_2.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import java.io.FileInputStream ;
-import java.io.IOException ;
-import java.io.InputStream ;
-
-import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.riot.RDFParser ;
-import org.apache.jena.riot.system.ErrorHandlerFactory ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.riot.system.StreamRDFLib ;
-
-/** Example of using RIOT directly.
- * 
- * The parsers produce a stream of triples and quads so processing does not need
- * to hold everything in memory at the same time. See also {@code ExRIOT_4}
- */
-public class ExRIOT_2
-{
-    public static void main(String...argv) throws IOException
-    {
-        // ---- Parse to a Sink.
-        StreamRDF noWhere = StreamRDFLib.sinkNull() ;
-
-        // --- Or create a parser and do the parsing with detailed setup.
-        String baseURI = "http://example/base" ;
-        
-        // It is always better to use an InputStream, rather than a Java Reader.
-        // The parsers will do the necessary character set conversion.  
-        try (InputStream in = new FileInputStream("data.trig")) {
-            RDFParser.create()
-                .source(in)
-                .lang(RDFLanguages.TRIG)
-                .errorHandler(ErrorHandlerFactory.errorHandlerStrict)
-                .base("http://example/base")
-                .parse(noWhere);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_3.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_3.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_3.java
deleted file mode 100644
index 7289dfa..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_3.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import static org.apache.jena.riot.RDFLanguages.TRIG ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.riot.RDFDataMgr ;
-
-/** Example of using RIOT : reading data into datasets. */
-public class ExRIOT_3
-{
-    public static void main(String...argv)
-    {
-        Dataset ds = null ;
-        
-        // Read a TriG file into quad storage in-memory.
-        ds = RDFDataMgr.loadDataset("data.trig") ;
-        
-        // read some (more) data into a dataset graph.
-        RDFDataMgr.read(ds, "data2.trig") ;
-        
-        // Create a dataset,
-        Dataset ds2 = DatasetFactory.createTxnMem() ;
-        // read in data, indicating the syntax in case the remote end does not
-        // correctly provide the HTTP content type.
-        RDFDataMgr.read(ds2, "http://host/data2.unknown", TRIG) ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_4.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_4.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_4.java
deleted file mode 100644
index 38bbb86..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_4.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import org.apache.jena.atlas.lib.Sink ;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.rdf.model.Property ;
-import org.apache.jena.riot.RDFParser ;
-import org.apache.jena.riot.out.SinkTripleOutput ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.riot.system.StreamRDFBase ;
-import org.apache.jena.riot.system.SyntaxLabels ;
-import org.apache.jena.sparql.vocabulary.FOAF ;
-
-/** Example of using RIOT : extract only certain properties from a parser run */ 
-public class ExRIOT_4
-{
-    public static void main(String...argv)
-    {
-        String filename = "data.ttl" ;
-
-        // This is the heart of N-triples printing ... outoput is heavily buffered
-        // so the FilterSinkRDF called flush at the end of parsing.
-        Sink<Triple> output = new SinkTripleOutput(System.out, null, SyntaxLabels.createNodeToLabel()) ;
-        StreamRDF filtered = new FilterSinkRDF(output, FOAF.name, FOAF.knows) ;
-        
-        // Call the parsing process.
-        RDFParser.source(filename).parse(filtered);
-    }
-    
-    static class FilterSinkRDF extends StreamRDFBase
-    {
-        private final Node[] properties ;
-        // Where to send the filtered triples.
-        private final Sink<Triple> dest ;
-
-        FilterSinkRDF(Sink<Triple> dest, Property... properties)
-        {
-            this.dest = dest ;
-            this.properties = new Node[properties.length] ;
-            for ( int i = 0 ; i < properties.length ; i++ ) 
-                this.properties[i] = properties[i].asNode() ;
-        }
-
-        @Override
-        public void triple(Triple triple)
-        {
-            for ( Node p : properties )
-            {
-                if ( triple.getPredicate().equals(p) )
-                    dest.send(triple) ;
-            }
-        }
-        
-        @Override
-        public void finish()
-        {
-            // Output may be buffered.
-            dest.flush() ;
-        }
-    }
-}
- 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_5.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_5.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_5.java
deleted file mode 100644
index e6bd556..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_5.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Iterator;
-
-import org.apache.jena.atlas.logging.LogCtl;
-import org.apache.jena.atlas.web.ContentType;
-import org.apache.jena.graph.Graph;
-import org.apache.jena.graph.Triple;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.rdf.model.ModelFactory;
-import org.apache.jena.riot.Lang;
-import org.apache.jena.riot.LangBuilder;
-import org.apache.jena.riot.RDFDataMgr;
-import org.apache.jena.riot.RDFLanguages;
-import org.apache.jena.riot.RDFParserRegistry;
-import org.apache.jena.riot.ReaderRIOT;
-import org.apache.jena.riot.ReaderRIOTFactory;
-import org.apache.jena.riot.adapters.RDFReaderRIOT;
-import org.apache.jena.riot.system.ErrorHandler;
-import org.apache.jena.riot.system.ErrorHandlerFactory;
-import org.apache.jena.riot.system.ParserProfile;
-import org.apache.jena.riot.system.StreamRDF;
-import org.apache.jena.sparql.sse.Item;
-import org.apache.jena.sparql.sse.SSE;
-import org.apache.jena.sparql.sse.builders.BuilderGraph;
-import org.apache.jena.sparql.util.Context;
-
-/** Example of using RIOT : register a new input language */
-public class ExRIOT_5
-{
-    static { LogCtl.setCmdLogging(); }
-    
-    public static void main(String... argv) {
-        Lang lang = LangBuilder.create("SSE", "text/x-sse").addFileExtensions("rsse").build();
-        // This just registers the name, not the parser.
-        RDFLanguages.register(lang);
-
-        // Register the parser factory.
-        ReaderRIOTFactory factory = new SSEReaderFactory();
-        RDFParserRegistry.registerLangTriples(lang, factory);
-
-        // use it ... inline data
-        String x = "(graph (<s> <p1> 123) (<s> <p2> 456) )"; 
-        // Model.read( , "SSE")
-        Model model = ModelFactory.createDefaultModel();
-        RDFDataMgr.read(model, new StringReader(x), "http://example/", lang);
-        // print results.
-        RDFDataMgr.write(System.out, model, Lang.TTL);      
-    }
-
-    static class SSEReaderFactory implements ReaderRIOTFactory
-    {
-        @Override
-        public ReaderRIOT create(Lang language, ParserProfile profile) {
-            return new SSEReader();
-        }
-    }
-
-    static class SSEReader implements ReaderRIOT
-    {
-        private ErrorHandler errorHandler = ErrorHandlerFactory.getDefaultErrorHandler();
-        
-        // This is just an example - it reads a graph in
-        // http://jena.apache.org/documentation/notes/sse.html
-        // format. It is not a streaming parser; it creates some triples,
-        // then send them to the output. This style might be useful for creating
-        // triples from a converter process or program.
-
-        @Override
-        public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context) {
-            Item item = SSE.parse(in);
-            read(item, baseURI, ct, output, context);
-        }
-
-        @Override
-        public void read(Reader in, String baseURI, ContentType ct, StreamRDF output, Context context) {
-            Item item = SSE.parse(in);
-            read(item, baseURI, ct, output, context);
-        }
-
-        private void read(Item item, String baseURI, ContentType ct, StreamRDF output, Context context) {
-            Graph graph = BuilderGraph.buildGraph(item);
-            Iterator<Triple> iter = graph.find(null, null, null);
-            for (; iter.hasNext(); )
-                output.triple(iter.next());
-        }
-    }
-
-    // Model.read adapter - must be public.
-    public static class RDFReaderSSE extends RDFReaderRIOT
-    {
-        public RDFReaderSSE() {
-            super("SSE");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_6.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_6.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_6.java
deleted file mode 100644
index 4ca85e8..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_6.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import java.util.concurrent.ExecutorService ;
-import java.util.concurrent.Executors ;
-
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.riot.RDFParser ;
-import org.apache.jena.riot.lang.PipedRDFIterator ;
-import org.apache.jena.riot.lang.PipedRDFStream ;
-import org.apache.jena.riot.lang.PipedTriplesStream ;
-
-/**
- * Example of using RIOT : iterate over output of parser run using a
- * {@link PipedRDFStream} and a {@link PipedRDFIterator}
- * 
- */
-public class ExRIOT_6 {
-
-    public static void main(String... argv) {
-        final String filename = "data.ttl";
-
-        // Create a PipedRDFStream to accept input and a PipedRDFIterator to
-        // consume it
-        // You can optionally supply a buffer size here for the
-        // PipedRDFIterator, see the documentation for details about recommended
-        // buffer sizes
-        PipedRDFIterator<Triple> iter = new PipedRDFIterator<>();
-        final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);
-
-        // PipedRDFStream and PipedRDFIterator need to be on different threads
-        ExecutorService executor = Executors.newSingleThreadExecutor();
-
-        // Create a runnable for our parser thread
-        Runnable parser = new Runnable() {
-
-            @Override
-            public void run() {
-                RDFParser.source(filename).parse(inputStream);
-            }
-        };
-
-        // Start the parser on another thread
-        executor.submit(parser);
-
-        // We will consume the input on the main thread here
-
-        // We can now iterate over data as it is parsed, parsing only runs as
-        // far ahead of our consumption as the buffer size allows
-        while (iter.hasNext()) {
-            Triple next = iter.next();
-            // Do something with each triple
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_7.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_7.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_7.java
deleted file mode 100644
index ee34407..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_7.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.riot.RDFParser ;
-import org.apache.jena.riot.lang.CollectorStreamBase;
-import org.apache.jena.riot.lang.CollectorStreamTriples;
-
-/**
- * Example of using RIOT for streaming RDF to be stored into a Collection.
- * 
- * Suitable for single-threaded parsing, for use with small data or distributed 
- * computing frameworks (e.g. Hadoop) where the overhead of creating many threads
- * is significant. 
- * 
- * @see CollectorStreamBase
- */
-public class ExRIOT_7 {
-
-    public static void main(String... argv) {
-        final String filename = "data.ttl";
-        
-        CollectorStreamTriples inputStream = new CollectorStreamTriples();
-        RDFParser.source(filename).parse(inputStream);
-
-        for (Triple triple : inputStream.getCollected()) {
-        	System.out.println(triple);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_out1.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_out1.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_out1.java
deleted file mode 100644
index 7dea76f..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_out1.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.riot.* ;
-
-/** Example writing a model with RIOT */
-public class ExRIOT_out1
-{
-    public static void main(String[] args)
-    {
-        Model model = RDFDataMgr.loadModel("D.ttl") ;
-        
-        System.out.println() ;
-        System.out.println("#### ---- Write as Turtle") ;
-        System.out.println() ;
-        RDFDataMgr.write(System.out, model, Lang.TURTLE) ;
-        
-        System.out.println() ;
-        System.out.println("#### ---- Write as Turtle (streaming)") ;
-        System.out.println() ;
-        RDFDataMgr.write(System.out, model, RDFFormat.TURTLE_BLOCKS) ;
-        
-        System.out.println() ;
-        System.out.println("#### ---- Write as Turtle via model.write") ;
-        System.out.println() ;
-        model.write(System.out, "TTL") ;
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_out2.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_out2.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_out2.java
deleted file mode 100644
index d17fe90..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_out2.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-
-/** Other writer examples */
-public class ExRIOT_out2
-{
-    public static void main(String[] args)
-    {
-        Model model = RDFDataMgr.loadModel("D.ttl") ;
-        System.out.println() ;
-        System.out.println("#### ---- Write as TriG") ;
-        System.out.println() ;
-        // This wil be the default graph of the dataset written.
-        RDFDataMgr.write(System.out, model, Lang.TRIG) ;
-        
-        // Loading Turtle as Trig reads into the default graph.
-        Dataset dataset = RDFDataMgr.loadDataset("D.ttl") ;
-        System.out.println() ;
-        System.out.println("#### ---- Write as NQuads") ;
-        System.out.println() ;
-        RDFDataMgr.write(System.out, dataset, Lang.NQUADS) ;
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOT_out3.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOT_out3.java b/jena-arq/src-examples/arq/examples/riot/ExRIOT_out3.java
deleted file mode 100644
index ac7c26e..0000000
--- a/jena-arq/src-examples/arq/examples/riot/ExRIOT_out3.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package arq.examples.riot;
-
-import java.io.OutputStream ;
-import java.io.Writer ;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.riot.* ;
-import org.apache.jena.riot.adapters.RDFWriterRIOT ;
-import org.apache.jena.riot.system.PrefixMap ;
-import org.apache.jena.riot.system.RiotLib ;
-import org.apache.jena.riot.writer.WriterGraphRIOTBase ;
-import org.apache.jena.sparql.sse.SSE ;
-import org.apache.jena.sparql.util.Context ;
-
-/** Example of registering a new writer with RIOT */
-public class ExRIOT_out3
-{
-    static { LogCtl.setCmdLogging(); }
-    
-    // See also ExRIOT_5
-    public static void main(String[] args)
-    {
-        System.out.println("## Example of a registering a new language with RIOT") ; 
-        System.out.println() ;
-        
-        // Register the language
-        Lang lang = LangBuilder.create("SSE", "text/x-sse").addFileExtensions("rsse").build() ;
-        RDFLanguages.register(lang) ;
-
-        // Create format and register the association of language and default format.
-        // We are creating only one format here but in geenral theer can be variants
-        // (e.g. TURTLE - pretty printed or streamed) 
-        RDFFormat format = new RDFFormat(lang) ;
-        RDFWriterRegistry.register(lang, format)  ;
-        
-        // Register the writer factory
-        RDFWriterRegistry.register(format, new SSEWriterFactory()) ;
-
-        // ---- Use the register writer
-        Model model = RDFDataMgr.loadModel("/home/afs/tmp/D.ttl") ;
-        // Write
-        System.out.println("## Write by format") ;
-        RDFDataMgr.write(System.out, model, format) ;
-        System.out.println() ;
-        System.out.println("## Write by language") ;
-        RDFDataMgr.write(System.out, model, lang) ;
-        
-        // ---- Or use Model.write
-        System.out.println("## Write by Model.write") ;
-        model.write(System.out, "SSE") ;
-    }
-    
-    static class SSEWriterFactory implements WriterGraphRIOTFactory
-    {
-        @Override
-        public WriterGraphRIOT create(RDFFormat syntaxForm)
-        {
-            return new SSEWriter() ;
-        }
-    }
-    
-    static class SSEWriter extends WriterGraphRIOTBase
-    {
-        // Ignore externally provided prefix map and baseURI
-        @Override
-        public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
-        {
-            SSE.write(out, graph) ;
-        }
-
-        @Override
-        public Lang getLang()   { return  RDFLanguages.contentTypeToLang("text/x-sse") ; }
-
-        @Override
-        public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
-        {
-            // Writers are discouraged : just hope the charset is UTF-8.
-            IndentedWriter x = RiotLib.create(out) ;
-            SSE.write(x, graph) ;
-        }
-    }
-
-    // Model.write adapter - must be public.
-    public static class RDFWriterSSE extends RDFWriterRIOT { public RDFWriterSSE() { super("SSE") ; } } 
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOTw1_writeModel.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOTw1_writeModel.java b/jena-arq/src-examples/arq/examples/riot/ExRIOTw1_writeModel.java
new file mode 100644
index 0000000..405d350
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOTw1_writeModel.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.riot.* ;
+
+/** Example writing a model with RIOT */
+public class ExRIOTw1_writeModel
+{
+    public static void main(String[] args)
+    {
+        Model model = RDFDataMgr.loadModel("D.ttl") ;
+        
+        System.out.println() ;
+        System.out.println("#### ---- Write as Turtle") ;
+        System.out.println() ;
+        RDFDataMgr.write(System.out, model, Lang.TURTLE) ;
+        
+        System.out.println() ;
+        System.out.println("#### ---- Write as Turtle (streaming)") ;
+        System.out.println() ;
+        RDFDataMgr.write(System.out, model, RDFFormat.TURTLE_BLOCKS) ;
+        
+        System.out.println() ;
+        System.out.println("#### ---- Write as Turtle via model.write") ;
+        System.out.println() ;
+        model.write(System.out, "TTL") ;
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOTw2_writeRDF.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOTw2_writeRDF.java b/jena-arq/src-examples/arq/examples/riot/ExRIOTw2_writeRDF.java
new file mode 100644
index 0000000..69288bd
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOTw2_writeRDF.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr ;
+
+/** Other writer examples */
+public class ExRIOTw2_writeRDF
+{
+    public static void main(String[] args)
+    {
+        Model model = RDFDataMgr.loadModel("D.ttl") ;
+        System.out.println() ;
+        System.out.println("#### ---- Write as TriG") ;
+        System.out.println() ;
+        // This will be the default graph of the dataset written.
+        RDFDataMgr.write(System.out, model, Lang.TRIG) ;
+        
+        // Loading Turtle as Trig reads into the default graph.
+        Dataset dataset = RDFDataMgr.loadDataset("D.ttl") ;
+        System.out.println() ;
+        System.out.println("#### ---- Write as NQuads") ;
+        System.out.println() ;
+        RDFDataMgr.write(System.out, dataset, Lang.NQUADS) ;
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/1669b75f/jena-arq/src-examples/arq/examples/riot/ExRIOTw3_AddNewWriter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src-examples/arq/examples/riot/ExRIOTw3_AddNewWriter.java b/jena-arq/src-examples/arq/examples/riot/ExRIOTw3_AddNewWriter.java
new file mode 100644
index 0000000..5a0abc1
--- /dev/null
+++ b/jena-arq/src-examples/arq/examples/riot/ExRIOTw3_AddNewWriter.java
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.examples.riot;
+
+import java.io.OutputStream ;
+import java.io.Writer ;
+
+import org.apache.jena.atlas.io.IndentedWriter ;
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.riot.* ;
+import org.apache.jena.riot.adapters.RDFWriterRIOT ;
+import org.apache.jena.riot.system.PrefixMap ;
+import org.apache.jena.riot.system.RiotLib ;
+import org.apache.jena.riot.writer.WriterGraphRIOTBase ;
+import org.apache.jena.sparql.sse.SSE ;
+import org.apache.jena.sparql.util.Context ;
+
+/** Example of registering a new writer with RIOT */
+public class ExRIOTw3_AddNewWriter
+{
+    static { LogCtl.setCmdLogging(); }
+    
+    // See also ExRIOT6_AddNewLang
+    public static void main(String[] args)
+    {
+        System.out.println("## Example of a registering a new language with RIOT for writing") ; 
+        System.out.println() ;
+        
+        // Register the language
+        Lang lang = LangBuilder.create("SSE", "text/x-sse").addFileExtensions("rsse").build() ;
+        RDFLanguages.register(lang) ;
+
+        // Create format and register the association of language and default format.
+        // We are creating only one format here but in geenral theer can be variants
+        // (e.g. TURTLE - pretty printed or streamed) 
+        RDFFormat format = new RDFFormat(lang) ;
+        RDFWriterRegistry.register(lang, format)  ;
+        
+        // Register the writer factory
+        RDFWriterRegistry.register(format, new SSEWriterFactory()) ;
+
+        // ---- Use the register writer
+        Model model = RDFDataMgr.loadModel("/home/afs/tmp/D.ttl") ;
+        // Write
+        System.out.println("## Write by format") ;
+        RDFDataMgr.write(System.out, model, format) ;
+        System.out.println() ;
+        System.out.println("## Write by language") ;
+        RDFDataMgr.write(System.out, model, lang) ;
+        
+        // ---- Or use Model.write
+        System.out.println("## Write by Model.write") ;
+        model.write(System.out, "SSE") ;
+    }
+    
+    static class SSEWriterFactory implements WriterGraphRIOTFactory
+    {
+        @Override
+        public WriterGraphRIOT create(RDFFormat syntaxForm)
+        {
+            return new SSEWriter() ;
+        }
+    }
+    
+    static class SSEWriter extends WriterGraphRIOTBase
+    {
+        // Ignore externally provided prefix map and baseURI
+        @Override
+        public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
+        {
+            SSE.write(out, graph) ;
+        }
+
+        @Override
+        public Lang getLang()   { return  RDFLanguages.contentTypeToLang("text/x-sse") ; }
+
+        @Override
+        public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
+        {
+            // Writers are discouraged : just hope the charset is UTF-8.
+            IndentedWriter x = RiotLib.create(out) ;
+            SSE.write(x, graph) ;
+        }
+    }
+
+    // Model.write adapter - must be public.
+    public static class RDFWriterSSE extends RDFWriterRIOT { public RDFWriterSSE() { super("SSE") ; } } 
+}
+