You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by st...@apache.org on 2018/02/15 01:54:56 UTC

[01/17] commons-rdf git commit: Target subtype Consumer

Repository: commons-rdf
Updated Branches:
  refs/heads/fluent-parser [created] a944f7b9e


Target subtype Consumer


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/84a644d7
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/84a644d7
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/84a644d7

Branch: refs/heads/fluent-parser
Commit: 84a644d77cb03c3fd7758385e0fd55a0f8045257
Parents: fff1339
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Tue Feb 21 12:19:32 2017 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 18:57:54 2018 +0000

----------------------------------------------------------------------
 .../commons/rdf/experimental/ParserFactory.java |  9 ++++----
 .../rdf/simple/experimental/DatasetTarget.java  | 14 +++++++++----
 .../rdf/simple/experimental/GraphTarget.java    | 10 +++++++++
 .../experimental/ImplicitDatasetTarget.java     |  9 +++++++-
 .../rdf/simple/experimental/ParserBuilder.java  |  5 -----
 .../simple/experimental/ParserFactoryImpl.java  |  8 -------
 .../simple/experimental/QuadConsumerTarget.java | 22 --------------------
 7 files changed, 33 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java b/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
index b80ac91..2b4fcf3 100644
--- a/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
+++ b/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
@@ -101,8 +101,11 @@ public interface ParserFactory extends _NeedTargetOrRDF {
         T source();
     }
 
-    interface Target<T> {
-        T target();
+    @FunctionalInterface
+    interface Target<T> extends Consumer<Quad> {
+        default T target() {
+            return null; // unknown
+        }
     }
 
     NeedTargetOrRDF syntax(RDFSyntax syntax);
@@ -119,8 +122,6 @@ interface _NeedIdentifiedSource<T> {
 }
 
 interface _NeedTarget {
-    NeedSourceOrBase<Consumer<Quad>> target(Consumer<? super Quad> consumer);
-
     NeedSourceOrBase<Dataset> target(Dataset dataset);
 
     NeedSourceOrBase<Graph> target(Graph graph);

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
index bf60726..714e188 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
@@ -1,19 +1,25 @@
 package org.apache.commons.rdf.simple.experimental;
 
 import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.experimental.ParserFactory.Target;
 
 public class DatasetTarget implements Target<Dataset> {
 
-    private final Dataset target;
+    private final Dataset dataset;
 
-    public DatasetTarget(Dataset target) {
-        this.target = target;
+    public DatasetTarget(Dataset dataset) {
+        this.dataset = dataset;
+    }
+    
+    @Override
+    public void accept(Quad q) {
+        dataset.add(q);
     }
     
     @Override
     public Dataset target() {
-        return target;
+        return dataset;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
index 8f03351..6270048 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
@@ -1,6 +1,9 @@
 package org.apache.commons.rdf.simple.experimental;
 
+import java.util.function.Consumer;
+
 import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.experimental.ParserFactory.Target;
 
 public class GraphTarget implements Target<Graph> {
@@ -12,6 +15,13 @@ public class GraphTarget implements Target<Graph> {
     }
 
     @Override
+    public void accept(Quad q) {
+        if (! q.getGraphName().isPresent()) {
+            graph.add(q.asTriple());
+        }
+    }
+    
+    @Override
     public Graph target() {
         return graph;
     }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
index f2d0b74..0b0de2d 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
@@ -1,6 +1,9 @@
 package org.apache.commons.rdf.simple.experimental;
 
+import java.util.function.Consumer;
+
 import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.api.RDF;
 import org.apache.commons.rdf.experimental.ParserFactory.Target;
 
@@ -12,7 +15,7 @@ public class ImplicitDatasetTarget implements Target<Dataset> {
 
     public ImplicitDatasetTarget(RDF rdf) {
         this.rdf = rdf;
-    }    
+    }
     
     @Override
     public Dataset target() {
@@ -27,4 +30,8 @@ public class ImplicitDatasetTarget implements Target<Dataset> {
         return target;
     }
 
+    @Override
+    public void accept(Quad t) {
+        target().add(t);        
+    }
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
index 512243c..6842c54 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
@@ -121,11 +121,6 @@ public final class ParserBuilder implements NeedTargetOrRDF, NeedSourceBased, Sy
     }
 
     @Override
-    public NeedSourceOrBase<Consumer<Quad>> target(Consumer<? super Quad> consumer) {
-        return target(new QuadConsumerTarget(consumer));
-    }
-
-    @Override
     public NeedSourceOrBase<Dataset> target(Dataset dataset) {
         return target(new DatasetTarget(dataset));
     }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
index c136459..70b7237 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
@@ -1,10 +1,7 @@
 package org.apache.commons.rdf.simple.experimental;
 
-import java.util.function.Consumer;
-
 import org.apache.commons.rdf.api.Dataset;
 import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.api.RDF;
 import org.apache.commons.rdf.api.RDFSyntax;
 import org.apache.commons.rdf.experimental.ParserFactory;
@@ -27,11 +24,6 @@ public class ParserFactoryImpl implements ParserFactory {
         return target(new DatasetTarget(dataset));
     }
 
-    @Override
-    public NeedSourceOrBase<Consumer<Quad>> target(Consumer<? super Quad> consumer) {
-        return target(new QuadConsumerTarget(consumer));
-    }
-
     @SuppressWarnings("unchecked")
     @Override
     public <T> NeedSourceOrBase<T> target(Target<T> target) {

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/84a644d7/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java
deleted file mode 100644
index 3e6365a..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.Quad;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public class QuadConsumerTarget implements Target<Consumer<Quad>> {
-
-    private final Consumer<? super Quad> consumer;
-
-    public QuadConsumerTarget(Consumer<? super Quad> consumer) {
-        this.consumer = consumer;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Consumer<Quad> target() {
-        return (Consumer<Quad>) consumer;
-    }
-
-}


[02/17] commons-rdf git commit: Parser defactoring

Posted by st...@apache.org.
Parser defactoring


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/fff13398
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/fff13398
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/fff13398

Branch: refs/heads/fluent-parser
Commit: fff1339896acaf78a5820e64119471fcb7df417e
Parents: 7d05cc0
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Tue Feb 21 01:06:02 2017 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 18:57:54 2018 +0000

----------------------------------------------------------------------
 .../rdf/simple/experimental/DatasetTarget.java  |  19 +
 .../rdf/simple/experimental/GraphTarget.java    |  19 +
 .../rdf/simple/experimental/IRISource.java      |  20 ++
 .../experimental/ImplicitDatasetTarget.java     |  30 ++
 .../simple/experimental/InputStreamSource.java  |  20 ++
 .../rdf/simple/experimental/ParsedImpl.java     |  34 ++
 .../rdf/simple/experimental/ParserBuilder.java  | 155 ++++++++
 .../simple/experimental/ParserFactoryImpl.java  |  52 +++
 .../experimental/ParserImplementation.java      |  14 +
 .../rdf/simple/experimental/PathSource.java     |  20 ++
 .../simple/experimental/QuadConsumerTarget.java |  22 ++
 .../commons/rdf/simple/experimental/State.java  | 356 +++++++++++++++++++
 .../simple/experimental/ParserFactoryTest.java  |  24 ++
 13 files changed, 785 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
new file mode 100644
index 0000000..bf60726
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
@@ -0,0 +1,19 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public class DatasetTarget implements Target<Dataset> {
+
+    private final Dataset target;
+
+    public DatasetTarget(Dataset target) {
+        this.target = target;
+    }
+    
+    @Override
+    public Dataset target() {
+        return target;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
new file mode 100644
index 0000000..8f03351
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
@@ -0,0 +1,19 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public class GraphTarget implements Target<Graph> {
+
+    private Graph graph;
+
+    public GraphTarget(Graph graph) {
+        this.graph = graph;
+    }
+
+    @Override
+    public Graph target() {
+        return graph;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java
new file mode 100644
index 0000000..8324929
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java
@@ -0,0 +1,20 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+
+public final class IRISource implements Source<IRI> {
+
+    private final IRI source;
+
+    public IRISource(IRI iri) {
+        this.source = iri;
+    }
+
+    @Override
+    public IRI source() {
+        return source;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
new file mode 100644
index 0000000..f2d0b74
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
@@ -0,0 +1,30 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public class ImplicitDatasetTarget implements Target<Dataset> {
+
+    private final RDF rdf;
+    
+    private Dataset target;
+
+    public ImplicitDatasetTarget(RDF rdf) {
+        this.rdf = rdf;
+    }    
+    
+    @Override
+    public Dataset target() {
+        if (target == null) {
+            synchronized (this) {
+                // Make sure we only make it once
+                if (target == null) {
+                    target = rdf.createDataset();
+                }
+            }
+        }
+        return target;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java
new file mode 100644
index 0000000..f68ac78
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java
@@ -0,0 +1,20 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.io.InputStream;
+
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+
+public class InputStreamSource implements Source<InputStream> {
+
+    private final InputStream source;
+
+    public InputStreamSource(InputStream source) {
+        this.source = source;
+    }
+
+    @Override
+    public InputStream source() {
+        return source;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java
new file mode 100644
index 0000000..afbac1f
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java
@@ -0,0 +1,34 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import org.apache.commons.rdf.experimental.ParserFactory.Parsed;
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public class ParsedImpl<T,S> implements Parsed<T, S> {
+
+    private final Source<S> source;
+    private final Target<T> target;
+    private final long count;
+
+    public ParsedImpl(Source<S> source, Target<T> target, final long count) {
+        this.source = source;
+        this.target = target;
+        this.count = count;
+    }
+
+    @Override
+    public long count() {
+        return count;
+    }
+    
+    @Override
+    public Source<S> source() {
+        return source;
+    }
+
+    @Override
+    public Target<T> target() {
+        return target;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
new file mode 100644
index 0000000..512243c
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
@@ -0,0 +1,155 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.Future;
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.experimental.ParserFactory.*;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public final class ParserBuilder implements NeedTargetOrRDF, NeedSourceBased, Sync, NeedSourceOrBase, OptionalTarget,
+        NeedSourceOrBaseOrSyntax, Async {
+
+    public static enum AsyncOption implements Option<ExecutorService> {
+        EXECUTOR_SERVICE
+    }
+
+    public static enum BaseOption implements Option<IRI> {
+        BASE        
+    }
+    
+    private final State state;
+
+    public ParserBuilder() {
+        this.state = new DefaultState();
+    }
+
+    public ParserBuilder(ParserImplementation impl) {
+        this.state = new WithImplementation(impl);
+    }
+
+    public ParserBuilder(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public Async async() {
+        return async(ForkJoinPool.commonPool());
+    }
+
+    @Override
+    public Async async(ExecutorService executor) {
+        return newState(state.withOption(AsyncOption.EXECUTOR_SERVICE, executor));
+    }
+
+    @Override
+    public NeedSourceBased<Dataset> base(IRI iri) {
+        return newState(implicitTarget().withOption(BaseOption.BASE, iri));
+    }
+
+    @Override
+    public NeedSourceBased<Dataset> base(String iri) {
+        return base(state.rdf().createIRI(iri));
+    }
+
+    public ParserBuilder build() {
+        return newState(state.freeze());
+    }
+
+    @Override
+    public ParserBuilder option(Option o, Object v) {
+        return newState(state.withOption(o, v));
+    }
+
+    @Override
+    public Parsed parse() {
+        ParserImplementation impl = state.impl();
+        long count = impl.parse(state.source(), state.syntax(), state.target(), state.rdf(), state.optionsAsMap());
+        return new ParsedImpl<>(state.source(), state.target(), count);
+    }
+
+    @Override
+    public Future parseAsync() {
+        Map<Option, Object> options = state.optionsAsMap();
+        ExecutorService executor = (ExecutorService) options.getOrDefault(AsyncOption.EXECUTOR_SERVICE,
+                ForkJoinPool.commonPool());
+        return executor.submit(this::parse);
+    }
+
+    @Override
+    public OptionalTarget rdf(RDF rdf) {
+        return newState(state.withRDF(rdf));
+    }
+
+    @Override
+    public Sync source(InputStream is) {
+        return source(new InputStreamSource(is));
+    }
+
+    @Override
+    public Sync source(IRI iri) {
+        return source(new IRISource(iri));
+    }
+
+    @Override
+    public Sync source(Path path) {
+        return source(new PathSource(path));
+    }
+
+    @Override
+    public Sync source(Source source) {
+        return newState(implicitTarget().withSource(source));
+    }
+
+    @Override
+    public Sync source(String iri) {
+        return source(state.rdf().createIRI(iri));
+    }
+
+    public NeedSourceOrBase syntax(RDFSyntax syntax) {
+        return newState(state.withSyntax(syntax));
+    }
+
+    @Override
+    public NeedSourceOrBase<Consumer<Quad>> target(Consumer<? super Quad> consumer) {
+        return target(new QuadConsumerTarget(consumer));
+    }
+
+    @Override
+    public NeedSourceOrBase<Dataset> target(Dataset dataset) {
+        return target(new DatasetTarget(dataset));
+    }
+
+    @Override
+    public NeedSourceOrBase<Graph> target(Graph graph) {
+        return target(new GraphTarget(graph));
+    }
+
+    @Override
+    public NeedSourceOrBase target(Target target) {
+        return newState(state.withTarget(target));
+    }
+
+    private State implicitTarget() {
+        return state.withTarget(new ImplicitDatasetTarget(state.rdf()));
+    }
+
+    private ParserBuilder newState(State newState) {
+        if (this.state == newState) {
+            // probably a MutableState
+            return this;
+        }
+        return new ParserBuilder(newState);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
new file mode 100644
index 0000000..c136459
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
@@ -0,0 +1,52 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.experimental.ParserFactory;
+
+public class ParserFactoryImpl implements ParserFactory {
+
+    private State state;
+
+    public ParserFactoryImpl(ParserImplementation impl) {
+        this.state = new WithImplementation(impl);
+    }
+    
+    @Override
+    public NeedSourceOrBase<Graph> target(Graph graph) {
+        return target(new GraphTarget(graph));
+    }
+
+    @Override
+    public NeedSourceOrBase<Dataset> target(Dataset dataset) {
+        return target(new DatasetTarget(dataset));
+    }
+
+    @Override
+    public NeedSourceOrBase<Consumer<Quad>> target(Consumer<? super Quad> consumer) {
+        return target(new QuadConsumerTarget(consumer));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> NeedSourceOrBase<T> target(Target<T> target) {
+        return new ParserBuilder(state.withTarget(target));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public OptionalTarget<Dataset> rdf(RDF rdf) {
+        return new ParserBuilder(state.withRDF(rdf));
+    }
+
+    @Override
+    public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+        return new ParserBuilder(state.withSyntax(syntax));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java
new file mode 100644
index 0000000..4284429
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java
@@ -0,0 +1,14 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.util.Map;
+
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.experimental.ParserFactory.Option;
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public interface ParserImplementation {
+    @SuppressWarnings("rawtypes")
+    public long parse(Source source, RDFSyntax rdfSyntax, Target target, RDF rdf, Map<Option, Object> map);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java
new file mode 100644
index 0000000..0341f47
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java
@@ -0,0 +1,20 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.nio.file.Path;
+
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+
+public class PathSource implements Source<Path> {
+    private final Path source;
+
+    public PathSource(Path source) {
+        this.source = source;
+    }
+    
+    @Override
+    public Path source() {
+        return source;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java
new file mode 100644
index 0000000..3e6365a
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/QuadConsumerTarget.java
@@ -0,0 +1,22 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public class QuadConsumerTarget implements Target<Consumer<Quad>> {
+
+    private final Consumer<? super Quad> consumer;
+
+    public QuadConsumerTarget(Consumer<? super Quad> consumer) {
+        this.consumer = consumer;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Consumer<Quad> target() {
+        return (Consumer<Quad>) consumer;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java
new file mode 100644
index 0000000..f94f827
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java
@@ -0,0 +1,356 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.experimental.ParserFactory.Option;
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+import org.apache.commons.rdf.simple.SimpleRDF;
+
+@SuppressWarnings("rawtypes")
+interface State {
+    ParserImplementation impl();
+    RDF rdf();
+    Source source();
+    Target target();
+    RDFSyntax syntax();
+    Stream<Map.Entry<Option, Object>> options();
+    Map<Option, Object> optionsAsMap();
+    State withRDF(RDF rdf);
+    State withSource(Source p);
+    State withTarget(Target g);
+    State withSyntax(RDFSyntax s);
+    <O> State withOption(Option<O> o, O v);
+    State withImplementation(ParserImplementation impl);
+    State freeze();
+}
+
+@SuppressWarnings("rawtypes")
+final class MutableState implements State, Cloneable {
+    private ParserImplementation impl;
+    private RDF rdf = new SimpleRDF();
+    private Source source;
+    private Target target;
+    private RDFSyntax syntax;
+    private Map<Option, Object> options = new LinkedHashMap<>();
+
+    @Override
+    public ParserImplementation impl() {
+        return Objects.requireNonNull(impl);
+    }
+    public State freeze() {
+        // options will be cloned inside constructor
+        return new FrozenState(impl, source, syntax, target, rdf, options);
+    }
+    @Override
+    public RDF rdf() {
+        return Objects.requireNonNull(rdf);
+    }
+    @Override
+    public Source source() {
+        return Objects.requireNonNull(source);
+    }
+    @Override
+    public Target target() {
+        return Objects.requireNonNull(target);
+    }
+    @Override
+    public RDFSyntax syntax() {
+        return Objects.requireNonNull(syntax);
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return options.entrySet().stream();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return Collections.unmodifiableMap(options);
+    }
+    @Override
+    public State withRDF(RDF rdf) {
+        this.rdf = rdf;
+        return this;
+    }
+    @Override
+    public State withSource(Source s) {
+        this.source = s;
+        return this;
+    }
+    @Override
+    public State withTarget(Target t) {
+        this.target = t;
+        return this;
+    }
+    @Override
+    public State withSyntax(RDFSyntax s) {
+        this.syntax = s;
+        return this;
+    }
+    @Override
+    public <O> State withOption(Option<O> o, O v) {
+        options.put(o, v);
+        return this;
+    }
+    @Override
+    public State withImplementation(ParserImplementation impl) {
+        this.impl = impl;
+        return this;
+    }
+}
+
+
+@SuppressWarnings("rawtypes")
+abstract class ImmutableState implements State {
+    @Override
+    public State withSource(Source src) {
+        return new WithSource(src, this);
+    }
+    @Override
+    public State withSyntax(RDFSyntax s) {
+        return new WithSyntax(s, this);
+    }
+    @Override
+    public State withTarget(Target t) {
+        return new WithTarget(t, this);
+    }
+    public State withRDF(RDF rdf) {
+        return new WithRDF(rdf, this);
+    };
+    public <O> State withOption(Option<O> o, O v) {
+        return new WithOption(o, v, this);
+    };
+    @Override
+    public State withImplementation(ParserImplementation impl) {
+        return new WithImplementation(impl, this);
+    }
+    @Override
+    public State freeze() {
+        return this;
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class DefaultState extends ImmutableState {
+    @Override
+    public Source source() {
+        throw new IllegalStateException("Source not set");
+    }
+    @Override
+    public Target target() {
+        throw new IllegalStateException("Target not set");
+    }
+    @Override
+    public RDFSyntax syntax() {
+        throw new IllegalStateException("Syntax not set");
+    }
+    @Override
+    public RDF rdf() {
+        return new SimpleRDF(); // fresh every time?
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return Stream.empty();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return Collections.emptyMap();
+    }
+    @Override
+    public ParserImplementation impl() {
+        throw new IllegalStateException("Implementation not set");
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class FrozenState extends ImmutableState implements State {
+    private final ParserImplementation impl;
+    private final Source source;
+    private final RDFSyntax syntax;
+    private final Target target;
+    private final RDF rdf;
+    private final Map<Option, Object> options;
+
+    public FrozenState(ParserImplementation impl, Source source, RDFSyntax syntax, Target target, RDF rdf,
+            Map<Option, Object> options) {
+        this.impl = impl;
+        this.source = source;
+        this.syntax = syntax;
+        this.target = target;
+        this.rdf = rdf;
+        // shallow copy of options
+        this.options = Collections.unmodifiableMap(new LinkedHashMap<>(options));
+    }
+    @Override
+    public ParserImplementation impl() {
+        return impl;
+    }
+    @Override
+    public RDF rdf() {
+        return rdf;
+    }
+    @Override
+    public Source source() {
+        return source;
+    }
+    @Override
+    public Target target() {
+        return target;
+    }
+    @Override
+    public RDFSyntax syntax() {
+        return syntax;
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return options.entrySet().stream();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return options;
+    }
+}
+
+@SuppressWarnings("rawtypes")
+abstract class Inherited extends ImmutableState {
+    private final ImmutableState parent;
+    public Inherited() {
+        this(new DefaultState());
+    }
+    public Inherited(ImmutableState state) {
+        parent = state;
+    }
+    @Override
+    public Source source() {
+        return parent.source();
+    }
+    @Override
+    public Target target() {
+        return parent.target();
+    }
+    @Override
+    public RDFSyntax syntax() {
+        return parent.syntax();
+    }
+    @Override
+    public RDF rdf() {
+        return parent.rdf();
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return parent.options();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return parent.optionsAsMap();
+    }
+    @Override
+    public ParserImplementation impl() {
+        return parent.impl();
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class WithSource extends Inherited {
+    private final Source source;
+
+    public WithSource(final Source src) {
+        this.source = src;
+    }
+    public WithSource(final Source src, final ImmutableState state) {
+        super(state);
+        this.source = src;
+    }
+    @Override
+    public Source source() {
+        return source;
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class WithTarget extends Inherited {
+    private final Target target;
+
+    public WithTarget(final Target t) {
+        this.target = t;
+    }
+    public WithTarget(final Target t, final ImmutableState state) {
+        super(state);
+        this.target = t;
+    }
+    @Override
+    public Target target() {
+        return target;
+    }
+}
+
+final class WithSyntax extends Inherited {
+    private final RDFSyntax syntax;
+    public WithSyntax(final RDFSyntax s) {
+        syntax = s;
+    }
+    public WithSyntax(final RDFSyntax s, final ImmutableState state) {
+        super(state);
+        syntax = s;
+    }
+    @Override
+    public RDFSyntax syntax() {
+        return syntax;
+    }
+}
+
+final class WithRDF extends Inherited {
+    private final RDF rdf;
+    public WithRDF(final RDF r) {
+        rdf = r;
+    }
+    public WithRDF(final RDF r, final ImmutableState state) {
+        super(state);
+        rdf = r;
+    }
+    @Override
+    public RDF rdf() {
+        return rdf;
+    }
+}
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+final class WithOption extends Inherited {
+    private Option<? extends Object> option;
+    private Object value;
+    public <O> WithOption(Option<O> o, O v, ImmutableState immutableState) {
+        this.option = o;
+        this.value = v;
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return Stream.concat(super.options(), Stream.of(new SimpleImmutableEntry(option, value)));
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return options().collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+    }
+}
+
+final class WithImplementation extends Inherited {
+    private final ParserImplementation impl;
+    public WithImplementation(ParserImplementation impl) {
+        this.impl = impl;
+    }
+    public WithImplementation(ParserImplementation impl, ImmutableState parent) {
+        super(parent);
+        this.impl = impl;
+    }
+    @Override
+    public ParserImplementation impl() {
+        return impl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fff13398/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java
new file mode 100644
index 0000000..a5b63c2
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java
@@ -0,0 +1,24 @@
+package org.apache.commons.rdf.simple.experimental;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.experimental.ParserFactory;
+import org.apache.commons.rdf.experimental.ParserFactory.*;
+import org.apache.commons.rdf.simple.SimpleRDF;
+import org.junit.Test;
+
+public class ParserFactoryTest {
+    @Test
+    public void testName() throws Exception {
+        ParserFactory f = new ParserFactoryImpl((a,b,c,d,e) -> 1);
+        InputStream is = getClass().getResourceAsStream("Fred");
+        Async g = f.syntax(RDFSyntax.JSONLD).rdf(new SimpleRDF()).base("http://example.com/").source(is).async();
+        Future<Parsed<?,?>> x = g.parseAsync();
+        Parsed<?, ?> p = x.get();
+        System.out.println(p.count());
+    }
+}


[05/17] commons-rdf git commit: Split out fluent interfaces

Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
new file mode 100644
index 0000000..eab29c9
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
@@ -0,0 +1,364 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.ParserSource;
+import org.apache.commons.rdf.api.io.ParserTarget;
+import org.apache.commons.rdf.simple.SimpleRDF;
+
+@SuppressWarnings("rawtypes")
+public interface ParseJob {
+    ParserImplementation impl();
+    RDF rdf();
+    ParserSource source();
+    ParserTarget target();
+    Optional<RDFSyntax> syntax();
+    Stream<Map.Entry<Option, Object>> options();
+    Map<Option, Object> optionsAsMap();
+    ParseJob withRDF(RDF rdf);
+    ParseJob withSource(ParserSource p);
+    ParseJob withTarget(ParserTarget g);
+    ParseJob withSyntax(RDFSyntax s);
+    <O> ParseJob withOption(Option<O> o, O v);
+    ParseJob withImplementation(ParserImplementation impl);
+    ImmutableParseJob freeze();    
+}
+
+interface ImmutableParseJob extends ParseJob {
+}
+
+@SuppressWarnings("rawtypes")
+final class MutableParseJob implements ParseJob, Cloneable {
+    private ParserImplementation impl;
+    private RDF rdf = new SimpleRDF();
+    private ParserSource source;
+    private ParserTarget target;
+    private RDFSyntax syntax;
+    private Map<Option, Object> options = new LinkedHashMap<>();
+
+    @Override
+    public ParserImplementation impl() {
+        return Objects.requireNonNull(impl);
+    }
+    public ImmutableParseJob freeze() {
+        return new FrozenParseJob(this);
+    }
+    @Override
+    public RDF rdf() {
+        return Objects.requireNonNull(rdf);
+    }
+    @Override
+    public ParserSource source() {
+        return Objects.requireNonNull(source);
+    }
+    @Override
+    public ParserTarget target() {
+        return Objects.requireNonNull(target);
+    }
+    @Override
+    public Optional<RDFSyntax> syntax() {
+        return Optional.ofNullable(syntax);
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return options.entrySet().stream();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return Collections.unmodifiableMap(options);
+    }
+    @Override
+    public ParseJob withRDF(RDF rdf) {
+        this.rdf = rdf;
+        return this;
+    }
+    @Override
+    public ParseJob withSource(ParserSource s) {
+        this.source = s;
+        return this;
+    }
+    @Override
+    public ParseJob withTarget(ParserTarget t) {
+        this.target = t;
+        return this;
+    }
+    @Override
+    public ParseJob withSyntax(RDFSyntax s) {
+        this.syntax = s;
+        return this;
+    }
+    @Override
+    public <O> ParseJob withOption(Option<O> o, O v) {
+        options.put(o, v);
+        return this;
+    }
+    @Override
+    public ParseJob withImplementation(ParserImplementation impl) {
+        this.impl = impl;
+        return this;
+    }
+}
+
+
+@SuppressWarnings("rawtypes")
+abstract class ImmutableParseJobImpl implements ImmutableParseJob {
+    @Override
+    public ParseJob withSource(ParserSource src) {
+        return new WithSource(src, this);
+    }
+    @Override
+    public ParseJob withSyntax(RDFSyntax s) {
+        return new WithSyntax(s, this);
+    }
+    @Override
+    public ParseJob withTarget(ParserTarget t) {
+        return new WithTarget(t, this);
+    }
+    public ParseJob withRDF(RDF rdf) {
+        return new WithRDF(rdf, this);
+    };
+    public <O> ParseJob withOption(Option<O> o, O v) {
+        return new WithOption(o, v, this);
+    };
+    @Override
+    public ParseJob withImplementation(ParserImplementation impl) {
+        return new WithImplementation(impl, this);
+    }
+    @Override
+    public ImmutableParseJob freeze() {
+        return this;
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class DefaultParseJob extends ImmutableParseJobImpl implements ImmutableParseJob {
+    @Override
+    public ParserSource source() {
+        throw new IllegalStateException("Source not set");
+    }
+    @Override
+    public ParserTarget target() {
+        throw new IllegalStateException("Target not set");
+    }
+    @Override
+    public Optional<RDFSyntax> syntax() {
+        return Optional.empty();
+    }
+    @Override
+    public RDF rdf() {
+        return new SimpleRDF(); // fresh every time?
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return Stream.empty();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return Collections.emptyMap();
+    }
+    @Override
+    public ParserImplementation impl() {
+        throw new IllegalStateException("Implementation not set");
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class FrozenParseJob extends ImmutableParseJobImpl implements ImmutableParseJob {
+    private final ParserImplementation impl;
+    private final ParserSource source;
+    private final Optional<RDFSyntax> syntax;
+    private final ParserTarget target;
+    private final RDF rdf;
+    private final Map<Option, Object> options;
+
+    public FrozenParseJob(ParseJob parseJob) {
+        this(parseJob.impl(), parseJob.source(), parseJob.syntax().orElse(null), 
+               parseJob.target(), parseJob.rdf(), parseJob.optionsAsMap());
+    }
+    public FrozenParseJob(ParserImplementation impl, ParserSource source, RDFSyntax syntax, ParserTarget target, RDF rdf,
+            Map<Option, Object> options) {
+        this.impl = Objects.requireNonNull(impl);
+        this.source =  Objects.requireNonNull(source);
+        this.syntax = Optional.ofNullable(syntax);
+        this.target = Objects.requireNonNull(target);
+        this.rdf = Objects.requireNonNull(rdf);
+        // shallow copy of options
+        this.options = Collections.unmodifiableMap(new LinkedHashMap<>(options));
+    }
+    @Override
+    public ParserImplementation impl() {
+        return impl;
+    }
+    @Override
+    public RDF rdf() {
+        return rdf;
+    }
+    @Override
+    public ParserSource source() {
+        return source;
+    }
+    @Override
+    public ParserTarget target() {
+        return target;
+    }
+    @Override
+    public Optional<RDFSyntax> syntax() {
+        return syntax;
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return options.entrySet().stream();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return options;
+    }
+}
+
+@SuppressWarnings("rawtypes")
+abstract class Inherited extends ImmutableParseJobImpl implements ImmutableParseJob  {
+    private final ImmutableParseJob parent;
+    public Inherited() {
+        this(new DefaultParseJob());
+    }
+    public Inherited(ImmutableParseJob job) {
+        parent = job;
+    }
+    @Override
+    public ParserSource source() {
+        return parent.source();
+    }
+    @Override
+    public ParserTarget target() {
+        return parent.target();
+    }
+    @Override
+    public Optional<RDFSyntax> syntax() {
+        return parent.syntax();
+    }
+    @Override
+    public RDF rdf() {
+        return parent.rdf();
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return parent.options();
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return parent.optionsAsMap();
+    }
+    @Override
+    public ParserImplementation impl() {
+        return parent.impl();
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class WithSource extends Inherited {
+    private final ParserSource source;
+
+    public WithSource(final ParserSource src) {
+        this.source = src;
+    }
+    public WithSource(final ParserSource src, final ImmutableParseJob parent) {
+        super(parent);        
+        this.source = src;
+    }
+    @Override
+    public ParserSource source() {
+        return source;
+    }
+}
+
+@SuppressWarnings("rawtypes")
+final class WithTarget extends Inherited {
+    private final ParserTarget target;
+
+    public WithTarget(final ParserTarget t) {
+        this.target = t;
+    }
+    public WithTarget(final ParserTarget t, final ImmutableParseJob parent) {
+        super(parent);
+        this.target = t;
+    }
+    @Override
+    public ParserTarget target() {
+        return target;
+    }
+}
+
+final class WithSyntax extends Inherited {
+    private final RDFSyntax syntax;
+    public WithSyntax(final RDFSyntax s) {
+        syntax = s;
+    }
+    public WithSyntax(final RDFSyntax s, final ImmutableParseJob parent) {
+        super(parent);
+        syntax = s;
+    }
+    @Override
+    public Optional<RDFSyntax> syntax() {
+        return Optional.ofNullable(syntax);
+    }
+}
+
+final class WithRDF extends Inherited {
+    private final RDF rdf;
+    public WithRDF(final RDF r) {
+        rdf = r;
+    }
+    public WithRDF(final RDF r, final ImmutableParseJob parent) {
+        super(parent);
+        rdf = r;
+    }
+    @Override
+    public RDF rdf() {
+        return rdf;
+    }
+}
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+final class WithOption extends Inherited {
+    private Option<? extends Object> option;
+    private Object value;
+    public <O> WithOption(Option<O> o, O v, ImmutableParseJob parent) {
+        super(parent);
+        this.option = o;
+        this.value = v;
+    }
+    @Override
+    public Stream<Entry<Option, Object>> options() {
+        return Stream.concat(super.options(), Stream.of(new SimpleImmutableEntry(option, value)));
+    }
+    @Override
+    public Map<Option, Object> optionsAsMap() {
+        return options().collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+    }
+}
+
+final class WithImplementation extends Inherited {
+    private final ParserImplementation impl;
+    public WithImplementation(ParserImplementation impl) {
+        this.impl = impl;
+    }
+    public WithImplementation(ParserImplementation impl, ImmutableParseJob parent) {
+        super(parent);
+        this.impl = impl;
+    }
+    @Override
+    public ParserImplementation impl() {
+        return impl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
new file mode 100644
index 0000000..3beed15
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
@@ -0,0 +1,34 @@
+package org.apache.commons.rdf.simple.io;
+
+import org.apache.commons.rdf.api.io.Parsed;
+import org.apache.commons.rdf.api.io.ParserSource;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+public class ParsedImpl<T,S> implements Parsed<T, S> {
+
+    private final ParserSource<S> source;
+    private final ParserTarget<T> target;
+    private final long count;
+
+    public ParsedImpl(ParserSource<S> source, ParserTarget<T> target, final long count) {
+        this.source = source;
+        this.target = target;
+        this.count = count;
+    }
+
+    @Override
+    public long count() {
+        return count;
+    }
+    
+    @Override
+    public ParserSource<S> source() {
+        return source;
+    }
+
+    @Override
+    public ParserTarget<T> target() {
+        return target;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
new file mode 100644
index 0000000..bb3eec7
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
@@ -0,0 +1,159 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.io.Async;
+import org.apache.commons.rdf.api.io.NeedSourceBased;
+import org.apache.commons.rdf.api.io.NeedSourceOrBase;
+import org.apache.commons.rdf.api.io.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.OptionalTarget;
+import org.apache.commons.rdf.api.io.Parsed;
+import org.apache.commons.rdf.api.io.ParserSource;
+import org.apache.commons.rdf.api.io.ParserTarget;
+import org.apache.commons.rdf.api.io.Sync;
+import org.apache.commons.rdf.api.io.Option.RequiredOption;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public final class ParserBuilder implements NeedTargetOrRDF, NeedSourceBased, Sync, NeedSourceOrBase, OptionalTarget,
+        Async {
+
+    public static enum AsyncOption implements RequiredOption<ExecutorService> {
+        EXECUTOR_SERVICE
+    }
+
+    public static enum BaseOption implements RequiredOption<IRI> {
+        BASE        
+    }
+    
+    private final ParseJob parseJob;
+
+    public ParserBuilder() {
+        this.parseJob = new DefaultParseJob();
+    }
+
+    public ParserBuilder(ParserImplementation impl) {
+        this.parseJob = new WithImplementation(impl);
+    }
+
+    public ParserBuilder(ParseJob parseJob) {
+        this.parseJob = parseJob;
+    }
+
+    @Override
+    public Async async() {
+        return async(ForkJoinPool.commonPool());
+    }
+
+    @Override
+    public Async async(ExecutorService executor) {
+        return newState(parseJob.withOption(AsyncOption.EXECUTOR_SERVICE, executor));
+    }
+
+    @Override
+    public NeedSourceBased<Dataset> base(IRI iri) {
+        return newState(implicitTarget().withOption(BaseOption.BASE, iri));
+    }
+
+    @Override
+    public NeedSourceBased<Dataset> base(String iri) {
+        return base(parseJob.rdf().createIRI(iri));
+    }
+
+    @Override
+    public ParserBuilder build() {
+        return newState(parseJob.freeze());
+    }
+
+    @Override
+    public ParserBuilder option(Option o, Object v) {
+        return newState(parseJob.withOption(o, v));
+    }
+
+    @Override
+    public Parsed parse() {
+        ParserImplementation impl = parseJob.impl();
+        long count = impl.parse(parseJob.source(), parseJob.syntax().orElse(null), parseJob.target(), parseJob.rdf(), parseJob.optionsAsMap());
+        return new ParsedImpl<>(parseJob.source(), parseJob.target(), count);
+    }
+
+    @Override
+    public Future parseAsync() {
+        Map<Option, Object> options = parseJob.optionsAsMap();
+        ExecutorService executor = (ExecutorService) options.getOrDefault(AsyncOption.EXECUTOR_SERVICE,
+                ForkJoinPool.commonPool());
+        return executor.submit(this::parse);
+    }
+
+    @Override
+    public OptionalTarget rdf(RDF rdf) {
+        return newState(parseJob.withRDF(rdf));
+    }
+
+    @Override
+    public Sync source(InputStream is) {
+        return source(new InputStreamSource(is));
+    }
+
+    @Override
+    public Sync source(IRI iri) {
+        return source(new IRISource(iri));
+    }
+
+    @Override
+    public Sync source(Path path) {
+        return source(new PathSource(path));
+    }
+
+    @Override
+    public Sync source(ParserSource source) {
+        return newState(implicitTarget().withSource(source));
+    }
+
+    @Override
+    public Sync source(String iri) {
+        return source(parseJob.rdf().createIRI(iri));
+    }
+
+    public NeedSourceOrBase syntax(RDFSyntax syntax) {
+        return newState(parseJob.withSyntax(syntax));
+    }
+
+    @Override
+    public NeedSourceOrBase<Dataset> target(Dataset dataset) {
+        return target(new DatasetTarget(dataset));
+    }
+
+    @Override
+    public NeedSourceOrBase<Graph> target(Graph graph) {
+        return target(new GraphTarget(graph));
+    }
+
+    @Override
+    public NeedSourceOrBase target(ParserTarget target) {
+        return newState(parseJob.withTarget(target));
+    }
+
+    private ParseJob implicitTarget() {
+        return parseJob.withTarget(new ImplicitDatasetTarget(parseJob.rdf()));
+    }
+
+    private ParserBuilder newState(ParseJob newState) {
+        if (this.parseJob == newState) {
+            // probably a MutableParseJob
+            return this;
+        }
+        return new ParserBuilder(newState);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
new file mode 100644
index 0000000..e5df228
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
@@ -0,0 +1,52 @@
+package org.apache.commons.rdf.simple.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.io.NeedSourceOrBase;
+import org.apache.commons.rdf.api.io.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.io.OptionalTarget;
+import org.apache.commons.rdf.api.io.ParserFactory;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+public class ParserFactoryImpl implements ParserFactory {
+
+    private ParserImplementation impl;
+
+    public ParserFactoryImpl(ParserImplementation impl) {
+        this.impl = impl;
+    }
+    
+    @Override
+    public NeedSourceOrBase<Graph> target(Graph graph) {
+        return target(new GraphTarget(graph));
+    }
+
+    @Override
+    public NeedSourceOrBase<Dataset> target(Dataset dataset) {
+        return target(new DatasetTarget(dataset));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
+        return new ParserBuilder(mutableState().withTarget(target));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public OptionalTarget<Dataset> rdf(RDF rdf) {
+        return new ParserBuilder(mutableState().withRDF(rdf));
+    }
+
+    private ParseJob mutableState() {
+        return new MutableParseJob().withImplementation(impl);
+    }
+
+    @Override
+    public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+        return new ParserBuilder(mutableState().withSyntax(syntax));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserImplementation.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserImplementation.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserImplementation.java
new file mode 100644
index 0000000..6199314
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserImplementation.java
@@ -0,0 +1,14 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.util.Map;
+
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.ParserSource;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+public interface ParserImplementation {
+    @SuppressWarnings("rawtypes")
+    public long parse(ParserSource source, RDFSyntax rdfSyntax, ParserTarget target, RDF rdf, Map<Option, Object> options);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
new file mode 100644
index 0000000..25fdd0a
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
@@ -0,0 +1,46 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.io.ParserSource;
+import org.apache.commons.rdf.simple.SimpleRDF;
+
+public class PathSource implements ParserSource<Path> {
+    private final Path source;
+
+    private static final RDF rdf = new SimpleRDF();
+    
+    public PathSource(Path source) {
+        this.source = source;
+    }
+
+    @Override
+    public Path source() {
+        return source;
+    }
+
+    @Override
+    public InputStream inputStream() throws IOException {
+        return Files.newInputStream(source);
+    }
+
+    @Override
+    public Optional<IRI> iri() {
+        Path p;
+        try {
+            // Resolve any symlinks etc.
+            p = source.toRealPath();
+        } catch (IOException e) {
+            // Probably some folder is not found, use full path as-is
+            p = source.toAbsolutePath();
+        }
+        return Optional.of(rdf.createIRI(p.toUri().toString()));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/package-info.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/package-info.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/package-info.java
new file mode 100644
index 0000000..c80524e
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.simple.io;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java
deleted file mode 100644
index a5b63c2..0000000
--- a/simple/src/test/java/org/apache/commons/rdf/simple/experimental/ParserFactoryTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import static org.junit.Assert.*;
-
-import java.io.InputStream;
-import java.util.concurrent.Future;
-
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.experimental.ParserFactory;
-import org.apache.commons.rdf.experimental.ParserFactory.*;
-import org.apache.commons.rdf.simple.SimpleRDF;
-import org.junit.Test;
-
-public class ParserFactoryTest {
-    @Test
-    public void testName() throws Exception {
-        ParserFactory f = new ParserFactoryImpl((a,b,c,d,e) -> 1);
-        InputStream is = getClass().getResourceAsStream("Fred");
-        Async g = f.syntax(RDFSyntax.JSONLD).rdf(new SimpleRDF()).base("http://example.com/").source(is).async();
-        Future<Parsed<?,?>> x = g.parseAsync();
-        Parsed<?, ?> p = x.get();
-        System.out.println(p.count());
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
new file mode 100644
index 0000000..1377c2f
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
@@ -0,0 +1,30 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.io.InputStream;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.io.Async;
+import org.apache.commons.rdf.api.io.OptionalTarget;
+import org.apache.commons.rdf.api.io.Parsed;
+import org.apache.commons.rdf.api.io.ParserFactory;
+import org.apache.commons.rdf.simple.SimpleRDF;
+import org.junit.Test;
+
+public class ParserFactoryTest {
+    @Test
+    public void testName() throws Exception {
+        ParserFactory f = new ParserFactoryImpl((a,b,c,d,e) -> 1);
+        InputStream is = getClass().getResourceAsStream("Fred");
+        OptionalTarget<Dataset> p = f.rdf(new SimpleRDF());
+        Dataset ds = p.source("hello").parse().target().target();
+        
+        
+        Async<Dataset, InputStream> g = f.syntax(RDFSyntax.JSONLD).rdf(new SimpleRDF()).base("http://example.com/").source(is).async();
+        
+        Future<Parsed<Dataset, InputStream>> x = g.parseAsync();
+        Parsed<Dataset, InputStream> p2 = x.get();    
+        System.out.println(p2.count());
+    }
+}


[06/17] commons-rdf git commit: Split out fluent interfaces

Posted by st...@apache.org.
Split out fluent interfaces

under org.apache.commons.rdf.api.io


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/a11db68d
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/a11db68d
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/a11db68d

Branch: refs/heads/fluent-parser
Commit: a11db68d6cb78be783cef91163bc1e952834350f
Parents: 84a644d
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Feb 24 11:31:04 2017 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 18:58:54 2018 +0000

----------------------------------------------------------------------
 .../org/apache/commons/rdf/api/io/Async.java    |  28 ++
 .../commons/rdf/api/io/NeedSourceBased.java     |  27 ++
 .../commons/rdf/api/io/NeedSourceOrBase.java    |  23 ++
 .../apache/commons/rdf/api/io/NeedTarget.java   |  23 ++
 .../commons/rdf/api/io/NeedTargetOrRDF.java     |  23 ++
 .../org/apache/commons/rdf/api/io/Option.java   |  25 ++
 .../commons/rdf/api/io/OptionalTarget.java      |  23 ++
 .../org/apache/commons/rdf/api/io/Parsed.java   |  26 ++
 .../commons/rdf/api/io/ParserFactory.java       |  25 ++
 .../apache/commons/rdf/api/io/ParserSource.java |  33 ++
 .../apache/commons/rdf/api/io/ParserTarget.java |  32 ++
 .../org/apache/commons/rdf/api/io/Sync.java     |  29 ++
 .../apache/commons/rdf/api/io/_Buildable.java   |  47 +++
 .../rdf/api/io/_NeedIdentifiedSource.java       |  34 ++
 .../apache/commons/rdf/api/io/_NeedTarget.java  |  29 ++
 .../commons/rdf/api/io/_NeedTargetOrRDF.java    |  21 ++
 .../commons/rdf/api/io/_OptionalBase.java       |  26 ++
 .../apache/commons/rdf/api/io/_OptionalRDF.java |  25 ++
 .../apache/commons/rdf/api/io/package-info.java |  21 ++
 .../commons/rdf/experimental/ParserFactory.java | 143 --------
 .../test/resources/example-rdf/example.jsonld   |  32 +-
 .../rdf4j/experimental/RDF4JParserFactory.java  | 212 +++++++++++
 .../rdf/rdf4j/experimental/RDF4JParserTest.java |  75 ++++
 .../rdf/simple/experimental/DatasetTarget.java  |  25 --
 .../rdf/simple/experimental/GraphTarget.java    |  29 --
 .../rdf/simple/experimental/IRISource.java      |  20 -
 .../experimental/ImplicitDatasetTarget.java     |  37 --
 .../simple/experimental/InputStreamSource.java  |  20 -
 .../rdf/simple/experimental/ParsedImpl.java     |  34 --
 .../rdf/simple/experimental/ParserBuilder.java  | 150 --------
 .../simple/experimental/ParserFactoryImpl.java  |  44 ---
 .../experimental/ParserImplementation.java      |  14 -
 .../rdf/simple/experimental/PathSource.java     |  20 -
 .../commons/rdf/simple/experimental/State.java  | 356 ------------------
 .../commons/rdf/simple/io/DatasetTarget.java    |  25 ++
 .../commons/rdf/simple/io/GraphTarget.java      |  27 ++
 .../apache/commons/rdf/simple/io/IRISource.java |  53 +++
 .../rdf/simple/io/ImplicitDatasetTarget.java    |  35 ++
 .../rdf/simple/io/InputStreamSource.java        |  32 ++
 .../apache/commons/rdf/simple/io/ParseJob.java  | 364 +++++++++++++++++++
 .../commons/rdf/simple/io/ParsedImpl.java       |  34 ++
 .../commons/rdf/simple/io/ParserBuilder.java    | 159 ++++++++
 .../rdf/simple/io/ParserFactoryImpl.java        |  52 +++
 .../rdf/simple/io/ParserImplementation.java     |  14 +
 .../commons/rdf/simple/io/PathSource.java       |  46 +++
 .../commons/rdf/simple/io/package-info.java     |  21 ++
 .../simple/experimental/ParserFactoryTest.java  |  24 --
 .../rdf/simple/io/ParserFactoryTest.java        |  30 ++
 48 files changed, 1717 insertions(+), 930 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/Async.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Async.java b/api/src/main/java/org/apache/commons/rdf/api/io/Async.java
new file mode 100644
index 0000000..2c99a0b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/Async.java
@@ -0,0 +1,28 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.util.concurrent.Future;
+
+public interface Async<T, S> extends _Buildable {
+    Async<T, S> build();
+    
+    <V> Async<T, S> option(Option<V> option, V value);
+
+    Future<Parsed<T, S>> parseAsync();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java
new file mode 100644
index 0000000..d390529
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java
@@ -0,0 +1,27 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.InputStream;
+
+public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
+    NeedSourceBased<T> build();
+    <V> NeedSourceBased<T> option(Option<V> option, V value);
+
+    Sync<T, InputStream> source(InputStream is);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java
new file mode 100644
index 0000000..4211137
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java
@@ -0,0 +1,23 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T>, _Buildable {
+    NeedSourceOrBase<T> build();
+    <V> NeedSourceOrBase<T> option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java
new file mode 100644
index 0000000..4816382
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java
@@ -0,0 +1,23 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+interface NeedTarget extends _NeedTarget,_Buildable {
+    NeedTarget build();
+    <V> NeedTarget option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java
new file mode 100644
index 0000000..1ed3b0a
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java
@@ -0,0 +1,23 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
+    NeedTargetOrRDF build();
+    <V> NeedTargetOrRDF option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/Option.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Option.java b/api/src/main/java/org/apache/commons/rdf/api/io/Option.java
new file mode 100644
index 0000000..7cf5c86
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/Option.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface Option<V> {
+
+    public interface RequiredOption<V> extends Option<V> {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java
new file mode 100644
index 0000000..f9bf651
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java
@@ -0,0 +1,23 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T>,_Buildable {
+    OptionalTarget<T> build();
+    <V> OptionalTarget<T> option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java b/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
new file mode 100644
index 0000000..753eda1
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
@@ -0,0 +1,26 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface Parsed<T, S> {
+    long count();
+
+    ParserSource<S> source();
+
+    ParserTarget<T> target();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
new file mode 100644
index 0000000..6026b00
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+
+public interface ParserFactory extends _NeedTargetOrRDF {
+
+    NeedTargetOrRDF syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
new file mode 100644
index 0000000..7aa5dee
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
@@ -0,0 +1,33 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+
+/**
+ *
+ */
+public interface ParserSource<S> {
+    S source();   
+    InputStream inputStream() throws IOException;
+    Optional<IRI> iri();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
new file mode 100644
index 0000000..a2ef4aa
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
@@ -0,0 +1,32 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.Quad;
+
+/**
+ *
+ */
+@FunctionalInterface
+public interface ParserTarget<T> extends Consumer<Quad> {
+    default T target() {
+        return null;// unknown
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java b/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java
new file mode 100644
index 0000000..7d8add7
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java
@@ -0,0 +1,29 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.util.concurrent.ExecutorService;
+
+public interface Sync<T, S> extends _Buildable{
+    Sync<T ,S> build();
+    <V> Sync<T, S> option(Option<V> option, V value);
+
+    Async<T, S> async();
+    Async<T, S> async(ExecutorService executor);
+    Parsed<T, S> parse();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.java b/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.java
new file mode 100644
index 0000000..23c4561
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.io.Option.RequiredOption;
+
+interface _Buildable {
+    /**
+     * Return an immutable builder at the current state. The returned builder
+     * can be re-used multiple times in a thread-safe way.
+     * 
+     * @return
+     */
+    _Buildable build();
+    
+    /**
+     * Return a builder with the given option set.
+     * <p>
+     * Note that implementations of {@link ParserFactory} may support different
+     * vendor-specific {@link Option} types, and are free to ignore the set
+     * option (unless it is a {@link RequiredOption}).
+     * <p>
+     * It is undefined if setting multiple values for the same (equal) option
+     * are accumulative or overriding.
+     * 
+     * @param option
+     * @param value
+     * @return
+     */
+    <V> _Buildable option(Option<V> option, V value);
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java
new file mode 100644
index 0000000..bc4a55c
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java
@@ -0,0 +1,34 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.nio.file.Path;
+
+import javax.xml.transform.Source;
+
+import org.apache.commons.rdf.api.IRI;
+
+interface _NeedIdentifiedSource<T> {
+    Sync<T, IRI> source(IRI iri);
+
+    Sync<T, Path> source(Path path);
+
+    <S> Sync<T, S> source(ParserSource<S> source);
+
+    Sync<T, IRI> source(String iri);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java
new file mode 100644
index 0000000..a8385dc
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java
@@ -0,0 +1,29 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+
+interface _NeedTarget {
+    NeedSourceOrBase<Dataset> target(Dataset dataset);
+
+    NeedSourceOrBase<Graph> target(Graph graph);
+
+    <T> NeedSourceOrBase<T> target(ParserTarget<T> target);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java
new file mode 100644
index 0000000..daf34fe
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java
@@ -0,0 +1,21 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java b/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java
new file mode 100644
index 0000000..f9a4e2d
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java
@@ -0,0 +1,26 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.IRI;
+
+interface _OptionalBase<T> {
+    NeedSourceBased<T> base(IRI iri);
+
+    NeedSourceBased<T> base(String iri);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java b/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java
new file mode 100644
index 0000000..b593e2b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.RDF;
+
+interface _OptionalRDF {
+    OptionalTarget<Dataset> rdf(RDF rdf);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
new file mode 100644
index 0000000..e80574b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java b/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
deleted file mode 100644
index 2b4fcf3..0000000
--- a/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed  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
- *  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,
- * OUT 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 org.apache.commons.rdf.experimental;
-
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.Quad;
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.experimental.ParserFactory.NeedSourceBased;
-import org.apache.commons.rdf.experimental.ParserFactory.NeedSourceOrBase;
-import org.apache.commons.rdf.experimental.ParserFactory.OptionalTarget;
-import org.apache.commons.rdf.experimental.ParserFactory.Sync;
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public interface ParserFactory extends _NeedTargetOrRDF {
-    
-    interface Async<T, S> {
-        <V> Async<T, S> option(Option<V> option, V value);
-
-        Future<Parsed<T, S>> parseAsync();
-    }
-
-    interface NeedSourceBased<T> extends _NeedIdentifiedSource<T> {
-        <V> NeedSourceBased<T> option(Option<V> option, V value);
-
-        Sync<T, InputStream> source(InputStream is);
-    }
-
-    interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T> {
-        <V> NeedSourceOrBase<T> option(Option<V> option, V value);
-    }
-
-    interface NeedSourceOrBaseOrSyntax<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T> {
-        <V> NeedSourceOrBaseOrSyntax<T> option(Option<V> option, V value);
-
-        NeedSourceOrBase<T> syntax(RDFSyntax syntax);
-    }
-
-    interface NeedTarget extends _NeedTarget {
-        <V> NeedTarget option(Option<V> option, V value);
-    }
-
-    interface NeedTargetOrRDF extends _NeedTargetOrRDF {
-        <V> NeedTargetOrRDF option(Option<V> option, V value);
-    }
-
-    interface NeedTargetOrRDFOrSyntax extends _NeedTargetOrRDF {
-        <V> NeedTargetOrRDFOrSyntax option(Option<V> option, V value);
-    }
-
-    interface Option<V> {
-    }
-
-    interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T> {
-        <V> OptionalTarget<T> option(Option<V> option, V value);
-    }
-
-    interface Parsed<T, S> {
-        long count();
-
-        Source<S> source();
-
-        Target<T> target();
-    }
-
-    interface Sync<T, S> {
-        Async<T, S> async();
-
-        Async<T, S> async(ExecutorService executor);
-
-        <V> Sync<T, S> option(Option<V> option, V value);
-
-        Parsed<T, S> parse();
-    }
-
-    interface Source<T> {
-        T source();
-    }
-
-    @FunctionalInterface
-    interface Target<T> extends Consumer<Quad> {
-        default T target() {
-            return null; // unknown
-        }
-    }
-
-    NeedTargetOrRDF syntax(RDFSyntax syntax);
-}
-
-interface _NeedIdentifiedSource<T> {
-    Sync<T, IRI> source(IRI iri);
-
-    Sync<T, Path> source(Path path);
-
-    <S> Sync<T, S> source(Source<S> source);
-
-    Sync<T, IRI> source(String iri);
-}
-
-interface _NeedTarget {
-    NeedSourceOrBase<Dataset> target(Dataset dataset);
-
-    NeedSourceOrBase<Graph> target(Graph graph);
-
-    <T> NeedSourceOrBase<T> target(Target<T> target);
-}
-
-interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
-}
-
-interface _OptionalBase<T> {
-    NeedSourceBased<T> base(IRI iri);
-
-    NeedSourceBased<T> base(String iri);
-}
-
-interface _OptionalRDF {
-    OptionalTarget rdf(RDF rdf);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/commons-rdf-api/src/test/resources/example-rdf/example.jsonld
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/test/resources/example-rdf/example.jsonld b/commons-rdf-api/src/test/resources/example-rdf/example.jsonld
index d6fb670..179d8fa 100644
--- a/commons-rdf-api/src/test/resources/example-rdf/example.jsonld
+++ b/commons-rdf-api/src/test/resources/example-rdf/example.jsonld
@@ -1,25 +1,29 @@
 {
-  "@graph" : [ {
-    "@id" : "_:b0",
+ "@context" : {
+  "name": "http://schema.org/name",
+  "rights": "http://purl.org/dc/terms/rights",
+  "license" : {
+    "@id" : "http://purl.org/dc/terms/license",
+    "@type" : "@id"
+  }
+ },
+ "@graph" : [ 
+  {
+    "@id" : "",
+    "name": "JSON-LD example",
     "license" : "http://www.apache.org/licenses/LICENSE-2.0",
     "rights" : {
       "@language" : "en",
       "@value" : "Licensed to the Apache Software Foundation (ASF) under one\n or more contributor license agreements. See the NOTICE file\n distributed with this work for additional information\n regarding copyright ownership. The ASF licenses this file\n to you under the Apache License, Version 2.0 (the\n \"License\"); you may not use this file except in compliance\n with the License.  You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n"
     }
   }, {
-    "@graph" : [ {
+    "@id" : "_:b0",
+    "name": "Same BNode",
+    "@graph" : [{
       "@id" : "_:b0",
+      "name": "Graph with different license",
       "license" : "http://example.com/LICENSE"
-    } ],
-    "@id" : "http://example.com"
-  } ],
-  "@context" : {
-    "rights" : {
-      "@id" : "http://purl.org/dc/terms/rights"
-    },
-    "license" : {
-      "@id" : "http://purl.org/dc/terms/license",
-      "@type" : "@id"
-    }
+    }]
   }
+ ]
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserFactory.java
new file mode 100644
index 0000000..c11efe7
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserFactory.java
@@ -0,0 +1,212 @@
+package org.apache.commons.rdf.rdf4j.experimental;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.rdf4j.RDF4J;
+import org.apache.commons.rdf.rdf4j.RDF4JBlankNodeOrIRI;
+import org.apache.commons.rdf.rdf4j.RDF4JDataset;
+import org.apache.commons.rdf.rdf4j.RDF4JGraph;
+import org.apache.commons.rdf.simple.experimental.IRISource;
+import org.apache.commons.rdf.simple.experimental.ParserBuilder;
+import org.apache.commons.rdf.simple.experimental.ParserFactoryImpl;
+import org.apache.commons.rdf.simple.experimental.ParserImplementation;
+import org.apache.commons.rdf.simple.experimental.PathSource;
+import org.eclipse.rdf4j.model.Model;
+import org.eclipse.rdf4j.model.Resource;
+import org.eclipse.rdf4j.model.Statement;
+import org.eclipse.rdf4j.repository.util.RDFInserter;
+import org.eclipse.rdf4j.repository.util.RDFLoader;
+import org.eclipse.rdf4j.rio.ParserConfig;
+import org.eclipse.rdf4j.rio.RDFFormat;
+import org.eclipse.rdf4j.rio.RDFHandler;
+import org.eclipse.rdf4j.rio.RDFHandlerException;
+import org.eclipse.rdf4j.rio.RDFParseException;
+import org.eclipse.rdf4j.rio.Rio;
+import org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler;
+import org.eclipse.rdf4j.rio.helpers.RDFHandlerBase;
+import org.eclipse.rdf4j.rio.helpers.RDFHandlerWrapper;
+
+public class RDF4JParserFactory extends ParserFactoryImpl {
+
+    public RDF4JParserFactory() {
+        super(new RDF4JParserImpl());
+    }
+    
+    private static RDFHandler makeRDFHandler(
+            @SuppressWarnings("rawtypes") Target target, 
+            RDF rdf) {
+        Object t = target.target();
+        if (t instanceof RDF4JDataset) {
+            // One of us, we can add them as Statements directly
+            final RDF4JDataset dataset = (RDF4JDataset) t;
+            if (dataset.asRepository().isPresent()) {
+                return new RDFInserter(dataset.asRepository().get().getConnection());
+            }
+            if (dataset.asModel().isPresent()) {
+                final Model model = dataset.asModel().get();
+                return new AddToModel(model);
+            }
+            // Not backed by Repository or Model?
+            // Third-party RDF4JDataset subclass, so we'll fall through to the
+            // Dataset handling
+        }
+        if (t instanceof RDF4JGraph) {
+            final RDF4JGraph graph = (RDF4JGraph) t;
+
+            if (graph.asRepository().isPresent()) {
+                final RDFInserter inserter = new RDFInserter(graph.asRepository().get().getConnection());
+                if (!graph.getContextMask().isEmpty()) {
+                    final Stream<RDF4JBlankNodeOrIRI> b = graph.getContextMask().stream();
+                    final Stream<Resource> c = b.map(RDF4JBlankNodeOrIRI::asValue);
+                    final Resource[] contexts = c.toArray(Resource[]::new);
+                    inserter.enforceContext(contexts);
+                }
+                return inserter;
+            }
+            if (graph.asModel().isPresent() && graph.getContextMask().isEmpty()) {
+                // the model accepts any quad
+                final Model model = graph.asModel().get();
+                return new AddToModel(model);
+            }
+        }
+        // Fall thorough: let target consume our converted quads.
+        return new AddToQuadConsumer(target, rdf);
+    }
+
+    private static final class RDF4JParserImpl implements ParserImplementation {
+        @Override
+        @SuppressWarnings("rawtypes") 
+        public long parse(Source source, Optional<RDFSyntax> rdfSyntax, 
+               Target target, Optional<RDF> rdf, Map<Option, Object> map) {
+            final CountingHandler rdfHandler = new CountingHandler(makeRDFHandler(target, rdf));
+            RDF4J rdf4j;
+            if (rdf.isPresent() && rdf.get() instanceof RDF4J) { 
+                rdf4j = (RDF4J) rdf.get();
+            } else { 
+                rdf4j = new RDF4J();
+            }            
+            // TODO: Support setting ParserConfig as Option?
+            ParserConfig parserConfig = new ParserConfig();
+            final RDFLoader loader = new RDFLoader(parserConfig, rdf4j.getValueFactory());
+            
+            
+            IRI baseIri = (IRI) map.getOrDefault(ParserBuilder.BaseOption.BASE, source.iri());
+            String base; // handle null
+            
+            if (source instanceof PathSource) {
+                Path p = ((PathSource)source).source();
+                
+                // rdfSyntax might not be present, or might not match RDF4J's known mime types
+                Optional<RDFFormat> formatByMimeType = rdfSyntax.flatMap(Rio::getParserFormatForMIMEType);
+                
+                // but RDF4J  can also try to guess it by the file name                
+                final Optional<RDFFormat> formatByFilename = p.map(Path::getFileName).map(Path::toString)
+                        .flatMap(Rio::getParserFormatForFileName);
+                // TODO: for the excited.. what about the extension after following
+                // symlinks? 
+                
+                final RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null));
+                
+                try (InputStream in = Files.newInputStream(p)) { 
+                    loader.load(in, base.getIRIString(), format, rdfHandler);
+                }
+                return rdfHandler.count();
+                
+            }
+            if (source instanceof IRISource) { 
+                // TODO: Do we support other iri()'s?
+                IRI i = source.iri();
+                
+                return rdfHandler.count()
+            } else {
+                // Fallback to parsing InputStream
+                InputStream in = source.inputStream();
+                // MUST have base and format
+                IRI base = (IRI) map.getOrDefault(ParserBuilder.BaseOption.BASE, source.iri());
+                RDFFormat format = Rio.getParserFormatForMIMEType(rdfSyntax.mediaType()).get();
+                try {
+                    loader.load(in, base.getIRIString(), format, rdfHandler);
+                } catch (RDFParseException | RDFHandlerException | IOException e) {
+                    throw new RuntimeException("Can't parse", e);
+                }
+                        
+                return rdfHandler.count();
+            }
+        }
+    }
+
+    public static class CountingHandler extends RDFHandlerWrapper implements RDFHandler {
+        private final AtomicLong counter = new AtomicLong();
+        public CountingHandler(RDFHandler makeRDFHandler) {
+            super(makeRDFHandler);
+        }
+        @Override
+        public void handleStatement(Statement st) throws RDFHandlerException {
+            super.handleStatement(st);
+            counter.incrementAndGet();
+        }
+        public long count() {
+            return counter.get();
+        }        
+    }
+    
+    private static final class AddToQuadConsumer extends AbstractRDFHandler {
+        private final Consumer<Quad> quadTarget;
+        private final RDF4J rdf4j;
+
+        private AddToQuadConsumer(final Consumer<Quad> quadTarget, final RDF rdf) {
+            this.quadTarget = quadTarget;
+            if (rdf instanceof RDF4J) { 
+                this.rdf4j = (RDF4J) rdf;
+            } else { 
+                this.rdf4j = new RDF4J();
+            }
+        }
+
+        @Override
+        public void handleStatement(final org.eclipse.rdf4j.model.Statement st)
+                throws org.eclipse.rdf4j.rio.RDFHandlerException {
+            quadTarget.accept(rdf4j.asQuad(st));
+            // Performance note:
+            // Graph/Quad.add should pick up again our
+            // RDF4JGraphLike.asStatement()
+            // and avoid double conversion.
+            // Additionally the RDF4JQuad and RDF4JTriple implementations
+            // are lazily converting subj/obj/pred/graph.s
+        }
+    }
+
+    private static final class AddToModel extends AbstractRDFHandler {
+        private final Model model;
+
+        public AddToModel(final Model model) {
+            this.model = model;
+        }
+
+        @Override
+        public void handleStatement(final org.eclipse.rdf4j.model.Statement st)
+                throws org.eclipse.rdf4j.rio.RDFHandlerException {
+            model.add(st);
+        }
+
+        @Override
+        public void handleNamespace(final String prefix, final String uri) throws RDFHandlerException {
+            model.setNamespace(prefix, uri);
+        }
+    }
+
+    
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
new file mode 100644
index 0000000..4a0200f
--- /dev/null
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
@@ -0,0 +1,75 @@
+/**
+ * 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 org.apache.commons.rdf.rdf4j.experimental;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.rdf4j.RDF4J;
+import org.junit.Test;
+
+public class RDF4JParserTest {
+    RDF4J rdf = new RDF4J();
+
+    @Test
+    public void parseJsonLd() throws Exception {
+        IRI base = rdf.createIRI("http://example.com/ex.jsonld");
+        IRI name = rdf.createIRI("http://schema.org/name");
+        IRI license = rdf.createIRI("http://purl.org/dc/terms/license");
+        IRI rights = rdf.createIRI("http://purl.org/dc/terms/rights");
+        IRI apacheLicense = rdf.createIRI("http://www.apache.org/licenses/LICENSE-2.0");
+        IRI exampleLicense = rdf.createIRI("http://example.com/LICENSE");
+
+        Dataset ds = new RDF4JParserFactory().syntax(RDFSyntax.JSONLD).rdf(rdf).base(base)
+                .source(getClass().getResourceAsStream("/example-rdf/example.jsonld")).parse().target().target();
+
+        // default graph
+        try (Stream<? extends Quad> s = ds.stream()) {
+            s.forEach(System.out::println);
+        }
+        System.out.println();
+        assertTrue(ds.getGraph().contains(base, name, rdf.createLiteral("JSON-LD example")));
+        assertTrue(ds.getGraph().contains(base, rights, null));
+        assertTrue(ds.getGraph().contains(base, license, apacheLicense));
+        // no leak from named graph
+        assertFalse(ds.getGraph().contains(base, license, exampleLicense));
+
+        // Let's find the bnode in the default graph
+        BlankNodeOrIRI bnode = firstSubject(ds, name, rdf.createLiteral("Same BNode"));
+        assertTrue(bnode instanceof BlankNode);
+        // the bnode should be the same inside the graph with the same bnode
+        assertTrue(ds.contains(Optional.of(bnode), bnode, name, rdf.createLiteral("Graph with different license")));
+    }
+
+    private BlankNodeOrIRI firstSubject(Dataset ds, IRI pred, RDFTerm obj) {
+        try (Stream<? extends Quad> s = ds.stream(Optional.empty(), null, pred, obj)) {
+            return s.findAny().get().getSubject();
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
deleted file mode 100644
index 714e188..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/DatasetTarget.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Quad;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public class DatasetTarget implements Target<Dataset> {
-
-    private final Dataset dataset;
-
-    public DatasetTarget(Dataset dataset) {
-        this.dataset = dataset;
-    }
-    
-    @Override
-    public void accept(Quad q) {
-        dataset.add(q);
-    }
-    
-    @Override
-    public Dataset target() {
-        return dataset;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
deleted file mode 100644
index 6270048..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/GraphTarget.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.Quad;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public class GraphTarget implements Target<Graph> {
-
-    private Graph graph;
-
-    public GraphTarget(Graph graph) {
-        this.graph = graph;
-    }
-
-    @Override
-    public void accept(Quad q) {
-        if (! q.getGraphName().isPresent()) {
-            graph.add(q.asTriple());
-        }
-    }
-    
-    @Override
-    public Graph target() {
-        return graph;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java
deleted file mode 100644
index 8324929..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/IRISource.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-
-public final class IRISource implements Source<IRI> {
-
-    private final IRI source;
-
-    public IRISource(IRI iri) {
-        this.source = iri;
-    }
-
-    @Override
-    public IRI source() {
-        return source;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
deleted file mode 100644
index 0b0de2d..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ImplicitDatasetTarget.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Quad;
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public class ImplicitDatasetTarget implements Target<Dataset> {
-
-    private final RDF rdf;
-    
-    private Dataset target;
-
-    public ImplicitDatasetTarget(RDF rdf) {
-        this.rdf = rdf;
-    }
-    
-    @Override
-    public Dataset target() {
-        if (target == null) {
-            synchronized (this) {
-                // Make sure we only make it once
-                if (target == null) {
-                    target = rdf.createDataset();
-                }
-            }
-        }
-        return target;
-    }
-
-    @Override
-    public void accept(Quad t) {
-        target().add(t);        
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java
deleted file mode 100644
index f68ac78..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/InputStreamSource.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.io.InputStream;
-
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-
-public class InputStreamSource implements Source<InputStream> {
-
-    private final InputStream source;
-
-    public InputStreamSource(InputStream source) {
-        this.source = source;
-    }
-
-    @Override
-    public InputStream source() {
-        return source;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java
deleted file mode 100644
index afbac1f..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParsedImpl.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import org.apache.commons.rdf.experimental.ParserFactory.Parsed;
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public class ParsedImpl<T,S> implements Parsed<T, S> {
-
-    private final Source<S> source;
-    private final Target<T> target;
-    private final long count;
-
-    public ParsedImpl(Source<S> source, Target<T> target, final long count) {
-        this.source = source;
-        this.target = target;
-        this.count = count;
-    }
-
-    @Override
-    public long count() {
-        return count;
-    }
-    
-    @Override
-    public Source<S> source() {
-        return source;
-    }
-
-    @Override
-    public Target<T> target() {
-        return target;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
deleted file mode 100644
index 6842c54..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserBuilder.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.Quad;
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.experimental.ParserFactory.*;
-
-@SuppressWarnings({ "rawtypes", "unchecked" })
-public final class ParserBuilder implements NeedTargetOrRDF, NeedSourceBased, Sync, NeedSourceOrBase, OptionalTarget,
-        NeedSourceOrBaseOrSyntax, Async {
-
-    public static enum AsyncOption implements Option<ExecutorService> {
-        EXECUTOR_SERVICE
-    }
-
-    public static enum BaseOption implements Option<IRI> {
-        BASE        
-    }
-    
-    private final State state;
-
-    public ParserBuilder() {
-        this.state = new DefaultState();
-    }
-
-    public ParserBuilder(ParserImplementation impl) {
-        this.state = new WithImplementation(impl);
-    }
-
-    public ParserBuilder(State state) {
-        this.state = state;
-    }
-
-    @Override
-    public Async async() {
-        return async(ForkJoinPool.commonPool());
-    }
-
-    @Override
-    public Async async(ExecutorService executor) {
-        return newState(state.withOption(AsyncOption.EXECUTOR_SERVICE, executor));
-    }
-
-    @Override
-    public NeedSourceBased<Dataset> base(IRI iri) {
-        return newState(implicitTarget().withOption(BaseOption.BASE, iri));
-    }
-
-    @Override
-    public NeedSourceBased<Dataset> base(String iri) {
-        return base(state.rdf().createIRI(iri));
-    }
-
-    public ParserBuilder build() {
-        return newState(state.freeze());
-    }
-
-    @Override
-    public ParserBuilder option(Option o, Object v) {
-        return newState(state.withOption(o, v));
-    }
-
-    @Override
-    public Parsed parse() {
-        ParserImplementation impl = state.impl();
-        long count = impl.parse(state.source(), state.syntax(), state.target(), state.rdf(), state.optionsAsMap());
-        return new ParsedImpl<>(state.source(), state.target(), count);
-    }
-
-    @Override
-    public Future parseAsync() {
-        Map<Option, Object> options = state.optionsAsMap();
-        ExecutorService executor = (ExecutorService) options.getOrDefault(AsyncOption.EXECUTOR_SERVICE,
-                ForkJoinPool.commonPool());
-        return executor.submit(this::parse);
-    }
-
-    @Override
-    public OptionalTarget rdf(RDF rdf) {
-        return newState(state.withRDF(rdf));
-    }
-
-    @Override
-    public Sync source(InputStream is) {
-        return source(new InputStreamSource(is));
-    }
-
-    @Override
-    public Sync source(IRI iri) {
-        return source(new IRISource(iri));
-    }
-
-    @Override
-    public Sync source(Path path) {
-        return source(new PathSource(path));
-    }
-
-    @Override
-    public Sync source(Source source) {
-        return newState(implicitTarget().withSource(source));
-    }
-
-    @Override
-    public Sync source(String iri) {
-        return source(state.rdf().createIRI(iri));
-    }
-
-    public NeedSourceOrBase syntax(RDFSyntax syntax) {
-        return newState(state.withSyntax(syntax));
-    }
-
-    @Override
-    public NeedSourceOrBase<Dataset> target(Dataset dataset) {
-        return target(new DatasetTarget(dataset));
-    }
-
-    @Override
-    public NeedSourceOrBase<Graph> target(Graph graph) {
-        return target(new GraphTarget(graph));
-    }
-
-    @Override
-    public NeedSourceOrBase target(Target target) {
-        return newState(state.withTarget(target));
-    }
-
-    private State implicitTarget() {
-        return state.withTarget(new ImplicitDatasetTarget(state.rdf()));
-    }
-
-    private ParserBuilder newState(State newState) {
-        if (this.state == newState) {
-            // probably a MutableState
-            return this;
-        }
-        return new ParserBuilder(newState);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
deleted file mode 100644
index 70b7237..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserFactoryImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.experimental.ParserFactory;
-
-public class ParserFactoryImpl implements ParserFactory {
-
-    private State state;
-
-    public ParserFactoryImpl(ParserImplementation impl) {
-        this.state = new WithImplementation(impl);
-    }
-    
-    @Override
-    public NeedSourceOrBase<Graph> target(Graph graph) {
-        return target(new GraphTarget(graph));
-    }
-
-    @Override
-    public NeedSourceOrBase<Dataset> target(Dataset dataset) {
-        return target(new DatasetTarget(dataset));
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T> NeedSourceOrBase<T> target(Target<T> target) {
-        return new ParserBuilder(state.withTarget(target));
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public OptionalTarget<Dataset> rdf(RDF rdf) {
-        return new ParserBuilder(state.withRDF(rdf));
-    }
-
-    @Override
-    public NeedTargetOrRDF syntax(RDFSyntax syntax) {
-        return new ParserBuilder(state.withSyntax(syntax));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java
deleted file mode 100644
index 4284429..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/ParserImplementation.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.util.Map;
-
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.experimental.ParserFactory.Option;
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-
-public interface ParserImplementation {
-    @SuppressWarnings("rawtypes")
-    public long parse(Source source, RDFSyntax rdfSyntax, Target target, RDF rdf, Map<Option, Object> map);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java
deleted file mode 100644
index 0341f47..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/PathSource.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.nio.file.Path;
-
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-
-public class PathSource implements Source<Path> {
-    private final Path source;
-
-    public PathSource(Path source) {
-        this.source = source;
-    }
-    
-    @Override
-    public Path source() {
-        return source;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java
deleted file mode 100644
index f94f827..0000000
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/State.java
+++ /dev/null
@@ -1,356 +0,0 @@
-package org.apache.commons.rdf.simple.experimental;
-
-import java.util.AbstractMap.SimpleImmutableEntry;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.experimental.ParserFactory.Option;
-import org.apache.commons.rdf.experimental.ParserFactory.Source;
-import org.apache.commons.rdf.experimental.ParserFactory.Target;
-import org.apache.commons.rdf.simple.SimpleRDF;
-
-@SuppressWarnings("rawtypes")
-interface State {
-    ParserImplementation impl();
-    RDF rdf();
-    Source source();
-    Target target();
-    RDFSyntax syntax();
-    Stream<Map.Entry<Option, Object>> options();
-    Map<Option, Object> optionsAsMap();
-    State withRDF(RDF rdf);
-    State withSource(Source p);
-    State withTarget(Target g);
-    State withSyntax(RDFSyntax s);
-    <O> State withOption(Option<O> o, O v);
-    State withImplementation(ParserImplementation impl);
-    State freeze();
-}
-
-@SuppressWarnings("rawtypes")
-final class MutableState implements State, Cloneable {
-    private ParserImplementation impl;
-    private RDF rdf = new SimpleRDF();
-    private Source source;
-    private Target target;
-    private RDFSyntax syntax;
-    private Map<Option, Object> options = new LinkedHashMap<>();
-
-    @Override
-    public ParserImplementation impl() {
-        return Objects.requireNonNull(impl);
-    }
-    public State freeze() {
-        // options will be cloned inside constructor
-        return new FrozenState(impl, source, syntax, target, rdf, options);
-    }
-    @Override
-    public RDF rdf() {
-        return Objects.requireNonNull(rdf);
-    }
-    @Override
-    public Source source() {
-        return Objects.requireNonNull(source);
-    }
-    @Override
-    public Target target() {
-        return Objects.requireNonNull(target);
-    }
-    @Override
-    public RDFSyntax syntax() {
-        return Objects.requireNonNull(syntax);
-    }
-    @Override
-    public Stream<Entry<Option, Object>> options() {
-        return options.entrySet().stream();
-    }
-    @Override
-    public Map<Option, Object> optionsAsMap() {
-        return Collections.unmodifiableMap(options);
-    }
-    @Override
-    public State withRDF(RDF rdf) {
-        this.rdf = rdf;
-        return this;
-    }
-    @Override
-    public State withSource(Source s) {
-        this.source = s;
-        return this;
-    }
-    @Override
-    public State withTarget(Target t) {
-        this.target = t;
-        return this;
-    }
-    @Override
-    public State withSyntax(RDFSyntax s) {
-        this.syntax = s;
-        return this;
-    }
-    @Override
-    public <O> State withOption(Option<O> o, O v) {
-        options.put(o, v);
-        return this;
-    }
-    @Override
-    public State withImplementation(ParserImplementation impl) {
-        this.impl = impl;
-        return this;
-    }
-}
-
-
-@SuppressWarnings("rawtypes")
-abstract class ImmutableState implements State {
-    @Override
-    public State withSource(Source src) {
-        return new WithSource(src, this);
-    }
-    @Override
-    public State withSyntax(RDFSyntax s) {
-        return new WithSyntax(s, this);
-    }
-    @Override
-    public State withTarget(Target t) {
-        return new WithTarget(t, this);
-    }
-    public State withRDF(RDF rdf) {
-        return new WithRDF(rdf, this);
-    };
-    public <O> State withOption(Option<O> o, O v) {
-        return new WithOption(o, v, this);
-    };
-    @Override
-    public State withImplementation(ParserImplementation impl) {
-        return new WithImplementation(impl, this);
-    }
-    @Override
-    public State freeze() {
-        return this;
-    }
-}
-
-@SuppressWarnings("rawtypes")
-final class DefaultState extends ImmutableState {
-    @Override
-    public Source source() {
-        throw new IllegalStateException("Source not set");
-    }
-    @Override
-    public Target target() {
-        throw new IllegalStateException("Target not set");
-    }
-    @Override
-    public RDFSyntax syntax() {
-        throw new IllegalStateException("Syntax not set");
-    }
-    @Override
-    public RDF rdf() {
-        return new SimpleRDF(); // fresh every time?
-    }
-    @Override
-    public Stream<Entry<Option, Object>> options() {
-        return Stream.empty();
-    }
-    @Override
-    public Map<Option, Object> optionsAsMap() {
-        return Collections.emptyMap();
-    }
-    @Override
-    public ParserImplementation impl() {
-        throw new IllegalStateException("Implementation not set");
-    }
-}
-
-@SuppressWarnings("rawtypes")
-final class FrozenState extends ImmutableState implements State {
-    private final ParserImplementation impl;
-    private final Source source;
-    private final RDFSyntax syntax;
-    private final Target target;
-    private final RDF rdf;
-    private final Map<Option, Object> options;
-
-    public FrozenState(ParserImplementation impl, Source source, RDFSyntax syntax, Target target, RDF rdf,
-            Map<Option, Object> options) {
-        this.impl = impl;
-        this.source = source;
-        this.syntax = syntax;
-        this.target = target;
-        this.rdf = rdf;
-        // shallow copy of options
-        this.options = Collections.unmodifiableMap(new LinkedHashMap<>(options));
-    }
-    @Override
-    public ParserImplementation impl() {
-        return impl;
-    }
-    @Override
-    public RDF rdf() {
-        return rdf;
-    }
-    @Override
-    public Source source() {
-        return source;
-    }
-    @Override
-    public Target target() {
-        return target;
-    }
-    @Override
-    public RDFSyntax syntax() {
-        return syntax;
-    }
-    @Override
-    public Stream<Entry<Option, Object>> options() {
-        return options.entrySet().stream();
-    }
-    @Override
-    public Map<Option, Object> optionsAsMap() {
-        return options;
-    }
-}
-
-@SuppressWarnings("rawtypes")
-abstract class Inherited extends ImmutableState {
-    private final ImmutableState parent;
-    public Inherited() {
-        this(new DefaultState());
-    }
-    public Inherited(ImmutableState state) {
-        parent = state;
-    }
-    @Override
-    public Source source() {
-        return parent.source();
-    }
-    @Override
-    public Target target() {
-        return parent.target();
-    }
-    @Override
-    public RDFSyntax syntax() {
-        return parent.syntax();
-    }
-    @Override
-    public RDF rdf() {
-        return parent.rdf();
-    }
-    @Override
-    public Stream<Entry<Option, Object>> options() {
-        return parent.options();
-    }
-    @Override
-    public Map<Option, Object> optionsAsMap() {
-        return parent.optionsAsMap();
-    }
-    @Override
-    public ParserImplementation impl() {
-        return parent.impl();
-    }
-}
-
-@SuppressWarnings("rawtypes")
-final class WithSource extends Inherited {
-    private final Source source;
-
-    public WithSource(final Source src) {
-        this.source = src;
-    }
-    public WithSource(final Source src, final ImmutableState state) {
-        super(state);
-        this.source = src;
-    }
-    @Override
-    public Source source() {
-        return source;
-    }
-}
-
-@SuppressWarnings("rawtypes")
-final class WithTarget extends Inherited {
-    private final Target target;
-
-    public WithTarget(final Target t) {
-        this.target = t;
-    }
-    public WithTarget(final Target t, final ImmutableState state) {
-        super(state);
-        this.target = t;
-    }
-    @Override
-    public Target target() {
-        return target;
-    }
-}
-
-final class WithSyntax extends Inherited {
-    private final RDFSyntax syntax;
-    public WithSyntax(final RDFSyntax s) {
-        syntax = s;
-    }
-    public WithSyntax(final RDFSyntax s, final ImmutableState state) {
-        super(state);
-        syntax = s;
-    }
-    @Override
-    public RDFSyntax syntax() {
-        return syntax;
-    }
-}
-
-final class WithRDF extends Inherited {
-    private final RDF rdf;
-    public WithRDF(final RDF r) {
-        rdf = r;
-    }
-    public WithRDF(final RDF r, final ImmutableState state) {
-        super(state);
-        rdf = r;
-    }
-    @Override
-    public RDF rdf() {
-        return rdf;
-    }
-}
-
-@SuppressWarnings({ "rawtypes", "unchecked" })
-final class WithOption extends Inherited {
-    private Option<? extends Object> option;
-    private Object value;
-    public <O> WithOption(Option<O> o, O v, ImmutableState immutableState) {
-        this.option = o;
-        this.value = v;
-    }
-    @Override
-    public Stream<Entry<Option, Object>> options() {
-        return Stream.concat(super.options(), Stream.of(new SimpleImmutableEntry(option, value)));
-    }
-    @Override
-    public Map<Option, Object> optionsAsMap() {
-        return options().collect(Collectors.toMap(Entry::getKey, Entry::getValue));
-    }
-}
-
-final class WithImplementation extends Inherited {
-    private final ParserImplementation impl;
-    public WithImplementation(ParserImplementation impl) {
-        this.impl = impl;
-    }
-    public WithImplementation(ParserImplementation impl, ImmutableState parent) {
-        super(parent);
-        this.impl = impl;
-    }
-    @Override
-    public ParserImplementation impl() {
-        return impl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
new file mode 100644
index 0000000..e8535d7
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
@@ -0,0 +1,25 @@
+package org.apache.commons.rdf.simple.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+public class DatasetTarget implements ParserTarget<Dataset> {
+
+    private final Dataset dataset;
+
+    public DatasetTarget(Dataset dataset) {
+        this.dataset = dataset;
+    }
+    
+    @Override
+    public void accept(Quad q) {
+        dataset.add(q);
+    }
+    
+    @Override
+    public Dataset target() {
+        return dataset;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
new file mode 100644
index 0000000..458c169
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
@@ -0,0 +1,27 @@
+package org.apache.commons.rdf.simple.io;
+
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+public class GraphTarget implements ParserTarget<Graph> {
+
+    private Graph graph;
+
+    public GraphTarget(Graph graph) {
+        this.graph = graph;
+    }
+
+    @Override
+    public void accept(Quad q) {
+        if (! q.getGraphName().isPresent()) {
+            graph.add(q.asTriple());
+        }
+    }
+    
+    @Override
+    public Graph target() {
+        return graph;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
new file mode 100644
index 0000000..9b251b0
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
@@ -0,0 +1,53 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.io.ParserSource;
+
+public final class IRISource implements ParserSource<IRI> {
+
+    private final IRI source;
+
+    public IRISource(IRI iri) {
+        this.source = iri;
+    }
+
+    @Override
+    public IRI source() {
+        return source;
+    }
+
+    /**
+     * NOTE: This does not follow HTTP redirects or perform content negotiation
+     * and should not generally be used.
+     */
+    @Override
+    public InputStream inputStream() {
+        // NOTE: This does not follow HTTP redirects, content negotiation,
+        try {
+            return asURL().openStream();
+        } catch (IOException ex) {
+            throw new UnsupportedOperationException("Unable to connect to " + source.getIRIString(), ex);
+        }
+    }
+
+    private URL asURL() throws MalformedURLException {
+        return new URL(source.getIRIString());
+    }
+
+    /**
+     * NOTE: This does not follow HTTP redirects, content negotiation, or
+     * respect the Content-Location, and so should NOT be used as a base URL
+     * when parsing.
+     */
+    @Override
+    public Optional<IRI> iri() {
+        return Optional.of(source);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
new file mode 100644
index 0000000..00be95e
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
@@ -0,0 +1,35 @@
+package org.apache.commons.rdf.simple.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+public class ImplicitDatasetTarget implements ParserTarget<Dataset> {
+
+    private final RDF rdf;
+    
+    private Dataset target;
+
+    public ImplicitDatasetTarget(RDF rdf) {
+        this.rdf = rdf;
+    }
+    
+    @Override
+    public Dataset target() {
+        if (target == null) {
+            synchronized (this) {
+                // Make sure we only make it once
+                if (target == null) {
+                    target = rdf.createDataset();
+                }
+            }
+        }
+        return target;
+    }
+
+    @Override
+    public void accept(Quad t) {
+        target().add(t);        
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a11db68d/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
new file mode 100644
index 0000000..2682176
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
@@ -0,0 +1,32 @@
+package org.apache.commons.rdf.simple.io;
+
+import java.io.InputStream;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.io.ParserSource;
+
+public class InputStreamSource implements ParserSource<InputStream> {
+
+    private final InputStream source;
+
+    public InputStreamSource(InputStream source) {
+        this.source = source;
+    }
+
+    @Override
+    public InputStream source() {
+        return source;
+    }
+    
+    @Override
+    public InputStream inputStream() {
+        return source;
+    }
+    
+    @Override
+    public Optional<IRI> iri() {
+        // Unknown base
+        return Optional.empty();
+    }
+}


[03/17] commons-rdf git commit: Parser refactoring

Posted by st...@apache.org.
Parser refactoring


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/7d05cc0b
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/7d05cc0b
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/7d05cc0b

Branch: refs/heads/fluent-parser
Commit: 7d05cc0bea6a13a7959813c532ea27500b447039
Parents: 96c21ea
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Tue Feb 21 01:05:46 2017 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 18:57:54 2018 +0000

----------------------------------------------------------------------
 .../commons/rdf/experimental/ParserFactory.java | 142 +++++++++++++++++++
 .../apache/commons/rdf/experimental/Test.java   | 130 +++++++++++++++++
 2 files changed, 272 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/7d05cc0b/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java b/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
new file mode 100644
index 0000000..b80ac91
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/experimental/ParserFactory.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed  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
+ *  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,
+ * OUT 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 org.apache.commons.rdf.experimental;
+
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.experimental.ParserFactory.NeedSourceBased;
+import org.apache.commons.rdf.experimental.ParserFactory.NeedSourceOrBase;
+import org.apache.commons.rdf.experimental.ParserFactory.OptionalTarget;
+import org.apache.commons.rdf.experimental.ParserFactory.Sync;
+import org.apache.commons.rdf.experimental.ParserFactory.Source;
+import org.apache.commons.rdf.experimental.ParserFactory.Target;
+
+public interface ParserFactory extends _NeedTargetOrRDF {
+    
+    interface Async<T, S> {
+        <V> Async<T, S> option(Option<V> option, V value);
+
+        Future<Parsed<T, S>> parseAsync();
+    }
+
+    interface NeedSourceBased<T> extends _NeedIdentifiedSource<T> {
+        <V> NeedSourceBased<T> option(Option<V> option, V value);
+
+        Sync<T, InputStream> source(InputStream is);
+    }
+
+    interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T> {
+        <V> NeedSourceOrBase<T> option(Option<V> option, V value);
+    }
+
+    interface NeedSourceOrBaseOrSyntax<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T> {
+        <V> NeedSourceOrBaseOrSyntax<T> option(Option<V> option, V value);
+
+        NeedSourceOrBase<T> syntax(RDFSyntax syntax);
+    }
+
+    interface NeedTarget extends _NeedTarget {
+        <V> NeedTarget option(Option<V> option, V value);
+    }
+
+    interface NeedTargetOrRDF extends _NeedTargetOrRDF {
+        <V> NeedTargetOrRDF option(Option<V> option, V value);
+    }
+
+    interface NeedTargetOrRDFOrSyntax extends _NeedTargetOrRDF {
+        <V> NeedTargetOrRDFOrSyntax option(Option<V> option, V value);
+    }
+
+    interface Option<V> {
+    }
+
+    interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T> {
+        <V> OptionalTarget<T> option(Option<V> option, V value);
+    }
+
+    interface Parsed<T, S> {
+        long count();
+
+        Source<S> source();
+
+        Target<T> target();
+    }
+
+    interface Sync<T, S> {
+        Async<T, S> async();
+
+        Async<T, S> async(ExecutorService executor);
+
+        <V> Sync<T, S> option(Option<V> option, V value);
+
+        Parsed<T, S> parse();
+    }
+
+    interface Source<T> {
+        T source();
+    }
+
+    interface Target<T> {
+        T target();
+    }
+
+    NeedTargetOrRDF syntax(RDFSyntax syntax);
+}
+
+interface _NeedIdentifiedSource<T> {
+    Sync<T, IRI> source(IRI iri);
+
+    Sync<T, Path> source(Path path);
+
+    <S> Sync<T, S> source(Source<S> source);
+
+    Sync<T, IRI> source(String iri);
+}
+
+interface _NeedTarget {
+    NeedSourceOrBase<Consumer<Quad>> target(Consumer<? super Quad> consumer);
+
+    NeedSourceOrBase<Dataset> target(Dataset dataset);
+
+    NeedSourceOrBase<Graph> target(Graph graph);
+
+    <T> NeedSourceOrBase<T> target(Target<T> target);
+}
+
+interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
+}
+
+interface _OptionalBase<T> {
+    NeedSourceBased<T> base(IRI iri);
+
+    NeedSourceBased<T> base(String iri);
+}
+
+interface _OptionalRDF {
+    OptionalTarget rdf(RDF rdf);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/7d05cc0b/api/src/test/java/org/apache/commons/rdf/experimental/Test.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/experimental/Test.java b/api/src/test/java/org/apache/commons/rdf/experimental/Test.java
new file mode 100644
index 0000000..cee0854
--- /dev/null
+++ b/api/src/test/java/org/apache/commons/rdf/experimental/Test.java
@@ -0,0 +1,130 @@
+package org.apache.commons.rdf.experimental;
+
+import static org.junit.Assert.*;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.slf4j.impl.SimpleLoggerFactory;
+
+interface State { 
+    Path source();
+    Graph target();
+    RDFSyntax syntax();
+    State withSource(Path p);
+    State withTarget(Graph g);
+    State withSyntax(RDFSyntax s);
+}
+
+abstract class AbstractState implements State { 
+    @Override
+    public State withSource(Path p) { 
+       return new WithSource(p, this); 
+    }
+    @Override
+    public State withSyntax(RDFSyntax s) {
+        return new WithSyntax(s, this);
+    }
+    @Override
+    public State withTarget(Graph g) {
+        return new WithTarget(g, this);
+    }
+    
+}
+
+final class DefaultState extends AbstractState {
+    @Override
+    public Path source() {
+        throw new IllegalStateException("Source not set");
+    }
+    @Override
+    public Graph target() {
+        throw new IllegalStateException("Target not set");
+    }
+    @Override
+    public RDFSyntax syntax() {
+        throw new IllegalStateException("Syntax not set");
+    }
+}
+
+abstract class Inherited extends AbstractState  {
+    private final State parent;
+    public Inherited() {
+        this(new DefaultState());
+    }
+    public Inherited(State state) {
+        parent = state;
+    }    
+    @Override
+    public Path source() {
+        return parent.source();
+    }
+    @Override
+    public Graph target() {
+        return parent.target();
+    }
+    @Override
+    public RDFSyntax syntax() {
+        return parent.syntax();
+    }
+    
+    
+}
+
+final class WithSource extends Inherited {    
+    private final Path source;   
+    public WithSource(final Path path) {
+        this.source = path;
+    }
+    public WithSource(final Path path, final State state) {
+        super(state);
+        this.source = path;
+    }    
+    @Override
+    public Path source() {
+        return source;
+    }
+}
+
+
+final class WithTarget extends Inherited {    
+    private final Graph target;   
+    public WithTarget(final Graph g) {
+        this.target = g;
+    }
+    public WithTarget(final Graph g, final State state) {
+        super(state);
+        this.target = g;
+    }    
+    @Override
+    public Graph target() {
+        return target;
+    }
+}
+
+final class WithSyntax extends Inherited {    
+    private final RDFSyntax syntax;   
+    public WithSyntax(final RDFSyntax s) {
+        syntax = s;
+    }
+    public WithSyntax(final RDFSyntax s, final State state) {
+        super(state);
+        syntax = s;
+    }    
+    @Override
+    public RDFSyntax syntax() {
+        return syntax;
+    }
+}
+
+public class Test {
+    @org.junit.Test
+    public void testName() throws Exception {
+        Path p = Paths.get("/tmp/f.txt");
+        Graph g = null;
+        State s = new DefaultState().withSource(p).withTarget(g).withSyntax(RDFSyntax.JSONLD);
+        
+    }
+}


[07/17] commons-rdf git commit: Rename parser methods

Posted by st...@apache.org.
Rename parser methods

source -> from
target -> into


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/577614d0
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/577614d0
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/577614d0

Branch: refs/heads/fluent-parser
Commit: 577614d0c1ac5330f109de9ad8231077a66cc316
Parents: 921965d
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Feb 14 18:40:58 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 19:00:43 2018 +0000

----------------------------------------------------------------------
 .../org/apache/commons/rdf/api/io/Parsed.java   |  4 +-
 .../apache/commons/rdf/api/io/ParserSource.java |  2 +-
 .../apache/commons/rdf/api/io/ParserTarget.java |  2 +-
 .../rdf/rdf4j/experimental/RDF4JParserTest.java |  2 +-
 .../commons/rdf/simple/io/DatasetTarget.java    |  2 +-
 .../commons/rdf/simple/io/GraphTarget.java      |  2 +-
 .../apache/commons/rdf/simple/io/IRISource.java |  2 +-
 .../rdf/simple/io/ImplicitDatasetTarget.java    |  4 +-
 .../rdf/simple/io/InputStreamSource.java        |  2 +-
 .../apache/commons/rdf/simple/io/ParseJob.java  | 24 +++---
 .../commons/rdf/simple/io/ParsedImpl.java       |  4 +-
 .../commons/rdf/simple/io/ParserBuilder.java    | 13 +--
 .../rdf/simple/io/ParserFactoryImpl.java        | 85 +++++++++++++++++---
 .../commons/rdf/simple/io/PathSource.java       |  2 +-
 .../rdf/simple/io/ParserFactoryTest.java        | 63 ++++++++++++---
 15 files changed, 155 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java b/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
index 753eda1..b252e44 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
@@ -20,7 +20,7 @@ package org.apache.commons.rdf.api.io;
 public interface Parsed<T, S> {
     long count();
 
-    ParserSource<S> source();
+    ParserSource<S> from();
 
-    ParserTarget<T> target();
+    ParserTarget<T> into();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
index 7aa5dee..259688e 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
@@ -27,7 +27,7 @@ import org.apache.commons.rdf.api.IRI;
  *
  */
 public interface ParserSource<S> {
-    S source();   
+    S src();   
     InputStream inputStream() throws IOException;
     Optional<IRI> iri();
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
index a2ef4aa..8898643 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
@@ -26,7 +26,7 @@ import org.apache.commons.rdf.api.Quad;
  */
 @FunctionalInterface
 public interface ParserTarget<T> extends Consumer<Quad> {
-    default T target() {
+    default T dest() {
         return null;// unknown
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
index 4a0200f..106d2c3 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParserTest.java
@@ -46,7 +46,7 @@ public class RDF4JParserTest {
         IRI exampleLicense = rdf.createIRI("http://example.com/LICENSE");
 
         Dataset ds = new RDF4JParserFactory().syntax(RDFSyntax.JSONLD).rdf(rdf).base(base)
-                .source(getClass().getResourceAsStream("/example-rdf/example.jsonld")).parse().target().target();
+                .source(getClass().getResourceAsStream("/example-rdf/example.jsonld")).parse().dest().dest();
 
         // default graph
         try (Stream<? extends Quad> s = ds.stream()) {

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
index e8535d7..8be990d 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/DatasetTarget.java
@@ -18,7 +18,7 @@ public class DatasetTarget implements ParserTarget<Dataset> {
     }
     
     @Override
-    public Dataset target() {
+    public Dataset dest() {
         return dataset;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
index 458c169..4be3586 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/GraphTarget.java
@@ -20,7 +20,7 @@ public class GraphTarget implements ParserTarget<Graph> {
     }
     
     @Override
-    public Graph target() {
+    public Graph dest() {
         return graph;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
index 9b251b0..1d63583 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/IRISource.java
@@ -18,7 +18,7 @@ public final class IRISource implements ParserSource<IRI> {
     }
 
     @Override
-    public IRI source() {
+    public IRI src() {
         return source;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
index 00be95e..35c6cf7 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ImplicitDatasetTarget.java
@@ -16,7 +16,7 @@ public class ImplicitDatasetTarget implements ParserTarget<Dataset> {
     }
     
     @Override
-    public Dataset target() {
+    public Dataset dest() {
         if (target == null) {
             synchronized (this) {
                 // Make sure we only make it once
@@ -30,6 +30,6 @@ public class ImplicitDatasetTarget implements ParserTarget<Dataset> {
 
     @Override
     public void accept(Quad t) {
-        target().add(t);        
+        dest().add(t);        
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
index 2682176..8fc0dd8 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/InputStreamSource.java
@@ -15,7 +15,7 @@ public class InputStreamSource implements ParserSource<InputStream> {
     }
 
     @Override
-    public InputStream source() {
+    public InputStream src() {
         return source;
     }
     

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
index eab29c9..79442c9 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParseJob.java
@@ -52,7 +52,7 @@ final class MutableParseJob implements ParseJob, Cloneable {
         return Objects.requireNonNull(impl);
     }
     public ImmutableParseJob freeze() {
-        return new FrozenParseJob(this);
+        return new FrozenParseJob(impl, source, syntax, target, rdf, options);
     }
     @Override
     public RDF rdf() {
@@ -182,18 +182,16 @@ final class FrozenParseJob extends ImmutableParseJobImpl implements ImmutablePar
     private final RDF rdf;
     private final Map<Option, Object> options;
 
-    public FrozenParseJob(ParseJob parseJob) {
-        this(parseJob.impl(), parseJob.source(), parseJob.syntax().orElse(null), 
-               parseJob.target(), parseJob.rdf(), parseJob.optionsAsMap());
-    }
-    public FrozenParseJob(ParserImplementation impl, ParserSource source, RDFSyntax syntax, ParserTarget target, RDF rdf,
-            Map<Option, Object> options) {
+    public FrozenParseJob(ParserImplementation impl, ParserSource source, RDFSyntax syntax, 
+                             ParserTarget target, RDF rdf, Map<Option, Object> options) {
         this.impl = Objects.requireNonNull(impl);
-        this.source =  Objects.requireNonNull(source);
+        // null -> Optional.empty() 
         this.syntax = Optional.ofNullable(syntax);
-        this.target = Objects.requireNonNull(target);
-        this.rdf = Objects.requireNonNull(rdf);
-        // shallow copy of options
+        // fields may be null (not yet set)
+        this.source =  source;
+        this.target = target;
+        this.rdf = rdf;
+        // shallow copy of options (can't be null)
         this.options = Collections.unmodifiableMap(new LinkedHashMap<>(options));
     }
     @Override
@@ -206,11 +204,11 @@ final class FrozenParseJob extends ImmutableParseJobImpl implements ImmutablePar
     }
     @Override
     public ParserSource source() {
-        return source;
+        return Objects.requireNonNull(source, "source not set");
     }
     @Override
     public ParserTarget target() {
-        return target;
+        return Objects.requireNonNull(target, "target not set");
     }
     @Override
     public Optional<RDFSyntax> syntax() {

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
index 3beed15..f93c551 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParsedImpl.java
@@ -22,12 +22,12 @@ public class ParsedImpl<T,S> implements Parsed<T, S> {
     }
     
     @Override
-    public ParserSource<S> source() {
+    public ParserSource<S> from() {
         return source;
     }
 
     @Override
-    public ParserTarget<T> target() {
+    public ParserTarget<T> into() {
         return target;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
index bb3eec7..9dc5eb9 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserBuilder.java
@@ -12,16 +12,16 @@ import org.apache.commons.rdf.api.Graph;
 import org.apache.commons.rdf.api.IRI;
 import org.apache.commons.rdf.api.RDF;
 import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.io.Async;
-import org.apache.commons.rdf.api.io.NeedSourceBased;
-import org.apache.commons.rdf.api.io.NeedSourceOrBase;
-import org.apache.commons.rdf.api.io.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.Async;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Sync;
 import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.OptionalTarget;
 import org.apache.commons.rdf.api.io.Parsed;
 import org.apache.commons.rdf.api.io.ParserSource;
 import org.apache.commons.rdf.api.io.ParserTarget;
-import org.apache.commons.rdf.api.io.Sync;
 import org.apache.commons.rdf.api.io.Option.RequiredOption;
 
 @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -62,6 +62,7 @@ public final class ParserBuilder implements NeedTargetOrRDF, NeedSourceBased, Sy
 
     @Override
     public NeedSourceBased<Dataset> base(IRI iri) {
+        // FIXME: Only do implicitTarget if target() can't be retrieved
         return newState(implicitTarget().withOption(BaseOption.BASE, iri));
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
index e5df228..a80b5bb 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/ParserFactoryImpl.java
@@ -1,21 +1,34 @@
 package org.apache.commons.rdf.simple.io;
 
+import java.nio.file.Path;
+import java.util.Set;
+
 import org.apache.commons.rdf.api.Dataset;
 import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
 import org.apache.commons.rdf.api.RDF;
 import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.io.NeedSourceOrBase;
-import org.apache.commons.rdf.api.io.NeedTargetOrRDF;
-import org.apache.commons.rdf.api.io.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Sync;
+import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.ParserFactory;
+import org.apache.commons.rdf.api.io.ParserSource;
 import org.apache.commons.rdf.api.io.ParserTarget;
 
 public class ParserFactoryImpl implements ParserFactory {
 
-    private ParserImplementation impl;
+    private final ParserImplementation impl;
+    private final RDF rdf;
+    private final Set<RDFSyntax> syntaxes;
 
-    public ParserFactoryImpl(ParserImplementation impl) {
+    public ParserFactoryImpl(final RDF rdf, final ParserImplementation impl, 
+                                final Set<RDFSyntax> syntaxes) {
+        this.rdf = rdf;
         this.impl = impl;
+        this.syntaxes = syntaxes;
     }
     
     @Override
@@ -31,22 +44,70 @@ public class ParserFactoryImpl implements ParserFactory {
     @SuppressWarnings("unchecked")
     @Override
     public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
-        return new ParserBuilder(mutableState().withTarget(target));
+        return new ParserBuilder(createMutableState().withTarget(target));
+    }
+
+    private ParseJob createMutableState() {
+        return new MutableParseJob().withImplementation(impl).withRDF(rdf);
+    }
+
+    private ParseJob createImmutableMutableState() {
+        return new DefaultParseJob().withImplementation(impl).withRDF(rdf);
+    }
+    
+    @Override
+    public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+        return new ParserBuilder(createMutableState().withSyntax(syntax));
+    }
+
+    @Override
+    public Set<RDFSyntax> supportedSyntaxes() {
+        return syntaxes;
+    }
+
+    @Override
+    public ParserBuilder build() {
+        return new ParserBuilder(createImmutableMutableState());
     }
 
     @SuppressWarnings("unchecked")
     @Override
-    public OptionalTarget<Dataset> rdf(RDF rdf) {
-        return new ParserBuilder(mutableState().withRDF(rdf));
+    public <V> OptionalTarget<Dataset> option(Option<V> o, V v) {
+        return new ParserBuilder(createMutableState()).option(o, v);
     }
 
-    private ParseJob mutableState() {
-        return new MutableParseJob().withImplementation(impl);
+    @Override
+    public NeedSourceBased<Dataset> base(IRI iri) {
+        return new ParserBuilder(createMutableState()).base(iri);
     }
 
     @Override
-    public NeedTargetOrRDF syntax(RDFSyntax syntax) {
-        return new ParserBuilder(mutableState().withSyntax(syntax));
+    public NeedSourceBased<Dataset> base(String iri) {
+        return new ParserBuilder(createMutableState()).base(iri);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Sync<Dataset, IRI> source(IRI iri) {
+        return new ParserBuilder(createMutableState()).source(iri);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Sync<Dataset, Path> source(Path path) {
+        return new ParserBuilder(createMutableState()).source(path);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <S> Sync<Dataset, S> source(ParserSource<S> source) {
+        return new ParserBuilder(createMutableState()).source(source);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Sync<Dataset, IRI> source(String iri) {
+        return new ParserBuilder(createMutableState()).source(iri);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java b/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
index 25fdd0a..384c4bd 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/io/PathSource.java
@@ -21,7 +21,7 @@ public class PathSource implements ParserSource<Path> {
     }
 
     @Override
-    public Path source() {
+    public Path src() {
         return source;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/577614d0/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
index 1377c2f..6b32f70 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/io/ParserFactoryTest.java
@@ -1,30 +1,67 @@
 package org.apache.commons.rdf.simple.io;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
 import java.io.InputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.Future;
 
 import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.RDF;
 import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.io.Async;
-import org.apache.commons.rdf.api.io.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Async;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
+import org.apache.commons.rdf.api.fluentparser.Sync;
+import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Parsed;
 import org.apache.commons.rdf.api.io.ParserFactory;
+import org.apache.commons.rdf.api.io.ParserSource;
+import org.apache.commons.rdf.api.io.ParserTarget;
 import org.apache.commons.rdf.simple.SimpleRDF;
 import org.junit.Test;
 
-public class ParserFactoryTest {
+public class ParserFactoryTest implements ParserImplementation {
     @Test
     public void testName() throws Exception {
-        ParserFactory f = new ParserFactoryImpl((a,b,c,d,e) -> 1);
-        InputStream is = getClass().getResourceAsStream("Fred");
-        OptionalTarget<Dataset> p = f.rdf(new SimpleRDF());
-        Dataset ds = p.source("hello").parse().target().target();
-        
-        
-        Async<Dataset, InputStream> g = f.syntax(RDFSyntax.JSONLD).rdf(new SimpleRDF()).base("http://example.com/").source(is).async();
-        
+        SimpleRDF rdf = new SimpleRDF();
+        Set<RDFSyntax> s = Collections.emptySet();
+        ParserFactory f = new ParserFactoryImpl(rdf, this, s);
+        // 
+        NeedSourceBased<Graph> reusable = f.target(rdf.createGraph()).base("sd").build();
+        // 
+        Sync<Graph, Path> src1 = reusable.source(Paths.get("/tmp/file1.ttl"));
+        Sync<Graph, Path> src2 = reusable.source(Paths.get("/tmp/file2.jsonld"));
+        Parsed<Graph, Path> src1Parsed = src1.parse();
+        Parsed<Graph, Path> src2Parsed = src2.parse();
+        Graph g1 = src1Parsed.into().dest();
+        Graph g2 = src2Parsed.into().dest();
+        assertEquals(g1, g2);
+        Path p1 = src1Parsed.from().src();
+        Path p2 = src2Parsed.from().src();
+        assertNotEquals(p1, p2);
+                
+                
+        Dataset ds = f.source("hello").parse().into().dest();
+        Async<Dataset, InputStream> g;
+        try (InputStream is = getClass().getResourceAsStream("Fred")) {
+            //f.base("fred").source(is).async().parseAsync().get().target();
+            g = f.syntax(RDFSyntax.JSONLD).rdf(new SimpleRDF()).base("http://example.com/").source(is).async();
+        }
         Future<Parsed<Dataset, InputStream>> x = g.parseAsync();
-        Parsed<Dataset, InputStream> p2 = x.get();    
-        System.out.println(p2.count());
+        Parsed<Dataset, InputStream> p3 = x.get();    
+        System.out.println(p3.count());
+    }
+
+    @Override
+    public long parse(ParserSource source, RDFSyntax rdfSyntax, ParserTarget target, RDF rdf,
+            Map<Option, Object> options) {
+        
+        return 0;
     }
 }


[13/17] commons-rdf git commit: ParserConfig interface

Posted by st...@apache.org.
ParserConfig interface


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/fb9a60bc
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/fb9a60bc
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/fb9a60bc

Branch: refs/heads/fluent-parser
Commit: fb9a60bc8e5cea358982fd3833be6e150752314a
Parents: 5241e75
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 15 00:41:36 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 15 00:41:36 2018 +0000

----------------------------------------------------------------------
 .../rdf/api/io/AbstractParserFactory.java       | 354 +++++++++++++++++++
 .../org/apache/commons/rdf/api/io/Parser.java   |  25 ++
 .../apache/commons/rdf/api/io/ParserConfig.java |  34 ++
 .../apache/commons/rdf/simple/SimpleRDF.java    |  14 +
 4 files changed, 427 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fb9a60bc/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
new file mode 100644
index 0000000..2e37b81
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
@@ -0,0 +1,354 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentparser.Async;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDFOrSyntax;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Sync;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public final class AbstractParserFactory implements 
+Cloneable, 
+Serializable, 
+NeedTargetOrRDF, 
+NeedTargetOrRDFOrSyntax, 
+NeedSourceOrBase,
+NeedSourceBased, 
+OptionalTarget, 
+Sync, 
+Async {
+
+	private static final long serialVersionUID = 1L;
+
+	@Override
+	public AbstractParserFactory clone() {
+		try {
+			AbstractParserFactory c = (AbstractParserFactory) super.clone();
+			c.config = (ParserConfigImpl) config.clone();
+			return c;
+		} catch (CloneNotSupportedException e) {
+			throw new IllegalStateException("AbstractParserFactory was not Cloneable", e);
+		}
+	}
+
+	static final class InputParserSource implements ParserSource {
+		private final InputStream is;
+
+		private InputParserSource(InputStream is) {
+			this.is = is;
+		}
+
+		@Override
+		public Object src() {
+			return is;
+		}
+
+		@Override
+		public InputStream inputStream() throws IOException {
+			return is;
+		}
+
+		@Override
+		public Optional iri() {
+			return Optional.empty();
+		}
+	}
+
+	private final class PathParserSource implements ParserSource<Path> {
+		private final Path path;
+
+		private PathParserSource(Path path) {
+			this.path = path;
+		}
+
+		@Override
+		public Path src() {
+			return path;
+		}
+
+		@Override
+		public InputStream inputStream() throws IOException {
+			return Files.newInputStream(path);
+		}
+
+		@Override
+		public Optional<IRI> iri() {
+			final String uri = path.toUri().toString();
+			return Optional.of(new IRIImpl(uri));
+		}
+	}
+
+	private final class IRIParserSource implements ParserSource<IRI> {
+		private final IRI iri;
+
+		private IRIParserSource(IRI iri) {
+			this.iri = iri;
+		}
+
+		@Override
+		public IRI src() {
+			return iri;
+		}
+
+		@Override
+		public InputStream inputStream() throws IOException {
+			return new URL(iri.getIRIString()).openStream();
+		}
+
+		@Override
+		public Optional<IRI> iri() {
+			return Optional.of(iri);
+		}
+	}
+
+	private final class IRIImpl implements IRI {
+		private final String uri;
+
+		private IRIImpl(String uri) {
+			this.uri = uri;
+		}
+
+		@Override
+		public String ntriplesString() {
+			return "<" + uri + ">";
+		}
+
+		@Override
+		public String getIRIString() {
+			return uri;
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			return (obj instanceof IRI) && ((IRI) obj).getIRIString().equals(uri);
+		}
+
+		@Override
+		public int hashCode() {
+			return uri.hashCode();
+		}
+	}
+
+	public static final class ParserConfigImpl implements Cloneable, Serializable, ParserConfig {
+		private static final long serialVersionUID = 1L;
+		private RDF rdf = null;
+		private RDFSyntax syntax = null;
+		private IRI base = null;
+		private ParserSource source = null;
+		private ParserTarget target = null;
+		final private  Map<Option, Object> options = new HashMap<>();
+
+		public ParserConfigImpl() {
+		}
+		
+		public ParserConfigImpl(ParserConfig old) {
+			rdf = old.rdf().orElse(null);
+			syntax = old.syntax().orElse(null);
+			base = old.base().orElse(null);
+			source = old.source().orElse(null);
+			target = old.target().orElse(null);
+			options.putAll(old.options());
+		}
+
+		@Override
+		protected Object clone() {
+			return new ParserConfigImpl(this);
+		}
+
+		@Override
+		public Optional<ParserSource> source() {
+			return Optional.of(source);
+		}
+
+		@Override
+		public Optional<IRI> base() {
+			return Optional.of(base);
+		}
+
+		@Override
+		public Optional<ParserTarget> target() {
+			return Optional.of(target);
+		}
+
+		@Override
+		public Optional<RDFSyntax> syntax() {
+			return Optional.of(syntax);
+		}
+
+		@Override
+		public Optional<RDF> rdf() {
+			return Optional.of(rdf);
+		}
+
+		@Override
+		public Map<Option, Object> options() {
+			return options;
+		}
+		
+		
+	}
+	private boolean mutable = false;
+	private ParserConfigImpl config = new ParserConfigImpl();
+
+	@Override
+	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+		AbstractParserFactory c = mutable();
+		c.config.syntax = syntax;
+		return c;
+	}
+
+	private AbstractParserFactory mutable(boolean mutable) {
+		if (this.mutable == mutable) {
+			return this;
+		} else {
+			AbstractParserFactory c = clone();
+			c.mutable = mutable;
+			return c;
+		}
+	}
+
+	private AbstractParserFactory mutable() {
+		return mutable(true);
+	}
+
+	@Override
+	public AbstractParserFactory build() {
+		return mutable(false);
+	}
+
+	@Override
+	public NeedSourceOrBase target(Dataset dataset) {
+		return target(dataset::add);
+
+	}
+
+	@Override
+	public NeedSourceOrBase<Graph> target(Graph graph) {
+		return target(q -> {
+			if (q.getGraphName().isPresent()) {
+				// Only add if q is in default graph
+				graph.add(q.asTriple());
+			}
+		});
+	}
+
+	@Override
+	public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
+		AbstractParserFactory c = mutable();
+		c.config.target = target;
+		return c;
+	}
+
+	@Override
+	public NeedSourceBased base(IRI iri) {
+		AbstractParserFactory c = mutable();
+		c.config.base = iri;
+		return c;
+	}
+
+	@Override
+	public NeedSourceBased base(String iri) {
+		AbstractParserFactory c = mutable();
+		c.config.base = new IRIImpl(iri);
+		return c;
+	}
+
+	@Override
+	public Sync source(final IRI iri) {
+		return source(new IRIParserSource(iri));
+	}
+
+	public Sync source(Path path) {
+		return source(new PathParserSource(path));
+	}
+
+	@Override
+	public OptionalTarget<Dataset> rdf(RDF rdf) {
+		AbstractParserFactory c = mutable();
+		c.config.rdf = rdf;
+		return c;
+	}
+
+	@Override
+	public Sync source(ParserSource source) {
+		AbstractParserFactory c = mutable();
+		c.config.source = source;
+		return c;		
+	}
+
+	@Override
+	public Sync source(String iri) {
+		return source(new IRIImpl(iri));
+	}
+
+	@Override
+	public AbstractParserFactory option(Option option, Object value) {
+		AbstractParserFactory c = mutable();
+		c.config.options.put(option, value);
+		return c;		
+	}
+
+	@Override
+	public Future parseAsync() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async async() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async async(ExecutorService executor) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Parsed parse() {
+		return null;
+	}
+
+	@Override
+	public Sync source(InputStream is) {
+		return source(new InputParserSource(is));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fb9a60bc/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
new file mode 100644
index 0000000..84ad2be
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
@@ -0,0 +1,25 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.io.AbstractParserFactory.ParserConfig;
+
+public interface Parser {
+
+	Parsed parse(ParserConfig config);
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fb9a60bc/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfig.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfig.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfig.java
new file mode 100644
index 0000000..d18a268
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfig.java
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+
+public interface ParserConfig {
+	Optional<ParserSource> source();
+	Optional<IRI> base();
+	Optional<ParserTarget> target();
+	Optional<RDFSyntax> syntax();
+	Optional<RDF> rdf();
+	Map<Option, Object> options();
+	
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/fb9a60bc/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDF.java b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDF.java
index 6f6b2a5..74d2378 100644
--- a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDF.java
+++ b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDF.java
@@ -17,6 +17,7 @@
  */
 package org.apache.commons.rdf.simple;
 
+import java.util.Optional;
 import java.util.UUID;
 
 import org.apache.commons.rdf.api.BlankNode;
@@ -28,7 +29,10 @@ import org.apache.commons.rdf.api.Literal;
 import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
 import org.apache.commons.rdf.api.Triple;
+import org.apache.commons.rdf.api.io.ParserBuilder;
+import org.apache.commons.rdf.api.io.ParserFactory;
 
 /**
  * Simple RDF implementation.
@@ -109,4 +113,14 @@ public class SimpleRDF implements RDF {
             throws IllegalArgumentException {
         return new QuadImpl(graphName, subject, predicate, object);
     }
+
+	@Override
+	public ParserFactory parserFactory() throws UnsupportedOperationException {
+		throw new UnsupportedOperationException("SimpleRDF does not support parsing");
+	}
+
+	@Override
+	public Optional<ParserBuilder> parser(RDFSyntax syntax) {
+		return Optional.empty();
+	}
 }


[15/17] commons-rdf git commit: Remove ParserFactory -- only ParserBuilder

Posted by st...@apache.org.
Remove ParserFactory -- only ParserBuilder

RDF now can return Parser or ParserBuilder


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/10928eac
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/10928eac
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/10928eac

Branch: refs/heads/fluent-parser
Commit: 10928eac7353266c1c0dc537f7bf7be03536f9f8
Parents: 725e8d0
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 15 01:21:48 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 15 01:24:25 2018 +0000

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/RDF.java    | 58 +++++++++++---------
 .../rdf/api/fluentparser/_Buildable.java        |  3 +-
 .../rdf/api/fluentwriter/_Buildable.java        |  3 +-
 .../rdf/api/io/AbstractParserFactory.java       | 50 ++++++-----------
 .../org/apache/commons/rdf/api/io/Parser.java   |  2 -
 .../commons/rdf/api/io/ParserBuilder.java       |  6 +-
 .../commons/rdf/api/io/ParserConfigImpl.java    | 37 +++++++++++--
 .../commons/rdf/api/io/ParserFactory.java       | 25 ---------
 8 files changed, 85 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
index 633356c..581d615 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
@@ -20,12 +20,13 @@ package org.apache.commons.rdf.api;
 import java.io.Serializable;
 import java.util.Locale;
 import java.util.Optional;
+import java.util.concurrent.Future;
 
 import org.apache.commons.rdf.api.fluentparser.Async;
-import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
 import org.apache.commons.rdf.api.fluentparser.Sync;
+import org.apache.commons.rdf.api.io.Parsed;
+import org.apache.commons.rdf.api.io.Parser;
 import org.apache.commons.rdf.api.io.ParserBuilder;
-import org.apache.commons.rdf.api.io.ParserFactory;
 
 /**
  * A RDF implementation.
@@ -263,24 +264,7 @@ public interface RDF {
             throws IllegalArgumentException;
     
     /**
-     * Get a ParserFactory backed by this RDF instance.
-     * <p>
-     * The returned factory is thread-safe and can be used multiple times,
-     * however the builders it creates are not immutable or reusable, unless
-     * frozen with the {@link _Buildable#build()} method or equivalent.
-     * 
-     * @return {@link ParserFactory} which can be used 
-     * @throws UnsupportedOperationException
-     *             If this RDF implementation does not support parsing RDF
-     */
-    public ParserFactory parserFactory() throws UnsupportedOperationException;
-    
-    /**
-     * Build a configured parser for the given RDF syntax.
-     * <p>
-     * If the RDF syntax is not supported/recognized by this RDF implementation,
-     * return {@link Optional#empty()}, otherwise the returned {@link Optional}
-     * contains an {@link ParserBuilder} fluent instance.
+     * Get a ParserBuilder backed by this RDF instance.
      * <p>
      * The returned {@link ParserBuilder} follows a <em>fluent</em> pattern to be
      * set up before parsing the configured source into the configured target.
@@ -290,7 +274,8 @@ public interface RDF {
      * {@link Async#parseAsync()} on the returned instance. For instance:
      * <pre>{@code
      * 
-     * Parsed<Dataset, IRI> p = rdf.parser(RDFSyntax.JSONLD)
+     * Parsed<Dataset, IRI> p = rdf.parserBuilder()
+     * 							   .syntax(RDFSyntax.JSONLD)
      *                             .source("http://example.com/data.jsonld")
      *                             .parse();
      * Dataset ds = p.target().target();
@@ -304,21 +289,42 @@ public interface RDF {
      * For instance:
      * 
      * <pre>{@code
-     * rdf.parser(RDFSyntax.TURTLE)
-     *    .target(quad ->; System.out.println(quad.getSubject()))  
+     * rdf.parserBuilder()
+     *    .syntax(RDFSyntax.TURTLE)
+     *    .target(quad -> System.out.println(quad.getSubject()))  
      *    .source(Paths.get("/tmp/file.ttl").
      *    .async().parseAsync();
      * }</pre>
+     * The above shows how parsing can be performed asynchronously, returning
+     * immediately a {@link Future} eventually returning a {@link Parsed} status.
      * <p>
      * Note that the returned {@link ParserBuilder} may be mutable and not
      * thread-safe, and should only be used for parsing once. A reusable,
      * immutable builder can be created at any step with
      * {@link _Builder#build()}.
      * 
-     * @param syntax RDF Syntax to build a parser for
-     * @return A {@link ParserBuilder}, or {@link Optional#empty()} if the
+     * @return {@link ParserBuilder} supported by this RDF implementation 
+     * @throws UnsupportedOperationException
+     *             If this RDF implementation does not support parsing RDF
+     */
+    public ParserBuilder parserBuilder() throws UnsupportedOperationException;
+    
+    /**
+     * Return a parser for the given RDF syntax.
+     * <p>
+     * If the syntax is not supported/recognised by this RDF implementation,
+     * return {@link Optional#empty()}, otherwise return an {@link Optional}
+     * containing an {@link Parser} for that syntax.
+     * <p>
+     * If the provided syntax is <code>null</code>, 
+     * return a generic {@link Parser} that can detect the syntax 
+     * (e.g. from Content-Type headers or file extension), or 
+     * {@link Optional#empty()} if this feature is not supported.
+     * 
+     * @param syntax RDF Syntax to parse, or <code>null</code> for any/unknown syntax.
+     * @return A {@link Parser}, or {@link Optional#empty()} if the
      *         syntax is not supported.
      */
-    public Optional<ParserBuilder> parser(RDFSyntax syntax);
+    public Optional<Parser> parser(RDFSyntax syntax);
 
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
index 1675cfa..4f1060a 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
@@ -19,7 +19,6 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Option.RequiredOption;
-import org.apache.commons.rdf.api.io.ParserFactory;
 
 interface _Buildable {
     /**
@@ -33,7 +32,7 @@ interface _Buildable {
     /**
      * Return a builder with the given option set.
      * <p>
-     * Note that implementations of {@link ParserFactory} may support different
+     * Note that implementations of {@link Parser} may support different
      * vendor-specific {@link Option} types, and are free to ignore the set
      * option (unless it is a {@link RequiredOption}).
      * <p>

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
index fc89f60..95c4c7b 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
@@ -19,7 +19,6 @@ package org.apache.commons.rdf.api.fluentwriter;
 
 import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Option.RequiredOption;
-import org.apache.commons.rdf.api.io.ParserFactory;
 
 interface _Buildable {
     /**
@@ -33,7 +32,7 @@ interface _Buildable {
     /**
      * Return a builder with the given option set.
      * <p>
-     * Note that implementations of {@link ParserFactory} may support different
+     * Note that implementations of {@link Writer} may support different
      * vendor-specific {@link Option} types, and are free to ignore the set
      * option (unless it is a {@link RequiredOption}).
      * <p>

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
index 725a569..141b2f1 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
@@ -36,19 +36,15 @@ import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
 import org.apache.commons.rdf.api.fluentparser.Sync;
 
 @SuppressWarnings({ "unchecked", "rawtypes" })
-public final class AbstractParserFactory implements 
-Cloneable, 
-Serializable, 
-NeedTargetOrRDF, 
-NeedTargetOrRDFOrSyntax, 
-NeedSourceOrBase,
-NeedSourceBased, 
-OptionalTarget, 
-Sync, 
-Async {
+public final class AbstractParserFactory implements Cloneable, Serializable, NeedTargetOrRDF, NeedTargetOrRDFOrSyntax,
+		NeedSourceOrBase, NeedSourceBased, OptionalTarget, Sync, Async {
 
 	private static final long serialVersionUID = 1L;
 
+	public AbstractParserFactory(RDF rdf) {
+		
+	}
+	
 	@Override
 	public AbstractParserFactory clone() {
 		try {
@@ -65,21 +61,9 @@ Async {
 
 	@Override
 	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
-		return mutate(config::withSyntax, syntax);
-	}
-
-	@FunctionalInterface
-	private interface WithValue<V> {
-		ParserConfig withValue(V value); 
-	}
-	
-	private AbstractParserFactory mutate(WithValue<V> valueFunc, V value) {
-		if (mutable) {
-			return valueFunc.withValue(value);
-		} else {
-			mutable().mutate(valueFunc, value);
-		}
-		
+		AbstractParserFactory c = mutable();
+		c.config.withSyntax(syntax);
+		return c;
 	}
 
 	private AbstractParserFactory mutable(boolean mutable) {
@@ -120,21 +104,21 @@ Async {
 	@Override
 	public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
 		AbstractParserFactory c = mutable();
-		c.config.target = target;
+		c.config.withTarget(target);
 		return c;
 	}
 
 	@Override
 	public NeedSourceBased base(IRI iri) {
 		AbstractParserFactory c = mutable();
-		c.config.base = iri;
+		c.config.withBase(iri);
 		return c;
 	}
 
 	@Override
 	public NeedSourceBased base(String iri) {
 		AbstractParserFactory c = mutable();
-		c.config.base = new IRIImpl(iri);
+		c.config.withBase(new IRIImpl(iri));
 		return c;
 	}
 
@@ -150,15 +134,15 @@ Async {
 	@Override
 	public OptionalTarget<Dataset> rdf(RDF rdf) {
 		AbstractParserFactory c = mutable();
-		c.config.rdf = rdf;
+		c.config.withRDF(rdf);
 		return c;
 	}
 
 	@Override
 	public Sync source(ParserSource source) {
 		AbstractParserFactory c = mutable();
-		c.config.source = source;
-		return c;		
+		c.config.withSource(source);
+		return c;
 	}
 
 	@Override
@@ -169,8 +153,8 @@ Async {
 	@Override
 	public AbstractParserFactory option(Option option, Object value) {
 		AbstractParserFactory c = mutable();
-		c.config.options.put(option, value);
-		return c;		
+		c.config.withOption(option, value);
+		return c;
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
index 84ad2be..fc0da77 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.rdf.api.io;
 
-import org.apache.commons.rdf.api.io.AbstractParserFactory.ParserConfig;
-
 public interface Parser {
 
 	Parsed parse(ParserConfig config);

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
index 037271c..cd3eae4 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
@@ -1,9 +1,7 @@
 package org.apache.commons.rdf.api.io;
 
 import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.OptionalTargetOrSyntax;
 
-public interface ParserBuilder extends OptionalTarget<Dataset> {
-    ParserBuilder build();
-    <V> ParserBuilder option(Option<V> option, V value);
+public interface ParserBuilder extends OptionalTargetOrSyntax<Dataset> {
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
index a61e50e..e682c4d 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
@@ -30,13 +30,15 @@ public final class ParserConfigImpl implements Cloneable, Serializable, ParserCo
 	private RDF rdf = null;
 	private RDFSyntax syntax = null;
 	private IRI base = null;
+	@SuppressWarnings("rawtypes")
 	private ParserSource source = null;
+	@SuppressWarnings("rawtypes")
 	private ParserTarget target = null;
-	private final  Map<Option, Object> options = new HashMap<>();
+	private final Map<Option, Object> options = new HashMap<>();
 
 	public ParserConfigImpl() {
 	}
-	
+
 	public ParserConfigImpl(ParserConfig old) {
 		rdf = old.rdf().orElse(null);
 		syntax = old.syntax().orElse(null);
@@ -81,10 +83,35 @@ public final class ParserConfigImpl implements Cloneable, Serializable, ParserCo
 		return options;
 	}
 
-	ParserConfig withSyntax(RDFSyntax syntax) {		
+	public ParserConfig withSyntax(RDFSyntax syntax) {
 		this.syntax = syntax;
 		return this;
 	}
-	
-	
+
+	@SuppressWarnings("rawtypes")
+	public ParserConfig withSource(ParserSource source) {
+		this.source = source;
+		return this;
+	}
+
+	public ParserConfig withTarget(ParserTarget target) {
+		this.target = target;
+		return this;
+	}
+
+	public ParserConfig withRDF(RDF rdf) {
+		this.rdf = rdf;
+		return this;
+	}
+
+	public ParserConfig withBase(IRI base) {
+		this.base = base;
+		return this;
+	}
+
+	public <V> ParserConfig withOption(Option<V> o, V v) {
+		this.options.put(o, v);
+		return this;
+	}
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/10928eac/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
deleted file mode 100644
index a1c82fd..0000000
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
-import org.apache.commons.rdf.api.fluentparser.OptionalTargetOrSyntax;
-
-public interface ParserFactory extends  _SupportedSyntaxes<NeedTargetOrRDF>, OptionalTargetOrSyntax<Dataset> {
-}


[11/17] commons-rdf git commit: Use _Buildable instead of explicit build()

Posted by st...@apache.org.
Use _Buildable instead of explicit build()


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/aee8a63c
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/aee8a63c
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/aee8a63c

Branch: refs/heads/fluent-parser
Commit: aee8a63c67fb068631bd281415c7c53b8059f298
Parents: 96fb0f0
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Feb 14 22:29:44 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 22:39:59 2018 +0000

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/RDF.java    | 10 +++---
 .../commons/rdf/api/fluentparser/Async.java     |  6 +---
 .../rdf/api/fluentparser/NeedSourceBased.java   |  6 +---
 .../rdf/api/fluentparser/NeedSourceOrBase.java  |  6 +---
 .../rdf/api/fluentparser/NeedTarget.java        |  6 +---
 .../rdf/api/fluentparser/NeedTargetOrRDF.java   |  6 +---
 .../rdf/api/fluentparser/OptionalTarget.java    |  6 +---
 .../fluentparser/OptionalTargetOrSyntax.java    | 21 ++++++++++--
 .../commons/rdf/api/fluentparser/Sync.java      |  6 +---
 .../rdf/api/fluentparser/_Buildable.java        |  6 ++--
 .../api/fluentparser/_NeedIdentifiedSource.java |  2 --
 .../rdf/api/fluentparser/_NeedSourceOrBase.java | 21 ++++++++++++
 .../rdf/api/fluentparser/_NeedSyntax.java       | 17 ++++++++++
 .../rdf/api/fluentparser/_OptionalTarget.java   | 21 ++++++++++++
 .../org/apache/commons/rdf/api/io/Option.java   |  2 +-
 .../commons/rdf/api/io/ParserFactory.java       |  4 +--
 .../commons/rdf/api/io/WriterFactory.java       |  4 +--
 .../commons/rdf/api/io/_SupportedSyntaxes.java  |  4 +--
 .../rdf/api/fluentparser/package-info.java      | 20 ++++++++++++
 .../commons/rdf/api/fluentparser/test/Test.java | 34 ++++++++++++++++++++
 20 files changed, 151 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
index aaa91e9..633356c 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
@@ -267,16 +267,16 @@ public interface RDF {
      * <p>
      * The returned factory is thread-safe and can be used multiple times,
      * however the builders it creates are not immutable or reusable, unless
-     * frozen with the {@link OptionalTarget#build()} method or equivalent.
+     * frozen with the {@link _Buildable#build()} method or equivalent.
      * 
-     * @return ParserFactory
+     * @return {@link ParserFactory} which can be used 
      * @throws UnsupportedOperationException
      *             If this RDF implementation does not support parsing RDF
      */
     public ParserFactory parserFactory() throws UnsupportedOperationException;
     
     /**
-     * Build a parser for the given RDF syntax.
+     * Build a configured parser for the given RDF syntax.
      * <p>
      * If the RDF syntax is not supported/recognized by this RDF implementation,
      * return {@link Optional#empty()}, otherwise the returned {@link Optional}
@@ -287,7 +287,7 @@ public interface RDF {
      * As a minimum, one of the
      * {@link ParserBuilder#source(org.apache.commons.rdf.api.io.ParserSource)}
      * methods need to be called before calling {@link Sync#parse()} or
-     * {@link Async#parseAsync()}. For instance:
+     * {@link Async#parseAsync()} on the returned instance. For instance:
      * <pre>{@code
      * 
      * Parsed<Dataset, IRI> p = rdf.parser(RDFSyntax.JSONLD)
@@ -313,7 +313,7 @@ public interface RDF {
      * Note that the returned {@link ParserBuilder} may be mutable and not
      * thread-safe, and should only be used for parsing once. A reusable,
      * immutable builder can be created at any step with
-     * {@link ParserBuilder#build()}.
+     * {@link _Builder#build()}.
      * 
      * @param syntax RDF Syntax to build a parser for
      * @return A {@link ParserBuilder}, or {@link Optional#empty()} if the

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
index ba3fb2d..84fdacd 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
@@ -19,13 +19,9 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.util.concurrent.Future;
 
-import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Parsed;
 
-public interface Async<T, S> extends _Buildable {
-    Async<T, S> build();
-    
-    <V> Async<T, S> option(Option<V> option, V value);
+public interface Async<T, S> extends _Buildable<Async<T,S>> {
 
     Future<Parsed<T, S>> parseAsync();
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
index 54889e1..8086264 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
@@ -19,11 +19,7 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.io.InputStream;
 
-import org.apache.commons.rdf.api.io.Option;
-
-public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
-    NeedSourceBased<T> build();
-    <V> NeedSourceBased<T> option(Option<V> option, V value);
+public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable<NeedSourceBased<T>> {
 
     Sync<T, InputStream> source(InputStream is);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
index 91b83b7..66161bc 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
@@ -17,9 +17,5 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-import org.apache.commons.rdf.api.io.Option;
-
-public interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T>, _Buildable {
-    NeedSourceOrBase<T> build();
-    <V> NeedSourceOrBase<T> option(Option<V> option, V value);
+public interface NeedSourceOrBase<T> extends _NeedSourceOrBase<T>, _Buildable<NeedSourceOrBase<T>> {
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
index 4ed3849..55e196e 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
@@ -17,9 +17,5 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-import org.apache.commons.rdf.api.io.Option;
-
-interface NeedTarget extends _NeedTarget,_Buildable {
-    NeedTarget build();
-    <V> NeedTarget option(Option<V> option, V value);
+interface NeedTarget extends _NeedTarget,_Buildable<NeedTarget> {
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
index 109b70d..6949f15 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
@@ -17,9 +17,5 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-import org.apache.commons.rdf.api.io.Option;
-
-public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
-    NeedTargetOrRDF build();
-    <V> NeedTargetOrRDF option(Option<V> option, V value);
+public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable<NeedTargetOrRDF> {
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
index be8195c..b8d5d03 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
@@ -17,9 +17,5 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-import org.apache.commons.rdf.api.io.Option;
-
-public interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T>,_Buildable {
-    OptionalTarget<T> build();
-    <V> OptionalTarget<T> option(Option<V> option, V value);
+public interface OptionalTarget<T> extends _OptionalTarget<T>,_Buildable<OptionalTarget<T>> {
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
index 7dee7e4..e4768f8 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
@@ -1,5 +1,20 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
-
-public interface OptionalTargetOrSyntax<T> extends OptionalTarget<T>, _NeedSyntax {
-    
+public interface OptionalTargetOrSyntax<T> extends _OptionalTarget<T>, _NeedSyntax {   
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
index c141a18..98de4d8 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
@@ -19,13 +19,9 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.util.concurrent.ExecutorService;
 
-import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Parsed;
 
-public interface Sync<T, S> extends _Buildable{
-    Sync<T ,S> build();
-    <V> Sync<T, S> option(Option<V> option, V value);
-
+public interface Sync<T, S> extends _Buildable<Sync<T, S>>{
     Async<T, S> async();
     Async<T, S> async(ExecutorService executor);
     Parsed<T, S> parse();

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
index b21eb9d..5183035 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
@@ -21,14 +21,14 @@ import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Option.RequiredOption;
 import org.apache.commons.rdf.api.io.ParserFactory;
 
-interface _Buildable {
+interface _Buildable<Self extends _Buildable<Self>> {
     /**
      * Return an immutable builder at the current state. The returned builder
      * can be re-used multiple times in a thread-safe way.
      * 
      * @return An immutable builder
      */
-    _Buildable build();
+	Self build();
     
     /**
      * Return a builder with the given option set.
@@ -45,6 +45,6 @@ interface _Buildable {
      * @param value Value to set for option
      * @return A builder with the given option set
      */
-    <V> _Buildable option(Option<V> option, V value);
+    <V> Self option(Option<V> option, V value);
 
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
index 580adf6..cb0a1a8 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
@@ -19,8 +19,6 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.nio.file.Path;
 
-import javax.xml.transform.Source;
-
 import org.apache.commons.rdf.api.IRI;
 import org.apache.commons.rdf.api.io.ParserSource;
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSourceOrBase.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSourceOrBase.java
new file mode 100644
index 0000000..a95b4b2
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSourceOrBase.java
@@ -0,0 +1,21 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+interface _NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T> {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
index 28f0cd1..6ab0142 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
@@ -1,3 +1,20 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
 
 import org.apache.commons.rdf.api.RDFSyntax;

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalTarget.java
new file mode 100644
index 0000000..3a2143e
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalTarget.java
@@ -0,0 +1,21 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+interface _OptionalTarget<T> extends _NeedTarget, _NeedSourceOrBase<T> {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
index 7cf5c86..43182a0 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
@@ -18,7 +18,7 @@
 package org.apache.commons.rdf.api.io;
 
 public interface Option<V> {
-
+	
     public interface RequiredOption<V> extends Option<V> {
 
     }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
index b25a536..a1c82fd 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
@@ -18,10 +18,8 @@
 package org.apache.commons.rdf.api.io;
 
 import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.RDFSyntax;
 import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
 import org.apache.commons.rdf.api.fluentparser.OptionalTargetOrSyntax;
 
-public interface ParserFactory extends  _SupportedSyntaxes, OptionalTargetOrSyntax<Dataset> {
-    NeedTargetOrRDF syntax(RDFSyntax syntax);
+public interface ParserFactory extends  _SupportedSyntaxes<NeedTargetOrRDF>, OptionalTargetOrSyntax<Dataset> {
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
index 59815f0..ce6c762 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
@@ -17,9 +17,7 @@
  */
 package org.apache.commons.rdf.api.io;
 
-import org.apache.commons.rdf.api.RDFSyntax;
 import org.apache.commons.rdf.api.fluentwriter.NeedTarget;
 
-public interface WriterFactory extends _SupportedSyntaxes {
-    NeedTarget syntax(RDFSyntax syntax);
+public interface WriterFactory extends _SupportedSyntaxes<NeedTarget> {
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
index aa3e115..14e64bc 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
@@ -4,7 +4,7 @@ import java.util.Set;
 
 import org.apache.commons.rdf.api.RDFSyntax;
 
-interface _SupportedSyntaxes {
+interface _SupportedSyntaxes<T> {
     /**
      * Get set of syntaxes supported by this factory.
      * <p>
@@ -24,5 +24,5 @@ interface _SupportedSyntaxes {
      * @param syntax RDFSyntax
      * @return Builder that uses specified syntax
      */
-    Object syntax(RDFSyntax syntax);
+    T syntax(RDFSyntax syntax);
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/package-info.java b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/package-info.java
new file mode 100644
index 0000000..ef84a13
--- /dev/null
+++ b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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 org.apache.commons.rdf.api.fluentparser;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/aee8a63c/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/test/Test.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/test/Test.java b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/test/Test.java
new file mode 100644
index 0000000..3f6fc7d
--- /dev/null
+++ b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/fluentparser/test/Test.java
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.commons.rdf.api.fluentparser.test;
+
+import static org.junit.Assert.*;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+
+public class Test {
+
+	@org.junit.Test
+	public void testName() throws Exception {
+		RDF rdf = null;
+		
+		rdf.parserFactory();
+	}
+}


[09/17] commons-rdf git commit: fluent API moved into commons-rdf-api/

Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
new file mode 100644
index 0000000..2148b54
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
@@ -0,0 +1,34 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentwriter;
+
+import java.io.OutputStream;
+import java.nio.file.Path;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.WriterTarget;
+
+public interface NeedTarget extends _Buildable {
+    @Override
+    NeedTarget build();
+    <V> NeedTarget option(Option<V> option, V value);
+    
+    NeedSource target(Path p);
+    NeedSource target(OutputStream out);
+    NeedSource target(WriterTarget target);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
new file mode 100644
index 0000000..f6d8afc
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
@@ -0,0 +1,16 @@
+package org.apache.commons.rdf.api.fluentwriter;
+
+import java.util.concurrent.ExecutorService;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Written;
+
+public interface Sync extends _Buildable {
+    
+    Sync build();    
+    <V> Sync option(Option<V> option, V value);
+
+    Written write(); // terminal
+    Async async();
+    Async async(ExecutorService service);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
new file mode 100644
index 0000000..fc89f60
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
@@ -0,0 +1,50 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentwriter;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Option.RequiredOption;
+import org.apache.commons.rdf.api.io.ParserFactory;
+
+interface _Buildable {
+    /**
+     * Return an immutable builder at the current state. The returned builder
+     * can be re-used multiple times in a thread-safe way.
+     * 
+     * @return An immutable builder
+     */
+    _Buildable build();
+    
+    /**
+     * Return a builder with the given option set.
+     * <p>
+     * Note that implementations of {@link ParserFactory} may support different
+     * vendor-specific {@link Option} types, and are free to ignore the set
+     * option (unless it is a {@link RequiredOption}).
+     * <p>
+     * It is undefined if setting multiple values for the same (equal) option
+     * are accumulative or overriding.
+     * 
+     * @param <V> The type of the {@link Option} value 
+     * @param option Option to set
+     * @param value Value to set for option
+     * @return A builder with the given option set
+     */
+    <V> _Buildable option(Option<V> option, V value);
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
new file mode 100644
index 0000000..85f4c8a
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.api.fluentwriter;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
new file mode 100644
index 0000000..7cf5c86
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Option.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface Option<V> {
+
+    public interface RequiredOption<V> extends Option<V> {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
new file mode 100644
index 0000000..b252e44
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
@@ -0,0 +1,26 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+public interface Parsed<T, S> {
+    long count();
+
+    ParserSource<S> from();
+
+    ParserTarget<T> into();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
new file mode 100644
index 0000000..037271c
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
@@ -0,0 +1,9 @@
+package org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+
+public interface ParserBuilder extends OptionalTarget<Dataset> {
+    ParserBuilder build();
+    <V> ParserBuilder option(Option<V> option, V value);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
new file mode 100644
index 0000000..b25a536
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
@@ -0,0 +1,27 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.OptionalTargetOrSyntax;
+
+public interface ParserFactory extends  _SupportedSyntaxes, OptionalTargetOrSyntax<Dataset> {
+    NeedTargetOrRDF syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
new file mode 100644
index 0000000..259688e
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
@@ -0,0 +1,33 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+
+/**
+ *
+ */
+public interface ParserSource<S> {
+    S src();   
+    InputStream inputStream() throws IOException;
+    Optional<IRI> iri();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
new file mode 100644
index 0000000..8898643
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
@@ -0,0 +1,32 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.Quad;
+
+/**
+ *
+ */
+@FunctionalInterface
+public interface ParserTarget<T> extends Consumer<Quad> {
+    default T dest() {
+        return null;// unknown
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
new file mode 100644
index 0000000..59815f0
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentwriter.NeedTarget;
+
+public interface WriterFactory extends _SupportedSyntaxes {
+    NeedTarget syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
new file mode 100644
index 0000000..2ce9bbf
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
@@ -0,0 +1,9 @@
+package org.apache.commons.rdf.api.io;
+
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.TripleLike;
+
+public interface WriterSource {
+    Stream<? extends TripleLike> stream();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
new file mode 100644
index 0000000..f58f3d4
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
@@ -0,0 +1,8 @@
+package org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface WriterTarget {
+    OutputStream outputStream() throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Written.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Written.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Written.java
new file mode 100644
index 0000000..38b5360
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Written.java
@@ -0,0 +1,9 @@
+package org.apache.commons.rdf.api.io;
+
+public interface Written<S,T> {
+
+    WriterSource source();
+
+    WriterTarget target();
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
new file mode 100644
index 0000000..aa3e115
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
@@ -0,0 +1,28 @@
+package org.apache.commons.rdf.api.io;
+
+import java.util.Set;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+
+interface _SupportedSyntaxes {
+    /**
+     * Get set of syntaxes supported by this factory.
+     * <p>
+     * The returned syntaxes can be used with {@link #syntax(RDFSyntax)} and may
+     * be used by this factory if no syntax is given.
+     * <p>
+     * Note that the factory may support additional syntaxes not returned
+     * in this set.
+     * 
+     * @return Set of supported syntaxes
+     */
+    Set<RDFSyntax> supportedSyntaxes();
+    
+    /**
+     * Use the specified RDF syntax
+     * 
+     * @param syntax RDFSyntax
+     * @return Builder that uses specified syntax
+     */
+    Object syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/package-info.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
new file mode 100644
index 0000000..859d954
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
\ No newline at end of file


[12/17] commons-rdf git commit: _Buildable can't use generics

Posted by st...@apache.org.
_Buildable can't use generics


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/5241e75f
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/5241e75f
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/5241e75f

Branch: refs/heads/fluent-parser
Commit: 5241e75fe51a3dd49a3981dfde92b9c681aabc00
Parents: aee8a63
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 15 00:16:07 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 15 00:16:07 2018 +0000

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/fluentparser/Async.java  | 6 +++++-
 .../apache/commons/rdf/api/fluentparser/NeedSourceBased.java | 6 +++++-
 .../commons/rdf/api/fluentparser/NeedSourceOrBase.java       | 6 +++++-
 .../org/apache/commons/rdf/api/fluentparser/NeedTarget.java  | 7 ++++++-
 .../apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java | 7 ++++++-
 .../apache/commons/rdf/api/fluentparser/OptionalTarget.java  | 7 ++++++-
 .../java/org/apache/commons/rdf/api/fluentparser/Sync.java   | 8 +++++++-
 .../org/apache/commons/rdf/api/fluentparser/_Buildable.java  | 6 +++---
 8 files changed, 43 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
index 84fdacd..0101f6c 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
@@ -19,9 +19,13 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.util.concurrent.Future;
 
+import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Parsed;
 
-public interface Async<T, S> extends _Buildable<Async<T,S>> {
+public interface Async<T, S> extends _Buildable {
 
+	Async<T, S> build();	
+	<V> Async<T,S> option(Option<V> option, V value);
+	
     Future<Parsed<T, S>> parseAsync();
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
index 8086264..7b9f2f7 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
@@ -19,7 +19,11 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.io.InputStream;
 
-public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable<NeedSourceBased<T>> {
+import org.apache.commons.rdf.api.io.Option;
 
+public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
+	
+	NeedSourceBased<T> build();	
+	<V> NeedSourceBased<T> option(Option<V> option, V value);
     Sync<T, InputStream> source(InputStream is);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
index 66161bc..4da540a 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
@@ -17,5 +17,9 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-public interface NeedSourceOrBase<T> extends _NeedSourceOrBase<T>, _Buildable<NeedSourceOrBase<T>> {
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedSourceOrBase<T> extends _NeedSourceOrBase<T> {
+	NeedSourceOrBase<T> build();	
+	<V> NeedSourceOrBase<T> option(Option<V> option, V value);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
index 55e196e..a2285a0 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
@@ -17,5 +17,10 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-interface NeedTarget extends _NeedTarget,_Buildable<NeedTarget> {
+import org.apache.commons.rdf.api.io.Option;
+
+interface NeedTarget extends _NeedTarget,_Buildable {
+	NeedTarget build();	
+	<V> NeedTarget option(Option<V> option, V value);
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
index 6949f15..674e540 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
@@ -17,5 +17,10 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable<NeedTargetOrRDF> {
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
+	NeedTargetOrRDF build();	
+	<V> NeedTargetOrRDF option(Option<V> option, V value);
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
index b8d5d03..5693b57 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
@@ -17,5 +17,10 @@
  */
 package org.apache.commons.rdf.api.fluentparser;
 
-public interface OptionalTarget<T> extends _OptionalTarget<T>,_Buildable<OptionalTarget<T>> {
+import org.apache.commons.rdf.api.io.Option;
+
+public interface OptionalTarget<T> extends _OptionalTarget<T>,_Buildable {
+	OptionalTarget<T> build();	
+	<V> OptionalTarget<T> option(Option<V> option, V value);
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
index 98de4d8..14f321d 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
@@ -19,9 +19,15 @@ package org.apache.commons.rdf.api.fluentparser;
 
 import java.util.concurrent.ExecutorService;
 
+import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Parsed;
 
-public interface Sync<T, S> extends _Buildable<Sync<T, S>>{
+public interface Sync<T, S> extends _Buildable {
+	
+	Sync<T, S> build();	
+	<V> Sync<T, S> option(Option<V> option, V value);
+
+	
     Async<T, S> async();
     Async<T, S> async(ExecutorService executor);
     Parsed<T, S> parse();

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/5241e75f/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
index 5183035..1675cfa 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
@@ -21,14 +21,14 @@ import org.apache.commons.rdf.api.io.Option;
 import org.apache.commons.rdf.api.io.Option.RequiredOption;
 import org.apache.commons.rdf.api.io.ParserFactory;
 
-interface _Buildable<Self extends _Buildable<Self>> {
+interface _Buildable {
     /**
      * Return an immutable builder at the current state. The returned builder
      * can be re-used multiple times in a thread-safe way.
      * 
      * @return An immutable builder
      */
-	Self build();
+	_Buildable build();
     
     /**
      * Return a builder with the given option set.
@@ -45,6 +45,6 @@ interface _Buildable<Self extends _Buildable<Self>> {
      * @param value Value to set for option
      * @return A builder with the given option set
      */
-    <V> Self option(Option<V> option, V value);
+    <V> _Buildable option(Option<V> option, V value);
 
 }


[08/17] commons-rdf git commit: new packages fluentparser/fluentwriter

Posted by st...@apache.org.
new packages fluentparser/fluentwriter

draft of fluent writer API


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/921965d4
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/921965d4
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/921965d4

Branch: refs/heads/fluent-parser
Commit: 921965d431e6c7b192655df3f76680d4607235ec
Parents: a11db68
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Tue Feb 28 18:35:54 2017 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 19:00:43 2018 +0000

----------------------------------------------------------------------
 .../commons/rdf/api/fluentparser/Async.java     | 31 +++++++++
 .../rdf/api/fluentparser/NeedSourceBased.java   | 29 +++++++++
 .../rdf/api/fluentparser/NeedSourceOrBase.java  | 25 ++++++++
 .../rdf/api/fluentparser/NeedTarget.java        | 25 ++++++++
 .../rdf/api/fluentparser/NeedTargetOrRDF.java   | 25 ++++++++
 .../fluentparser/NeedTargetOrRDFOrSyntax.java   | 22 +++++++
 .../rdf/api/fluentparser/OptionalTarget.java    | 25 ++++++++
 .../fluentparser/OptionalTargetOrSyntax.java    |  5 ++
 .../commons/rdf/api/fluentparser/Sync.java      | 32 ++++++++++
 .../rdf/api/fluentparser/_Buildable.java        | 50 +++++++++++++++
 .../api/fluentparser/_NeedIdentifiedSource.java | 35 +++++++++++
 .../rdf/api/fluentparser/_NeedSyntax.java       |  7 +++
 .../rdf/api/fluentparser/_NeedTarget.java       | 30 +++++++++
 .../rdf/api/fluentparser/_NeedTargetOrRDF.java  | 21 +++++++
 .../rdf/api/fluentparser/_OptionalBase.java     | 26 ++++++++
 .../rdf/api/fluentparser/_OptionalRDF.java      | 25 ++++++++
 .../rdf/api/fluentparser/package-info.java      | 21 +++++++
 .../commons/rdf/api/fluentwriter/Async.java     | 14 +++++
 .../rdf/api/fluentwriter/NeedSource.java        | 20 ++++++
 .../rdf/api/fluentwriter/NeedTarget.java        | 34 ++++++++++
 .../commons/rdf/api/fluentwriter/Sync.java      | 16 +++++
 .../rdf/api/fluentwriter/_Buildable.java        | 50 +++++++++++++++
 .../rdf/api/fluentwriter/package-info.java      | 21 +++++++
 .../org/apache/commons/rdf/api/io/Async.java    | 28 ---------
 .../commons/rdf/api/io/NeedSourceBased.java     | 27 --------
 .../commons/rdf/api/io/NeedSourceOrBase.java    | 23 -------
 .../apache/commons/rdf/api/io/NeedTarget.java   | 23 -------
 .../commons/rdf/api/io/NeedTargetOrRDF.java     | 23 -------
 .../commons/rdf/api/io/OptionalTarget.java      | 23 -------
 .../commons/rdf/api/io/ParserBuilder.java       |  9 +++
 .../commons/rdf/api/io/ParserFactory.java       |  6 +-
 .../org/apache/commons/rdf/api/io/Sync.java     | 29 ---------
 .../commons/rdf/api/io/WriterFactory.java       | 25 ++++++++
 .../apache/commons/rdf/api/io/WriterSource.java |  9 +++
 .../apache/commons/rdf/api/io/WriterTarget.java |  8 +++
 .../org/apache/commons/rdf/api/io/Written.java  |  9 +++
 .../apache/commons/rdf/api/io/_Buildable.java   | 47 --------------
 .../rdf/api/io/_NeedIdentifiedSource.java       | 34 ----------
 .../apache/commons/rdf/api/io/_NeedTarget.java  | 29 ---------
 .../commons/rdf/api/io/_NeedTargetOrRDF.java    | 21 -------
 .../commons/rdf/api/io/_OptionalBase.java       | 26 --------
 .../apache/commons/rdf/api/io/_OptionalRDF.java | 25 --------
 .../commons/rdf/api/io/_SupportedSyntaxes.java  | 28 +++++++++
 .../apache/commons/rdf/api/io/package-info.java |  2 +-
 .../java/org/apache/commons/rdf/api/RDF.java    | 66 ++++++++++++++++++++
 .../org/apache/commons/rdf/api/RDFSyntax.java   | 62 ++++++++++--------
 46 files changed, 784 insertions(+), 387 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
new file mode 100644
index 0000000..ba3fb2d
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
@@ -0,0 +1,31 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Parsed;
+
+public interface Async<T, S> extends _Buildable {
+    Async<T, S> build();
+    
+    <V> Async<T, S> option(Option<V> option, V value);
+
+    Future<Parsed<T, S>> parseAsync();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
new file mode 100644
index 0000000..54889e1
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
@@ -0,0 +1,29 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.io.InputStream;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
+    NeedSourceBased<T> build();
+    <V> NeedSourceBased<T> option(Option<V> option, V value);
+
+    Sync<T, InputStream> source(InputStream is);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
new file mode 100644
index 0000000..91b83b7
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T>, _Buildable {
+    NeedSourceOrBase<T> build();
+    <V> NeedSourceOrBase<T> option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
new file mode 100644
index 0000000..4ed3849
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+interface NeedTarget extends _NeedTarget,_Buildable {
+    NeedTarget build();
+    <V> NeedTarget option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
new file mode 100644
index 0000000..109b70d
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
+    NeedTargetOrRDF build();
+    <V> NeedTargetOrRDF option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
new file mode 100644
index 0000000..61a0256
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
@@ -0,0 +1,22 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+public interface NeedTargetOrRDFOrSyntax extends _NeedTargetOrRDF, _NeedSyntax {
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
new file mode 100644
index 0000000..be8195c
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T>,_Buildable {
+    OptionalTarget<T> build();
+    <V> OptionalTarget<T> option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
new file mode 100644
index 0000000..7dee7e4
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
@@ -0,0 +1,5 @@
+package org.apache.commons.rdf.api.fluentparser;
+
+public interface OptionalTargetOrSyntax<T> extends OptionalTarget<T>, _NeedSyntax {
+    
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
new file mode 100644
index 0000000..c141a18
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
@@ -0,0 +1,32 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.util.concurrent.ExecutorService;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Parsed;
+
+public interface Sync<T, S> extends _Buildable{
+    Sync<T ,S> build();
+    <V> Sync<T, S> option(Option<V> option, V value);
+
+    Async<T, S> async();
+    Async<T, S> async(ExecutorService executor);
+    Parsed<T, S> parse();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
new file mode 100644
index 0000000..b21eb9d
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
@@ -0,0 +1,50 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Option.RequiredOption;
+import org.apache.commons.rdf.api.io.ParserFactory;
+
+interface _Buildable {
+    /**
+     * Return an immutable builder at the current state. The returned builder
+     * can be re-used multiple times in a thread-safe way.
+     * 
+     * @return An immutable builder
+     */
+    _Buildable build();
+    
+    /**
+     * Return a builder with the given option set.
+     * <p>
+     * Note that implementations of {@link ParserFactory} may support different
+     * vendor-specific {@link Option} types, and are free to ignore the set
+     * option (unless it is a {@link RequiredOption}).
+     * <p>
+     * It is undefined if setting multiple values for the same (equal) option
+     * are accumulative or overriding.
+     * 
+     * @param <V> The type of the {@link Option} value 
+     * @param option Option to set
+     * @param value Value to set for option
+     * @return A builder with the given option set
+     */
+    <V> _Buildable option(Option<V> option, V value);
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
new file mode 100644
index 0000000..580adf6
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
@@ -0,0 +1,35 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.nio.file.Path;
+
+import javax.xml.transform.Source;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.io.ParserSource;
+
+interface _NeedIdentifiedSource<T> {
+    Sync<T, IRI> source(IRI iri);
+
+    Sync<T, Path> source(Path path);
+
+    <S> Sync<T, S> source(ParserSource<S> source);
+
+    Sync<T, IRI> source(String iri);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
new file mode 100644
index 0000000..28f0cd1
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
@@ -0,0 +1,7 @@
+package org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+
+interface _NeedSyntax {
+    NeedTargetOrRDF syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
new file mode 100644
index 0000000..2053f3b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+interface _NeedTarget {
+    NeedSourceOrBase<Dataset> target(Dataset dataset);
+
+    NeedSourceOrBase<Graph> target(Graph graph);
+
+    <T> NeedSourceOrBase<T> target(ParserTarget<T> target);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
new file mode 100644
index 0000000..89016b4
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
@@ -0,0 +1,21 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
new file mode 100644
index 0000000..3e3235c
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
@@ -0,0 +1,26 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.IRI;
+
+interface _OptionalBase<T> {
+    NeedSourceBased<T> base(IRI iri);
+
+    NeedSourceBased<T> base(String iri);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
new file mode 100644
index 0000000..80ac15b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.RDF;
+
+interface _OptionalRDF {
+    OptionalTarget<Dataset> rdf(RDF rdf);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
new file mode 100644
index 0000000..42c4921
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.api.fluentparser;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
new file mode 100644
index 0000000..e7edcf4
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
@@ -0,0 +1,14 @@
+package org.apache.commons.rdf.api.fluentwriter;
+
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Written;
+
+public interface Async extends _Buildable {
+    
+    Async build();    
+    <V> Async option(Option<V> option, V value);
+    
+    Future<Written> writeAsync();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
new file mode 100644
index 0000000..3070427
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
@@ -0,0 +1,20 @@
+package org.apache.commons.rdf.api.fluentwriter;
+
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.TripleLike;
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.WriterSource;
+
+public interface NeedSource extends _Buildable {
+    
+    NeedSource build();    
+    <V> NeedSource option(Option<V> option, V value);
+    
+    Sync source(Dataset dataset);
+    Sync source(Graph graph);
+    Sync source(Stream<? extends TripleLike> stream);
+    Sync source(WriterSource source);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
new file mode 100644
index 0000000..2148b54
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
@@ -0,0 +1,34 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentwriter;
+
+import java.io.OutputStream;
+import java.nio.file.Path;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.WriterTarget;
+
+public interface NeedTarget extends _Buildable {
+    @Override
+    NeedTarget build();
+    <V> NeedTarget option(Option<V> option, V value);
+    
+    NeedSource target(Path p);
+    NeedSource target(OutputStream out);
+    NeedSource target(WriterTarget target);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
new file mode 100644
index 0000000..f6d8afc
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
@@ -0,0 +1,16 @@
+package org.apache.commons.rdf.api.fluentwriter;
+
+import java.util.concurrent.ExecutorService;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Written;
+
+public interface Sync extends _Buildable {
+    
+    Sync build();    
+    <V> Sync option(Option<V> option, V value);
+
+    Written write(); // terminal
+    Async async();
+    Async async(ExecutorService service);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
new file mode 100644
index 0000000..fc89f60
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
@@ -0,0 +1,50 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentwriter;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Option.RequiredOption;
+import org.apache.commons.rdf.api.io.ParserFactory;
+
+interface _Buildable {
+    /**
+     * Return an immutable builder at the current state. The returned builder
+     * can be re-used multiple times in a thread-safe way.
+     * 
+     * @return An immutable builder
+     */
+    _Buildable build();
+    
+    /**
+     * Return a builder with the given option set.
+     * <p>
+     * Note that implementations of {@link ParserFactory} may support different
+     * vendor-specific {@link Option} types, and are free to ignore the set
+     * option (unless it is a {@link RequiredOption}).
+     * <p>
+     * It is undefined if setting multiple values for the same (equal) option
+     * are accumulative or overriding.
+     * 
+     * @param <V> The type of the {@link Option} value 
+     * @param option Option to set
+     * @param value Value to set for option
+     * @return A builder with the given option set
+     */
+    <V> _Buildable option(Option<V> option, V value);
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
new file mode 100644
index 0000000..85f4c8a
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.api.fluentwriter;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/Async.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Async.java b/api/src/main/java/org/apache/commons/rdf/api/io/Async.java
deleted file mode 100644
index 2c99a0b..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/Async.java
+++ /dev/null
@@ -1,28 +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 org.apache.commons.rdf.api.io;
-
-import java.util.concurrent.Future;
-
-public interface Async<T, S> extends _Buildable {
-    Async<T, S> build();
-    
-    <V> Async<T, S> option(Option<V> option, V value);
-
-    Future<Parsed<T, S>> parseAsync();
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java
deleted file mode 100644
index d390529..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceBased.java
+++ /dev/null
@@ -1,27 +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 org.apache.commons.rdf.api.io;
-
-import java.io.InputStream;
-
-public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
-    NeedSourceBased<T> build();
-    <V> NeedSourceBased<T> option(Option<V> option, V value);
-
-    Sync<T, InputStream> source(InputStream is);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java
deleted file mode 100644
index 4211137..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/NeedSourceOrBase.java
+++ /dev/null
@@ -1,23 +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 org.apache.commons.rdf.api.io;
-
-public interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T>, _Buildable {
-    NeedSourceOrBase<T> build();
-    <V> NeedSourceOrBase<T> option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java
deleted file mode 100644
index 4816382..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/NeedTarget.java
+++ /dev/null
@@ -1,23 +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 org.apache.commons.rdf.api.io;
-
-interface NeedTarget extends _NeedTarget,_Buildable {
-    NeedTarget build();
-    <V> NeedTarget option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java
deleted file mode 100644
index 1ed3b0a..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/NeedTargetOrRDF.java
+++ /dev/null
@@ -1,23 +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 org.apache.commons.rdf.api.io;
-
-public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
-    NeedTargetOrRDF build();
-    <V> NeedTargetOrRDF option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java
deleted file mode 100644
index f9bf651..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/OptionalTarget.java
+++ /dev/null
@@ -1,23 +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 org.apache.commons.rdf.api.io;
-
-public interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T>,_Buildable {
-    OptionalTarget<T> build();
-    <V> OptionalTarget<T> option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
new file mode 100644
index 0000000..037271c
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
@@ -0,0 +1,9 @@
+package org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+
+public interface ParserBuilder extends OptionalTarget<Dataset> {
+    ParserBuilder build();
+    <V> ParserBuilder option(Option<V> option, V value);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
index 6026b00..b25a536 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
@@ -17,9 +17,11 @@
  */
 package org.apache.commons.rdf.api.io;
 
+import org.apache.commons.rdf.api.Dataset;
 import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.OptionalTargetOrSyntax;
 
-public interface ParserFactory extends _NeedTargetOrRDF {
-
+public interface ParserFactory extends  _SupportedSyntaxes, OptionalTargetOrSyntax<Dataset> {
     NeedTargetOrRDF syntax(RDFSyntax syntax);
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java b/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java
deleted file mode 100644
index 7d8add7..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/Sync.java
+++ /dev/null
@@ -1,29 +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 org.apache.commons.rdf.api.io;
-
-import java.util.concurrent.ExecutorService;
-
-public interface Sync<T, S> extends _Buildable{
-    Sync<T ,S> build();
-    <V> Sync<T, S> option(Option<V> option, V value);
-
-    Async<T, S> async();
-    Async<T, S> async(ExecutorService executor);
-    Parsed<T, S> parse();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java b/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
new file mode 100644
index 0000000..59815f0
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentwriter.NeedTarget;
+
+public interface WriterFactory extends _SupportedSyntaxes {
+    NeedTarget syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
new file mode 100644
index 0000000..2ce9bbf
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
@@ -0,0 +1,9 @@
+package org.apache.commons.rdf.api.io;
+
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.TripleLike;
+
+public interface WriterSource {
+    Stream<? extends TripleLike> stream();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
new file mode 100644
index 0000000..f58f3d4
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
@@ -0,0 +1,8 @@
+package org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface WriterTarget {
+    OutputStream outputStream() throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/Written.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Written.java b/api/src/main/java/org/apache/commons/rdf/api/io/Written.java
new file mode 100644
index 0000000..38b5360
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/Written.java
@@ -0,0 +1,9 @@
+package org.apache.commons.rdf.api.io;
+
+public interface Written<S,T> {
+
+    WriterSource source();
+
+    WriterTarget target();
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.java b/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.java
deleted file mode 100644
index 23c4561..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_Buildable.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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.io.Option.RequiredOption;
-
-interface _Buildable {
-    /**
-     * Return an immutable builder at the current state. The returned builder
-     * can be re-used multiple times in a thread-safe way.
-     * 
-     * @return
-     */
-    _Buildable build();
-    
-    /**
-     * Return a builder with the given option set.
-     * <p>
-     * Note that implementations of {@link ParserFactory} may support different
-     * vendor-specific {@link Option} types, and are free to ignore the set
-     * option (unless it is a {@link RequiredOption}).
-     * <p>
-     * It is undefined if setting multiple values for the same (equal) option
-     * are accumulative or overriding.
-     * 
-     * @param option
-     * @param value
-     * @return
-     */
-    <V> _Buildable option(Option<V> option, V value);
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java
deleted file mode 100644
index bc4a55c..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedIdentifiedSource.java
+++ /dev/null
@@ -1,34 +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 org.apache.commons.rdf.api.io;
-
-import java.nio.file.Path;
-
-import javax.xml.transform.Source;
-
-import org.apache.commons.rdf.api.IRI;
-
-interface _NeedIdentifiedSource<T> {
-    Sync<T, IRI> source(IRI iri);
-
-    Sync<T, Path> source(Path path);
-
-    <S> Sync<T, S> source(ParserSource<S> source);
-
-    Sync<T, IRI> source(String iri);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java
deleted file mode 100644
index a8385dc..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTarget.java
+++ /dev/null
@@ -1,29 +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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-
-interface _NeedTarget {
-    NeedSourceOrBase<Dataset> target(Dataset dataset);
-
-    NeedSourceOrBase<Graph> target(Graph graph);
-
-    <T> NeedSourceOrBase<T> target(ParserTarget<T> target);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java
deleted file mode 100644
index daf34fe..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_NeedTargetOrRDF.java
+++ /dev/null
@@ -1,21 +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 org.apache.commons.rdf.api.io;
-
-interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java b/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java
deleted file mode 100644
index f9a4e2d..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalBase.java
+++ /dev/null
@@ -1,26 +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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.IRI;
-
-interface _OptionalBase<T> {
-    NeedSourceBased<T> base(IRI iri);
-
-    NeedSourceBased<T> base(String iri);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java b/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java
deleted file mode 100644
index b593e2b..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_OptionalRDF.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.RDF;
-
-interface _OptionalRDF {
-    OptionalTarget<Dataset> rdf(RDF rdf);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java b/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
new file mode 100644
index 0000000..aa3e115
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
@@ -0,0 +1,28 @@
+package org.apache.commons.rdf.api.io;
+
+import java.util.Set;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+
+interface _SupportedSyntaxes {
+    /**
+     * Get set of syntaxes supported by this factory.
+     * <p>
+     * The returned syntaxes can be used with {@link #syntax(RDFSyntax)} and may
+     * be used by this factory if no syntax is given.
+     * <p>
+     * Note that the factory may support additional syntaxes not returned
+     * in this set.
+     * 
+     * @return Set of supported syntaxes
+     */
+    Set<RDFSyntax> supportedSyntaxes();
+    
+    /**
+     * Use the specified RDF syntax
+     * 
+     * @param syntax RDFSyntax
+     * @return Builder that uses specified syntax
+     */
+    Object syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
index e80574b..859d954 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
@@ -16,6 +16,6 @@
  * limitations under the License.
  */
 /**
- *
+ * 
  */
 package org.apache.commons.rdf.api.io;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
index 457ee90..aaa91e9 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDF.java
@@ -19,6 +19,13 @@ package org.apache.commons.rdf.api;
 
 import java.io.Serializable;
 import java.util.Locale;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.fluentparser.Async;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Sync;
+import org.apache.commons.rdf.api.io.ParserBuilder;
+import org.apache.commons.rdf.api.io.ParserFactory;
 
 /**
  * A RDF implementation.
@@ -254,5 +261,64 @@ public interface RDF {
      */
     Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
             throws IllegalArgumentException;
+    
+    /**
+     * Get a ParserFactory backed by this RDF instance.
+     * <p>
+     * The returned factory is thread-safe and can be used multiple times,
+     * however the builders it creates are not immutable or reusable, unless
+     * frozen with the {@link OptionalTarget#build()} method or equivalent.
+     * 
+     * @return ParserFactory
+     * @throws UnsupportedOperationException
+     *             If this RDF implementation does not support parsing RDF
+     */
+    public ParserFactory parserFactory() throws UnsupportedOperationException;
+    
+    /**
+     * Build a parser for the given RDF syntax.
+     * <p>
+     * If the RDF syntax is not supported/recognized by this RDF implementation,
+     * return {@link Optional#empty()}, otherwise the returned {@link Optional}
+     * contains an {@link ParserBuilder} fluent instance.
+     * <p>
+     * The returned {@link ParserBuilder} follows a <em>fluent</em> pattern to be
+     * set up before parsing the configured source into the configured target.
+     * As a minimum, one of the
+     * {@link ParserBuilder#source(org.apache.commons.rdf.api.io.ParserSource)}
+     * methods need to be called before calling {@link Sync#parse()} or
+     * {@link Async#parseAsync()}. For instance:
+     * <pre>{@code
+     * 
+     * Parsed<Dataset, IRI> p = rdf.parser(RDFSyntax.JSONLD)
+     *                             .source("http://example.com/data.jsonld")
+     *                             .parse();
+     * Dataset ds = p.target().target();
+     * }</pre>
+     * <p>
+     * The returned {@link ParserBuilder} has an implicit parse target of a
+     * fresh {@link Dataset} created with this {@link RDF} instance, but this
+     * can be overridden with {@link ParserBuilder#target(Dataset)},
+     * {@link ParserBuilder#target(Graph)} or
+     * {@link ParserBuilder#target(org.apache.commons.rdf.api.io.ParserTarget)}.
+     * For instance:
+     * 
+     * <pre>{@code
+     * rdf.parser(RDFSyntax.TURTLE)
+     *    .target(quad ->; System.out.println(quad.getSubject()))  
+     *    .source(Paths.get("/tmp/file.ttl").
+     *    .async().parseAsync();
+     * }</pre>
+     * <p>
+     * Note that the returned {@link ParserBuilder} may be mutable and not
+     * thread-safe, and should only be used for parsing once. A reusable,
+     * immutable builder can be created at any step with
+     * {@link ParserBuilder#build()}.
+     * 
+     * @param syntax RDF Syntax to build a parser for
+     * @return A {@link ParserBuilder}, or {@link Optional#empty()} if the
+     *         syntax is not supported.
+     */
+    public Optional<ParserBuilder> parser(RDFSyntax syntax);
 
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/921965d4/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDFSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDFSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDFSyntax.java
index 00b9408..3ad7c24 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDFSyntax.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/RDFSyntax.java
@@ -99,11 +99,12 @@ public interface RDFSyntax {
     static RDFSyntax TRIG = W3CRDFSyntax.TRIG;
 
     /**
-     * A short name of the RDF Syntax e.g. <code>JSONLD</code>.
+     * A short name of the RDF Syntax.
      * <p>
-     * The name is specific to Commons RDF and carries no particular meaning.
-     *
-     * @return Short name for RDF syntax
+     * The name is specific to Commons RDF and carries no particular meaning. 
+     * 
+     * @return Short name for RDF syntax, e.g. <code>JSONLD</code>.
+     * @see #byName(String)
      */
     String name();
 
@@ -112,27 +113,30 @@ public interface RDFSyntax {
      * <p>
      * This is generally the title of the corresponding standard,
      * e.g. <em>RDF 1.1 Turtle</em>.
-     *
-     * @return Title of RDF Syntax
+     * 
+     * @return Title of RDF Syntax, e.g. <code>RDF 1.1 Turtle</code>.
      */
     String title();
 
     /**
-     * The <a href="https://tools.ietf.org/html/rfc2046">IANA media type</a> for
-     * the RDF syntax.
+     * The IANA media type for the RDF syntax.
      * <p>
      * The media type can be used as part of <code>Content-Type</code> and
      * <code>Accept</code> for <em>content negotiation</em> in the
      * <a href="https://tools.ietf.org/html/rfc7231#section-3.1.1.1">HTTP
      * protocol</a>.
-     *
-     * @return The registered media type of the RDF Syntax
+     * 
+     * @return IANA media type, e.g. <code>text/turtle</code>
+     *  
+     * @see #mediaTypes()
+     * @see #byMediaType(String)
+     * @see <a href="https://tools.ietf.org/html/rfc2046">IANA media type</a>
      */
     String mediaType();
 
     /**
-     * Set of <a href="https://tools.ietf.org/html/rfc2046">IANA media types</a> that
-     * covers this RDF syntax, including any non-official media types.
+     * Set of IANA media types that
+     * covers this RDF syntax, including any non-official media types. 
      * <p>
      * The media type can be used as part of <code>Content-Type</code> and
      * <code>Accept</code> for <em>content negotiation</em> in the
@@ -141,8 +145,10 @@ public interface RDFSyntax {
      * <p>
      * The returned Set MUST include the value {@link #mediaType()}; this is the
      * behaviour of the default implementation.
-     *
-     * @return The media types corresponding to the RDF Syntax
+     * 
+     * @return Set of IANA media types
+     * @see #mediaType()
+     * @see <a href="https://tools.ietf.org/html/rfc2046">IANA media types</a>
      */
     default Set<String> mediaTypes() {
         return Collections.singleton(mediaType());
@@ -151,10 +157,10 @@ public interface RDFSyntax {
     /**
      * The <a href="https://tools.ietf.org/html/rfc2046">IANA-registered</a>
      * file extension.
-     * <p>
-     * The file extension includes the leading period, e.g. <code>.jsonld</code>
-     *
-     * @return The registered file extension of the RDF Syntax
+     * 
+     * @return File extension including the leading period, e.g. <code>.jsonld</code>
+     * @see #fileExtensions()
+     * @see #byFileExtension(String)
      */
     String fileExtension();
 
@@ -165,8 +171,10 @@ public interface RDFSyntax {
      * <p>
      * The returned Set MUST include the value from {@link #fileExtension()}; this is
      * the behaviour of the default implementation.
-     *
-     * @return The file extensions corresponding to the RDF Syntax
+     * 
+     * @return Set of file extensions
+     * @see #fileExtension()
+     * @see #byFileExtension(String)
      */
     default Set<String> fileExtensions() {
         return Collections.singleton(fileExtension());
@@ -176,8 +184,8 @@ public interface RDFSyntax {
      * Indicate if this RDF syntax supports
      * <a href="https://www.w3.org/TR/rdf11-concepts/#section-dataset">RDF
      * Datasets</a>.
-     *
-     * @return true if this RDF Syntax supports datasets; false otherwise
+     * 
+     * @return <code>true</code> if this syntax supports datasets, otherwise <code>false</code>.
      */
     boolean supportsDataset();
 
@@ -199,10 +207,9 @@ public interface RDFSyntax {
      * {@link #mediaType()}s are equal when compared as lower case strings
      * according to {@link String#toLowerCase(Locale)} with the locale
      * {@link Locale#ROOT}.
-     *
-     * @param obj the object with which to compare
-     * @return true if this object is the same as the obj argument; false otherwise
-     */
+     * <p>
+     * {@inheritDoc}
+s     */
     @Override
     boolean equals(Object obj);
 
@@ -260,6 +267,8 @@ public interface RDFSyntax {
      *         a matching {@link RDFSyntax#mediaType()}, otherwise
      *         {@link Optional#empty()} indicating that no matching syntax was
      *         found.
+     * @see #mediaTypes()
+     *         
      */
     static Optional<RDFSyntax> byMediaType(final String mediaType) {
         final String type = mediaType.toLowerCase(Locale.ROOT).split("\\s*;", 2)[0];
@@ -282,6 +291,7 @@ public interface RDFSyntax {
      *         a matching {@link RDFSyntax#fileExtension()}, otherwise
      *         {@link Optional#empty()} indicating that no matching file
      *         extension was found.
+     * @see #fileExtensions()
      */
     static Optional<RDFSyntax> byFileExtension(final String fileExtension) {
         final String ext = fileExtension.toLowerCase(Locale.ROOT);


[14/17] commons-rdf git commit: Export inner classes

Posted by st...@apache.org.
Export inner classes


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/725e8d08
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/725e8d08
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/725e8d08

Branch: refs/heads/fluent-parser
Commit: 725e8d086a0306ccdb120d117ee9c59bb7f11e3e
Parents: fb9a60b
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 15 00:55:04 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 15 00:55:04 2018 +0000

----------------------------------------------------------------------
 .../rdf/api/io/AbstractParserFactory.java       | 178 ++-----------------
 .../org/apache/commons/rdf/api/io/IRIImpl.java  |  47 +++++
 .../commons/rdf/api/io/IRIParserSource.java     |  47 +++++
 .../commons/rdf/api/io/InputParserSource.java   |  44 +++++
 .../commons/rdf/api/io/ParserConfigImpl.java    |  90 ++++++++++
 .../commons/rdf/api/io/PathParserSource.java    |  49 +++++
 6 files changed, 291 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/725e8d08/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
index 2e37b81..725a569 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
@@ -16,15 +16,9 @@
  */
 package org.apache.commons.rdf.api.io;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
-import java.net.URL;
-import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
@@ -66,170 +60,26 @@ Async {
 		}
 	}
 
-	static final class InputParserSource implements ParserSource {
-		private final InputStream is;
-
-		private InputParserSource(InputStream is) {
-			this.is = is;
-		}
-
-		@Override
-		public Object src() {
-			return is;
-		}
-
-		@Override
-		public InputStream inputStream() throws IOException {
-			return is;
-		}
-
-		@Override
-		public Optional iri() {
-			return Optional.empty();
-		}
-	}
-
-	private final class PathParserSource implements ParserSource<Path> {
-		private final Path path;
-
-		private PathParserSource(Path path) {
-			this.path = path;
-		}
-
-		@Override
-		public Path src() {
-			return path;
-		}
-
-		@Override
-		public InputStream inputStream() throws IOException {
-			return Files.newInputStream(path);
-		}
+	private boolean mutable = false;
+	private ParserConfigImpl config = new ParserConfigImpl();
 
-		@Override
-		public Optional<IRI> iri() {
-			final String uri = path.toUri().toString();
-			return Optional.of(new IRIImpl(uri));
-		}
+	@Override
+	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+		return mutate(config::withSyntax, syntax);
 	}
 
-	private final class IRIParserSource implements ParserSource<IRI> {
-		private final IRI iri;
-
-		private IRIParserSource(IRI iri) {
-			this.iri = iri;
-		}
-
-		@Override
-		public IRI src() {
-			return iri;
-		}
-
-		@Override
-		public InputStream inputStream() throws IOException {
-			return new URL(iri.getIRIString()).openStream();
-		}
-
-		@Override
-		public Optional<IRI> iri() {
-			return Optional.of(iri);
-		}
+	@FunctionalInterface
+	private interface WithValue<V> {
+		ParserConfig withValue(V value); 
 	}
-
-	private final class IRIImpl implements IRI {
-		private final String uri;
-
-		private IRIImpl(String uri) {
-			this.uri = uri;
-		}
-
-		@Override
-		public String ntriplesString() {
-			return "<" + uri + ">";
-		}
-
-		@Override
-		public String getIRIString() {
-			return uri;
-		}
-
-		@Override
-		public boolean equals(Object obj) {
-			return (obj instanceof IRI) && ((IRI) obj).getIRIString().equals(uri);
-		}
-
-		@Override
-		public int hashCode() {
-			return uri.hashCode();
-		}
-	}
-
-	public static final class ParserConfigImpl implements Cloneable, Serializable, ParserConfig {
-		private static final long serialVersionUID = 1L;
-		private RDF rdf = null;
-		private RDFSyntax syntax = null;
-		private IRI base = null;
-		private ParserSource source = null;
-		private ParserTarget target = null;
-		final private  Map<Option, Object> options = new HashMap<>();
-
-		public ParserConfigImpl() {
-		}
-		
-		public ParserConfigImpl(ParserConfig old) {
-			rdf = old.rdf().orElse(null);
-			syntax = old.syntax().orElse(null);
-			base = old.base().orElse(null);
-			source = old.source().orElse(null);
-			target = old.target().orElse(null);
-			options.putAll(old.options());
-		}
-
-		@Override
-		protected Object clone() {
-			return new ParserConfigImpl(this);
-		}
-
-		@Override
-		public Optional<ParserSource> source() {
-			return Optional.of(source);
-		}
-
-		@Override
-		public Optional<IRI> base() {
-			return Optional.of(base);
-		}
-
-		@Override
-		public Optional<ParserTarget> target() {
-			return Optional.of(target);
-		}
-
-		@Override
-		public Optional<RDFSyntax> syntax() {
-			return Optional.of(syntax);
-		}
-
-		@Override
-		public Optional<RDF> rdf() {
-			return Optional.of(rdf);
-		}
-
-		@Override
-		public Map<Option, Object> options() {
-			return options;
+	
+	private AbstractParserFactory mutate(WithValue<V> valueFunc, V value) {
+		if (mutable) {
+			return valueFunc.withValue(value);
+		} else {
+			mutable().mutate(valueFunc, value);
 		}
 		
-		
-	}
-	private boolean mutable = false;
-	private ParserConfigImpl config = new ParserConfigImpl();
-
-	@Override
-	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
-		AbstractParserFactory c = mutable();
-		c.config.syntax = syntax;
-		return c;
 	}
 
 	private AbstractParserFactory mutable(boolean mutable) {

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/725e8d08/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIImpl.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIImpl.java
new file mode 100644
index 0000000..fa65e98
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIImpl.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 org.apache.commons.rdf.api.io;
+
+import org.apache.commons.rdf.api.IRI;
+
+final class IRIImpl implements IRI {
+	private final String uri;
+
+	IRIImpl(String uri) {
+		this.uri = uri;
+	}
+
+	@Override
+	public String ntriplesString() {
+		return "<" + uri + ">";
+	}
+
+	@Override
+	public String getIRIString() {
+		return uri;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		return (obj instanceof IRI) && ((IRI) obj).getIRIString().equals(uri);
+	}
+
+	@Override
+	public int hashCode() {
+		return uri.hashCode();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/725e8d08/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIParserSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIParserSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIParserSource.java
new file mode 100644
index 0000000..83a5ea4
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/IRIParserSource.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 org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+
+final class IRIParserSource implements ParserSource<IRI> {
+	private final IRI iri;
+
+	IRIParserSource(IRI iri) {
+		this.iri = iri;
+	}
+
+	@Override
+	public IRI src() {
+		return iri;
+	}
+
+	@Override
+	public InputStream inputStream() throws IOException {
+		return new URL(iri.getIRIString()).openStream();
+	}
+
+	@Override
+	public Optional<IRI> iri() {
+		return Optional.of(iri);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/725e8d08/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/InputParserSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/InputParserSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/InputParserSource.java
new file mode 100644
index 0000000..5a99e4b
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/InputParserSource.java
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+
+final class InputParserSource implements ParserSource {
+	private final InputStream is;
+
+	InputParserSource(InputStream is) {
+		this.is = is;
+	}
+
+	@Override
+	public Object src() {
+		return is;
+	}
+
+	@Override
+	public InputStream inputStream() throws IOException {
+		return is;
+	}
+
+	@Override
+	public Optional iri() {
+		return Optional.empty();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/725e8d08/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
new file mode 100644
index 0000000..a61e50e
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
@@ -0,0 +1,90 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+
+public final class ParserConfigImpl implements Cloneable, Serializable, ParserConfig {
+	private static final long serialVersionUID = 1L;
+	private RDF rdf = null;
+	private RDFSyntax syntax = null;
+	private IRI base = null;
+	private ParserSource source = null;
+	private ParserTarget target = null;
+	private final  Map<Option, Object> options = new HashMap<>();
+
+	public ParserConfigImpl() {
+	}
+	
+	public ParserConfigImpl(ParserConfig old) {
+		rdf = old.rdf().orElse(null);
+		syntax = old.syntax().orElse(null);
+		base = old.base().orElse(null);
+		source = old.source().orElse(null);
+		target = old.target().orElse(null);
+		options.putAll(old.options());
+	}
+
+	@Override
+	protected Object clone() {
+		return new ParserConfigImpl(this);
+	}
+
+	@Override
+	public Optional<ParserSource> source() {
+		return Optional.of(source);
+	}
+
+	@Override
+	public Optional<IRI> base() {
+		return Optional.of(base);
+	}
+
+	@Override
+	public Optional<ParserTarget> target() {
+		return Optional.of(target);
+	}
+
+	@Override
+	public Optional<RDFSyntax> syntax() {
+		return Optional.of(syntax);
+	}
+
+	@Override
+	public Optional<RDF> rdf() {
+		return Optional.of(rdf);
+	}
+
+	@Override
+	public Map<Option, Object> options() {
+		return options;
+	}
+
+	ParserConfig withSyntax(RDFSyntax syntax) {		
+		this.syntax = syntax;
+		return this;
+	}
+	
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/725e8d08/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/PathParserSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/PathParserSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/PathParserSource.java
new file mode 100644
index 0000000..7c6e14c
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/PathParserSource.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+
+final class PathParserSource implements ParserSource<Path> {
+	private final Path path;
+
+	PathParserSource(Path path) {
+		this.path = path;
+	}
+
+	@Override
+	public Path src() {
+		return path;
+	}
+
+	@Override
+	public InputStream inputStream() throws IOException {
+		return Files.newInputStream(path);
+	}
+
+	@Override
+	public Optional<IRI> iri() {
+		final String uri = path.toUri().toString();
+		return Optional.of(new IRIImpl(uri));
+	}
+}
\ No newline at end of file


[04/17] commons-rdf git commit: Use ForkJoinPool instead of own ThreadPool

Posted by st...@apache.org.
Use ForkJoinPool instead of own ThreadPool


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/96c21ea5
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/96c21ea5
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/96c21ea5

Branch: refs/heads/fluent-parser
Commit: 96c21ea5d97b14011e9bceb19d16d7ccf4fe2732
Parents: 092c465
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 16 11:52:58 2017 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 18:57:54 2018 +0000

----------------------------------------------------------------------
 .../commons/rdf/simple/experimental/AbstractRDFParser.java     | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96c21ea5/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
index 0ef4d68..55c8de8 100644
--- a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
+++ b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
@@ -25,6 +25,7 @@ import java.nio.file.Path;
 import java.util.Optional;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.Future;
 import java.util.function.Consumer;
 
@@ -58,9 +59,6 @@ import org.apache.commons.rdf.simple.SimpleRDF;
  */
 public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>> implements RDFParser, Cloneable {
 
-    public static final ThreadGroup threadGroup = new ThreadGroup("Commons RDF parsers");
-    private static final ExecutorService threadpool = Executors.newCachedThreadPool(r -> new Thread(threadGroup, r));
-
     // Basically only used for creating IRIs
     private static RDF internalRdfTermFactory = new SimpleRDF();
 
@@ -213,6 +211,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>> implemen
     private Consumer<Quad> target;
     private Dataset targetDataset;
     private Graph targetGraph;
+    private ExecutorService threadpool = ForkJoinPool.commonPool();
 
     @SuppressWarnings("unchecked")
     @Override
@@ -531,6 +530,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>> implemen
     @Override
     public Future<ParseResult> parse() throws IOException, IllegalStateException {
         final AbstractRDFParser<T> c = prepareForParsing();
+        
         return threadpool.submit(() -> {
             c.parseSynchronusly();
             return null;


[17/17] commons-rdf git commit: Thread pool submit

Posted by st...@apache.org.
Thread pool submit


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/a944f7b9
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/a944f7b9
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/a944f7b9

Branch: refs/heads/fluent-parser
Commit: a944f7b9e1f2ab7d64828e2b43baf440eff4def3
Parents: 0e43e6e
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 15 01:54:07 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 15 01:54:07 2018 +0000

----------------------------------------------------------------------
 .../rdf/api/io/AbstractParserBuilder.java       | 50 +++++++++++++++-----
 .../apache/commons/rdf/api/io/AsyncImpl.java    | 48 +++++++++++++++++++
 .../commons/rdf/api/io/ParserConfigImpl.java    |  2 +
 .../simple/experimental/AbstractRDFParser.java  |  2 +-
 4 files changed, 89 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a944f7b9/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
index c51cabb..bfd6b80 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
@@ -19,7 +19,9 @@ package org.apache.commons.rdf.api.io;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.nio.file.Path;
+import java.util.Optional;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import org.apache.commons.rdf.api.Dataset;
@@ -41,8 +43,12 @@ public final class AbstractParserBuilder implements Cloneable, Serializable, Nee
 
 	private static final long serialVersionUID = 1L;
 
+
+    private static final ThreadGroup THEAD_GROUP = new ThreadGroup("Commons RDF parsers");
+    private static final ExecutorService DEFAULT_EXECUTOR = Executors.newCachedThreadPool(r -> new Thread(THEAD_GROUP, r));
+	
 	public AbstractParserBuilder(RDF rdf) {
-		
+		config.withRDF(rdf);
 	}
 	
 	@Override
@@ -58,6 +64,7 @@ public final class AbstractParserBuilder implements Cloneable, Serializable, Nee
 
 	private boolean mutable = false;
 	private ParserConfigImpl config = new ParserConfigImpl();
+	private ExecutorService executor = DEFAULT_EXECUTOR;
 
 	@Override
 	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
@@ -158,31 +165,50 @@ public final class AbstractParserBuilder implements Cloneable, Serializable, Nee
 	}
 
 	@Override
-	public Future parseAsync() {
-		// TODO Auto-generated method stub
-		return null;
+	public Future<Parsed> parseAsync() {
+		// Ensure immutable
+		AbstractParserBuilder frozen = mutable(false);
+		Parser parser = getParserOrFail(frozen.config);		
+		return frozen.executor.submit(() -> parser.parse(frozen.config));
 	}
 
 	@Override
 	public Async async() {
-		// TODO Auto-generated method stub
-		return null;
+		AbstractParserBuilder c = mutable();
+		c.executor = DEFAULT_EXECUTOR;
+		return c;
 	}
 
 	@Override
 	public Async async(ExecutorService executor) {
-		// TODO Auto-generated method stub
-		return null;
+		AbstractParserBuilder c = mutable();
+		c.executor = executor;
+		return c;
 	}
 
 	@Override
-	public Parsed parse() {
-		return null;
+	public Sync source(InputStream is) {
+		return source(new InputParserSource(is));
 	}
 
 	@Override
-	public Sync source(InputStream is) {
-		return source(new InputParserSource(is));
+	public Parsed parse() {
+		// ensure immutable copy of config
+		ParserConfigImpl c = mutable(false).config;
+		Parser parser = getParserOrFail(c);
+		return parser.parse(c);
+	}
+
+	private Parser getParserOrFail(ParserConfigImpl c) {
+		if (! c.rdf().isPresent()) {
+			throw new IllegalStateException("ParserState has no RDF instance configured");
+		}
+		Optional<Parser> parser = c.rdf().get().parser(c.syntax().orElse(null));
+		if (! parser.isPresent()) { 
+			throw new IllegalStateException("Unsupported RDF syntax " 
+					+ c.syntax().map(t -> t.name() ).orElse("(guess)"));
+		}
+		return parser.get();
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a944f7b9/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AsyncImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AsyncImpl.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AsyncImpl.java
new file mode 100644
index 0000000..2c0c0d5
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AsyncImpl.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 org.apache.commons.rdf.api.io;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.fluentparser.Async;
+
+public class AsyncImpl implements Async {
+
+    public static final ThreadGroup threadGroup = new ThreadGroup("Commons RDF parsers");
+    private static final ExecutorService threadpool = Executors.newCachedThreadPool(r -> new Thread(threadGroup, r));
+	
+	@Override
+	public Async build() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async option(Option option, Object value) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Future parseAsync() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a944f7b9/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
index e682c4d..0c12104 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/ParserConfigImpl.java
@@ -20,6 +20,7 @@ import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.concurrent.ExecutorService;
 
 import org.apache.commons.rdf.api.IRI;
 import org.apache.commons.rdf.api.RDF;
@@ -35,6 +36,7 @@ public final class ParserConfigImpl implements Cloneable, Serializable, ParserCo
 	@SuppressWarnings("rawtypes")
 	private ParserTarget target = null;
 	private final Map<Option, Object> options = new HashMap<>();
+	private ExecutorService executor;
 
 	public ParserConfigImpl() {
 	}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/a944f7b9/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
index 55c8de8..f02ed19 100644
--- a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
+++ b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
@@ -58,7 +58,7 @@ import org.apache.commons.rdf.simple.SimpleRDF;
  * asynchronous remote execution).
  */
 public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>> implements RDFParser, Cloneable {
-
+	
     // Basically only used for creating IRIs
     private static RDF internalRdfTermFactory = new SimpleRDF();
 


[10/17] commons-rdf git commit: fluent API moved into commons-rdf-api/

Posted by st...@apache.org.
fluent API moved into commons-rdf-api/


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/96fb0f06
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/96fb0f06
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/96fb0f06

Branch: refs/heads/fluent-parser
Commit: 96fb0f06b58add16869637e5ab18ac5d7dbd1be0
Parents: 577614d
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Feb 14 19:03:08 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Feb 14 19:03:08 2018 +0000

----------------------------------------------------------------------
 .../commons/rdf/api/fluentparser/Async.java     |  31 -----
 .../rdf/api/fluentparser/NeedSourceBased.java   |  29 -----
 .../rdf/api/fluentparser/NeedSourceOrBase.java  |  25 ----
 .../rdf/api/fluentparser/NeedTarget.java        |  25 ----
 .../rdf/api/fluentparser/NeedTargetOrRDF.java   |  25 ----
 .../fluentparser/NeedTargetOrRDFOrSyntax.java   |  22 ----
 .../rdf/api/fluentparser/OptionalTarget.java    |  25 ----
 .../fluentparser/OptionalTargetOrSyntax.java    |   5 -
 .../commons/rdf/api/fluentparser/Sync.java      |  32 -----
 .../rdf/api/fluentparser/_Buildable.java        |  50 -------
 .../api/fluentparser/_NeedIdentifiedSource.java |  35 -----
 .../rdf/api/fluentparser/_NeedSyntax.java       |   7 -
 .../rdf/api/fluentparser/_NeedTarget.java       |  30 -----
 .../rdf/api/fluentparser/_NeedTargetOrRDF.java  |  21 ---
 .../rdf/api/fluentparser/_OptionalBase.java     |  26 ----
 .../rdf/api/fluentparser/_OptionalRDF.java      |  25 ----
 .../rdf/api/fluentparser/package-info.java      |  21 ---
 .../commons/rdf/api/fluentwriter/Async.java     |  14 --
 .../rdf/api/fluentwriter/NeedSource.java        |  20 ---
 .../rdf/api/fluentwriter/NeedTarget.java        |  34 -----
 .../commons/rdf/api/fluentwriter/Sync.java      |  16 ---
 .../rdf/api/fluentwriter/_Buildable.java        |  50 -------
 .../rdf/api/fluentwriter/package-info.java      |  21 ---
 .../org/apache/commons/rdf/api/io/Option.java   |  25 ----
 .../org/apache/commons/rdf/api/io/Parsed.java   |  26 ----
 .../commons/rdf/api/io/ParserBuilder.java       |   9 --
 .../commons/rdf/api/io/ParserFactory.java       |  27 ----
 .../apache/commons/rdf/api/io/ParserSource.java |  33 -----
 .../apache/commons/rdf/api/io/ParserTarget.java |  32 -----
 .../commons/rdf/api/io/WriterFactory.java       |  25 ----
 .../apache/commons/rdf/api/io/WriterSource.java |   9 --
 .../apache/commons/rdf/api/io/WriterTarget.java |   8 --
 .../org/apache/commons/rdf/api/io/Written.java  |   9 --
 .../commons/rdf/api/io/_SupportedSyntaxes.java  |  28 ----
 .../apache/commons/rdf/api/io/package-info.java |  21 ---
 .../apache/commons/rdf/experimental/Test.java   | 130 -------------------
 .../commons/rdf/api/fluentparser/Async.java     |  31 +++++
 .../rdf/api/fluentparser/NeedSourceBased.java   |  29 +++++
 .../rdf/api/fluentparser/NeedSourceOrBase.java  |  25 ++++
 .../rdf/api/fluentparser/NeedTarget.java        |  25 ++++
 .../rdf/api/fluentparser/NeedTargetOrRDF.java   |  25 ++++
 .../fluentparser/NeedTargetOrRDFOrSyntax.java   |  22 ++++
 .../rdf/api/fluentparser/OptionalTarget.java    |  25 ++++
 .../fluentparser/OptionalTargetOrSyntax.java    |   5 +
 .../commons/rdf/api/fluentparser/Sync.java      |  32 +++++
 .../rdf/api/fluentparser/_Buildable.java        |  50 +++++++
 .../api/fluentparser/_NeedIdentifiedSource.java |  35 +++++
 .../rdf/api/fluentparser/_NeedSyntax.java       |   7 +
 .../rdf/api/fluentparser/_NeedTarget.java       |  30 +++++
 .../rdf/api/fluentparser/_NeedTargetOrRDF.java  |  21 +++
 .../rdf/api/fluentparser/_OptionalBase.java     |  26 ++++
 .../rdf/api/fluentparser/_OptionalRDF.java      |  25 ++++
 .../rdf/api/fluentparser/package-info.java      |  21 +++
 .../commons/rdf/api/fluentwriter/Async.java     |  14 ++
 .../rdf/api/fluentwriter/NeedSource.java        |  20 +++
 .../rdf/api/fluentwriter/NeedTarget.java        |  34 +++++
 .../commons/rdf/api/fluentwriter/Sync.java      |  16 +++
 .../rdf/api/fluentwriter/_Buildable.java        |  50 +++++++
 .../rdf/api/fluentwriter/package-info.java      |  21 +++
 .../org/apache/commons/rdf/api/io/Option.java   |  25 ++++
 .../org/apache/commons/rdf/api/io/Parsed.java   |  26 ++++
 .../commons/rdf/api/io/ParserBuilder.java       |   9 ++
 .../commons/rdf/api/io/ParserFactory.java       |  27 ++++
 .../apache/commons/rdf/api/io/ParserSource.java |  33 +++++
 .../apache/commons/rdf/api/io/ParserTarget.java |  32 +++++
 .../commons/rdf/api/io/WriterFactory.java       |  25 ++++
 .../apache/commons/rdf/api/io/WriterSource.java |   9 ++
 .../apache/commons/rdf/api/io/WriterTarget.java |   8 ++
 .../org/apache/commons/rdf/api/io/Written.java  |   9 ++
 .../commons/rdf/api/io/_SupportedSyntaxes.java  |  28 ++++
 .../apache/commons/rdf/api/io/package-info.java |  21 +++
 71 files changed, 841 insertions(+), 971 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
deleted file mode 100644
index ba3fb2d..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
+++ /dev/null
@@ -1,31 +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 org.apache.commons.rdf.api.fluentparser;
-
-import java.util.concurrent.Future;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.Parsed;
-
-public interface Async<T, S> extends _Buildable {
-    Async<T, S> build();
-    
-    <V> Async<T, S> option(Option<V> option, V value);
-
-    Future<Parsed<T, S>> parseAsync();
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
deleted file mode 100644
index 54889e1..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
+++ /dev/null
@@ -1,29 +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 org.apache.commons.rdf.api.fluentparser;
-
-import java.io.InputStream;
-
-import org.apache.commons.rdf.api.io.Option;
-
-public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
-    NeedSourceBased<T> build();
-    <V> NeedSourceBased<T> option(Option<V> option, V value);
-
-    Sync<T, InputStream> source(InputStream is);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
deleted file mode 100644
index 91b83b7..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.io.Option;
-
-public interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T>, _Buildable {
-    NeedSourceOrBase<T> build();
-    <V> NeedSourceOrBase<T> option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
deleted file mode 100644
index 4ed3849..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.io.Option;
-
-interface NeedTarget extends _NeedTarget,_Buildable {
-    NeedTarget build();
-    <V> NeedTarget option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
deleted file mode 100644
index 109b70d..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.io.Option;
-
-public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
-    NeedTargetOrRDF build();
-    <V> NeedTargetOrRDF option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
deleted file mode 100644
index 61a0256..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
+++ /dev/null
@@ -1,22 +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 org.apache.commons.rdf.api.fluentparser;
-
-public interface NeedTargetOrRDFOrSyntax extends _NeedTargetOrRDF, _NeedSyntax {
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
deleted file mode 100644
index be8195c..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.io.Option;
-
-public interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T>,_Buildable {
-    OptionalTarget<T> build();
-    <V> OptionalTarget<T> option(Option<V> option, V value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
deleted file mode 100644
index 7dee7e4..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.commons.rdf.api.fluentparser;
-
-public interface OptionalTargetOrSyntax<T> extends OptionalTarget<T>, _NeedSyntax {
-    
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
deleted file mode 100644
index c141a18..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
+++ /dev/null
@@ -1,32 +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 org.apache.commons.rdf.api.fluentparser;
-
-import java.util.concurrent.ExecutorService;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.Parsed;
-
-public interface Sync<T, S> extends _Buildable{
-    Sync<T ,S> build();
-    <V> Sync<T, S> option(Option<V> option, V value);
-
-    Async<T, S> async();
-    Async<T, S> async(ExecutorService executor);
-    Parsed<T, S> parse();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
deleted file mode 100644
index b21eb9d..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
+++ /dev/null
@@ -1,50 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.Option.RequiredOption;
-import org.apache.commons.rdf.api.io.ParserFactory;
-
-interface _Buildable {
-    /**
-     * Return an immutable builder at the current state. The returned builder
-     * can be re-used multiple times in a thread-safe way.
-     * 
-     * @return An immutable builder
-     */
-    _Buildable build();
-    
-    /**
-     * Return a builder with the given option set.
-     * <p>
-     * Note that implementations of {@link ParserFactory} may support different
-     * vendor-specific {@link Option} types, and are free to ignore the set
-     * option (unless it is a {@link RequiredOption}).
-     * <p>
-     * It is undefined if setting multiple values for the same (equal) option
-     * are accumulative or overriding.
-     * 
-     * @param <V> The type of the {@link Option} value 
-     * @param option Option to set
-     * @param value Value to set for option
-     * @return A builder with the given option set
-     */
-    <V> _Buildable option(Option<V> option, V value);
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
deleted file mode 100644
index 580adf6..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
+++ /dev/null
@@ -1,35 +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 org.apache.commons.rdf.api.fluentparser;
-
-import java.nio.file.Path;
-
-import javax.xml.transform.Source;
-
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.io.ParserSource;
-
-interface _NeedIdentifiedSource<T> {
-    Sync<T, IRI> source(IRI iri);
-
-    Sync<T, Path> source(Path path);
-
-    <S> Sync<T, S> source(ParserSource<S> source);
-
-    Sync<T, IRI> source(String iri);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
deleted file mode 100644
index 28f0cd1..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.RDFSyntax;
-
-interface _NeedSyntax {
-    NeedTargetOrRDF syntax(RDFSyntax syntax);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
deleted file mode 100644
index 2053f3b..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
+++ /dev/null
@@ -1,30 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.io.ParserTarget;
-
-interface _NeedTarget {
-    NeedSourceOrBase<Dataset> target(Dataset dataset);
-
-    NeedSourceOrBase<Graph> target(Graph graph);
-
-    <T> NeedSourceOrBase<T> target(ParserTarget<T> target);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
deleted file mode 100644
index 89016b4..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
+++ /dev/null
@@ -1,21 +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 org.apache.commons.rdf.api.fluentparser;
-
-interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
deleted file mode 100644
index 3e3235c..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
+++ /dev/null
@@ -1,26 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.IRI;
-
-interface _OptionalBase<T> {
-    NeedSourceBased<T> base(IRI iri);
-
-    NeedSourceBased<T> base(String iri);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
deleted file mode 100644
index 80ac15b..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.fluentparser;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.RDF;
-
-interface _OptionalRDF {
-    OptionalTarget<Dataset> rdf(RDF rdf);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
deleted file mode 100644
index 42c4921..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
+++ /dev/null
@@ -1,21 +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 org.apache.commons.rdf.api.fluentparser;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
deleted file mode 100644
index e7edcf4..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.apache.commons.rdf.api.fluentwriter;
-
-import java.util.concurrent.Future;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.Written;
-
-public interface Async extends _Buildable {
-    
-    Async build();    
-    <V> Async option(Option<V> option, V value);
-    
-    Future<Written> writeAsync();
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
deleted file mode 100644
index 3070427..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.apache.commons.rdf.api.fluentwriter;
-
-import java.util.stream.Stream;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.TripleLike;
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.WriterSource;
-
-public interface NeedSource extends _Buildable {
-    
-    NeedSource build();    
-    <V> NeedSource option(Option<V> option, V value);
-    
-    Sync source(Dataset dataset);
-    Sync source(Graph graph);
-    Sync source(Stream<? extends TripleLike> stream);
-    Sync source(WriterSource source);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
deleted file mode 100644
index 2148b54..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedTarget.java
+++ /dev/null
@@ -1,34 +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 org.apache.commons.rdf.api.fluentwriter;
-
-import java.io.OutputStream;
-import java.nio.file.Path;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.WriterTarget;
-
-public interface NeedTarget extends _Buildable {
-    @Override
-    NeedTarget build();
-    <V> NeedTarget option(Option<V> option, V value);
-    
-    NeedSource target(Path p);
-    NeedSource target(OutputStream out);
-    NeedSource target(WriterTarget target);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
deleted file mode 100644
index f6d8afc..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Sync.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.commons.rdf.api.fluentwriter;
-
-import java.util.concurrent.ExecutorService;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.Written;
-
-public interface Sync extends _Buildable {
-    
-    Sync build();    
-    <V> Sync option(Option<V> option, V value);
-
-    Written write(); // terminal
-    Async async();
-    Async async(ExecutorService service);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
deleted file mode 100644
index fc89f60..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/_Buildable.java
+++ /dev/null
@@ -1,50 +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 org.apache.commons.rdf.api.fluentwriter;
-
-import org.apache.commons.rdf.api.io.Option;
-import org.apache.commons.rdf.api.io.Option.RequiredOption;
-import org.apache.commons.rdf.api.io.ParserFactory;
-
-interface _Buildable {
-    /**
-     * Return an immutable builder at the current state. The returned builder
-     * can be re-used multiple times in a thread-safe way.
-     * 
-     * @return An immutable builder
-     */
-    _Buildable build();
-    
-    /**
-     * Return a builder with the given option set.
-     * <p>
-     * Note that implementations of {@link ParserFactory} may support different
-     * vendor-specific {@link Option} types, and are free to ignore the set
-     * option (unless it is a {@link RequiredOption}).
-     * <p>
-     * It is undefined if setting multiple values for the same (equal) option
-     * are accumulative or overriding.
-     * 
-     * @param <V> The type of the {@link Option} value 
-     * @param option Option to set
-     * @param value Value to set for option
-     * @return A builder with the given option set
-     */
-    <V> _Buildable option(Option<V> option, V value);
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
deleted file mode 100644
index 85f4c8a..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/fluentwriter/package-info.java
+++ /dev/null
@@ -1,21 +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 org.apache.commons.rdf.api.fluentwriter;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/Option.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Option.java b/api/src/main/java/org/apache/commons/rdf/api/io/Option.java
deleted file mode 100644
index 7cf5c86..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/Option.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.io;
-
-public interface Option<V> {
-
-    public interface RequiredOption<V> extends Option<V> {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java b/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
deleted file mode 100644
index b252e44..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/Parsed.java
+++ /dev/null
@@ -1,26 +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 org.apache.commons.rdf.api.io;
-
-public interface Parsed<T, S> {
-    long count();
-
-    ParserSource<S> from();
-
-    ParserTarget<T> into();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
deleted file mode 100644
index 037271c..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserBuilder.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
-
-public interface ParserBuilder extends OptionalTarget<Dataset> {
-    ParserBuilder build();
-    <V> ParserBuilder option(Option<V> option, V value);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
deleted file mode 100644
index b25a536..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserFactory.java
+++ /dev/null
@@ -1,27 +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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
-import org.apache.commons.rdf.api.fluentparser.OptionalTargetOrSyntax;
-
-public interface ParserFactory extends  _SupportedSyntaxes, OptionalTargetOrSyntax<Dataset> {
-    NeedTargetOrRDF syntax(RDFSyntax syntax);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
deleted file mode 100644
index 259688e..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserSource.java
+++ /dev/null
@@ -1,33 +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 org.apache.commons.rdf.api.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Optional;
-
-import org.apache.commons.rdf.api.IRI;
-
-/**
- *
- */
-public interface ParserSource<S> {
-    S src();   
-    InputStream inputStream() throws IOException;
-    Optional<IRI> iri();
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
deleted file mode 100644
index 8898643..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/ParserTarget.java
+++ /dev/null
@@ -1,32 +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 org.apache.commons.rdf.api.io;
-
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.Quad;
-
-/**
- *
- */
-@FunctionalInterface
-public interface ParserTarget<T> extends Consumer<Quad> {
-    default T dest() {
-        return null;// unknown
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java b/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
deleted file mode 100644
index 59815f0..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/WriterFactory.java
+++ /dev/null
@@ -1,25 +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 org.apache.commons.rdf.api.io;
-
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.fluentwriter.NeedTarget;
-
-public interface WriterFactory extends _SupportedSyntaxes {
-    NeedTarget syntax(RDFSyntax syntax);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java b/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
deleted file mode 100644
index 2ce9bbf..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/WriterSource.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.commons.rdf.api.io;
-
-import java.util.stream.Stream;
-
-import org.apache.commons.rdf.api.TripleLike;
-
-public interface WriterSource {
-    Stream<? extends TripleLike> stream();
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java b/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
deleted file mode 100644
index f58f3d4..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/WriterTarget.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.commons.rdf.api.io;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-public interface WriterTarget {
-    OutputStream outputStream() throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/Written.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/Written.java b/api/src/main/java/org/apache/commons/rdf/api/io/Written.java
deleted file mode 100644
index 38b5360..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/Written.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.commons.rdf.api.io;
-
-public interface Written<S,T> {
-
-    WriterSource source();
-
-    WriterTarget target();
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java b/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
deleted file mode 100644
index aa3e115..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/_SupportedSyntaxes.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.commons.rdf.api.io;
-
-import java.util.Set;
-
-import org.apache.commons.rdf.api.RDFSyntax;
-
-interface _SupportedSyntaxes {
-    /**
-     * Get set of syntaxes supported by this factory.
-     * <p>
-     * The returned syntaxes can be used with {@link #syntax(RDFSyntax)} and may
-     * be used by this factory if no syntax is given.
-     * <p>
-     * Note that the factory may support additional syntaxes not returned
-     * in this set.
-     * 
-     * @return Set of supported syntaxes
-     */
-    Set<RDFSyntax> supportedSyntaxes();
-    
-    /**
-     * Use the specified RDF syntax
-     * 
-     * @param syntax RDFSyntax
-     * @return Builder that uses specified syntax
-     */
-    Object syntax(RDFSyntax syntax);
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java b/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
deleted file mode 100644
index 859d954..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/io/package-info.java
+++ /dev/null
@@ -1,21 +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 org.apache.commons.rdf.api.io;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/api/src/test/java/org/apache/commons/rdf/experimental/Test.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/experimental/Test.java b/api/src/test/java/org/apache/commons/rdf/experimental/Test.java
deleted file mode 100644
index cee0854..0000000
--- a/api/src/test/java/org/apache/commons/rdf/experimental/Test.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.apache.commons.rdf.experimental;
-
-import static org.junit.Assert.*;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.slf4j.impl.SimpleLoggerFactory;
-
-interface State { 
-    Path source();
-    Graph target();
-    RDFSyntax syntax();
-    State withSource(Path p);
-    State withTarget(Graph g);
-    State withSyntax(RDFSyntax s);
-}
-
-abstract class AbstractState implements State { 
-    @Override
-    public State withSource(Path p) { 
-       return new WithSource(p, this); 
-    }
-    @Override
-    public State withSyntax(RDFSyntax s) {
-        return new WithSyntax(s, this);
-    }
-    @Override
-    public State withTarget(Graph g) {
-        return new WithTarget(g, this);
-    }
-    
-}
-
-final class DefaultState extends AbstractState {
-    @Override
-    public Path source() {
-        throw new IllegalStateException("Source not set");
-    }
-    @Override
-    public Graph target() {
-        throw new IllegalStateException("Target not set");
-    }
-    @Override
-    public RDFSyntax syntax() {
-        throw new IllegalStateException("Syntax not set");
-    }
-}
-
-abstract class Inherited extends AbstractState  {
-    private final State parent;
-    public Inherited() {
-        this(new DefaultState());
-    }
-    public Inherited(State state) {
-        parent = state;
-    }    
-    @Override
-    public Path source() {
-        return parent.source();
-    }
-    @Override
-    public Graph target() {
-        return parent.target();
-    }
-    @Override
-    public RDFSyntax syntax() {
-        return parent.syntax();
-    }
-    
-    
-}
-
-final class WithSource extends Inherited {    
-    private final Path source;   
-    public WithSource(final Path path) {
-        this.source = path;
-    }
-    public WithSource(final Path path, final State state) {
-        super(state);
-        this.source = path;
-    }    
-    @Override
-    public Path source() {
-        return source;
-    }
-}
-
-
-final class WithTarget extends Inherited {    
-    private final Graph target;   
-    public WithTarget(final Graph g) {
-        this.target = g;
-    }
-    public WithTarget(final Graph g, final State state) {
-        super(state);
-        this.target = g;
-    }    
-    @Override
-    public Graph target() {
-        return target;
-    }
-}
-
-final class WithSyntax extends Inherited {    
-    private final RDFSyntax syntax;   
-    public WithSyntax(final RDFSyntax s) {
-        syntax = s;
-    }
-    public WithSyntax(final RDFSyntax s, final State state) {
-        super(state);
-        syntax = s;
-    }    
-    @Override
-    public RDFSyntax syntax() {
-        return syntax;
-    }
-}
-
-public class Test {
-    @org.junit.Test
-    public void testName() throws Exception {
-        Path p = Paths.get("/tmp/f.txt");
-        Graph g = null;
-        State s = new DefaultState().withSource(p).withTarget(g).withSyntax(RDFSyntax.JSONLD);
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
new file mode 100644
index 0000000..ba3fb2d
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Async.java
@@ -0,0 +1,31 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Parsed;
+
+public interface Async<T, S> extends _Buildable {
+    Async<T, S> build();
+    
+    <V> Async<T, S> option(Option<V> option, V value);
+
+    Future<Parsed<T, S>> parseAsync();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
new file mode 100644
index 0000000..54889e1
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceBased.java
@@ -0,0 +1,29 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.io.InputStream;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedSourceBased<T> extends _NeedIdentifiedSource<T>, _Buildable {
+    NeedSourceBased<T> build();
+    <V> NeedSourceBased<T> option(Option<V> option, V value);
+
+    Sync<T, InputStream> source(InputStream is);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
new file mode 100644
index 0000000..91b83b7
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedSourceOrBase.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedSourceOrBase<T> extends _OptionalBase<T>, _NeedIdentifiedSource<T>, _Buildable {
+    NeedSourceOrBase<T> build();
+    <V> NeedSourceOrBase<T> option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
new file mode 100644
index 0000000..4ed3849
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTarget.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+interface NeedTarget extends _NeedTarget,_Buildable {
+    NeedTarget build();
+    <V> NeedTarget option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
new file mode 100644
index 0000000..109b70d
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDF.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface NeedTargetOrRDF extends _NeedTargetOrRDF,_Buildable {
+    NeedTargetOrRDF build();
+    <V> NeedTargetOrRDF option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
new file mode 100644
index 0000000..61a0256
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/NeedTargetOrRDFOrSyntax.java
@@ -0,0 +1,22 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+public interface NeedTargetOrRDFOrSyntax extends _NeedTargetOrRDF, _NeedSyntax {
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
new file mode 100644
index 0000000..be8195c
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTarget.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+
+public interface OptionalTarget<T> extends _NeedTarget, NeedSourceOrBase<T>,_Buildable {
+    OptionalTarget<T> build();
+    <V> OptionalTarget<T> option(Option<V> option, V value);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
new file mode 100644
index 0000000..7dee7e4
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/OptionalTargetOrSyntax.java
@@ -0,0 +1,5 @@
+package org.apache.commons.rdf.api.fluentparser;
+
+public interface OptionalTargetOrSyntax<T> extends OptionalTarget<T>, _NeedSyntax {
+    
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
new file mode 100644
index 0000000..c141a18
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/Sync.java
@@ -0,0 +1,32 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.util.concurrent.ExecutorService;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Parsed;
+
+public interface Sync<T, S> extends _Buildable{
+    Sync<T ,S> build();
+    <V> Sync<T, S> option(Option<V> option, V value);
+
+    Async<T, S> async();
+    Async<T, S> async(ExecutorService executor);
+    Parsed<T, S> parse();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
new file mode 100644
index 0000000..b21eb9d
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_Buildable.java
@@ -0,0 +1,50 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Option.RequiredOption;
+import org.apache.commons.rdf.api.io.ParserFactory;
+
+interface _Buildable {
+    /**
+     * Return an immutable builder at the current state. The returned builder
+     * can be re-used multiple times in a thread-safe way.
+     * 
+     * @return An immutable builder
+     */
+    _Buildable build();
+    
+    /**
+     * Return a builder with the given option set.
+     * <p>
+     * Note that implementations of {@link ParserFactory} may support different
+     * vendor-specific {@link Option} types, and are free to ignore the set
+     * option (unless it is a {@link RequiredOption}).
+     * <p>
+     * It is undefined if setting multiple values for the same (equal) option
+     * are accumulative or overriding.
+     * 
+     * @param <V> The type of the {@link Option} value 
+     * @param option Option to set
+     * @param value Value to set for option
+     * @return A builder with the given option set
+     */
+    <V> _Buildable option(Option<V> option, V value);
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
new file mode 100644
index 0000000..580adf6
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedIdentifiedSource.java
@@ -0,0 +1,35 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import java.nio.file.Path;
+
+import javax.xml.transform.Source;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.io.ParserSource;
+
+interface _NeedIdentifiedSource<T> {
+    Sync<T, IRI> source(IRI iri);
+
+    Sync<T, Path> source(Path path);
+
+    <S> Sync<T, S> source(ParserSource<S> source);
+
+    Sync<T, IRI> source(String iri);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
new file mode 100644
index 0000000..28f0cd1
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedSyntax.java
@@ -0,0 +1,7 @@
+package org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.RDFSyntax;
+
+interface _NeedSyntax {
+    NeedTargetOrRDF syntax(RDFSyntax syntax);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
new file mode 100644
index 0000000..2053f3b
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTarget.java
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.io.ParserTarget;
+
+interface _NeedTarget {
+    NeedSourceOrBase<Dataset> target(Dataset dataset);
+
+    NeedSourceOrBase<Graph> target(Graph graph);
+
+    <T> NeedSourceOrBase<T> target(ParserTarget<T> target);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
new file mode 100644
index 0000000..89016b4
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_NeedTargetOrRDF.java
@@ -0,0 +1,21 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+interface _NeedTargetOrRDF extends _NeedTarget, _OptionalRDF {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
new file mode 100644
index 0000000..3e3235c
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalBase.java
@@ -0,0 +1,26 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.IRI;
+
+interface _OptionalBase<T> {
+    NeedSourceBased<T> base(IRI iri);
+
+    NeedSourceBased<T> base(String iri);
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
new file mode 100644
index 0000000..80ac15b
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/_OptionalRDF.java
@@ -0,0 +1,25 @@
+/**
+ * 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 org.apache.commons.rdf.api.fluentparser;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.RDF;
+
+interface _OptionalRDF {
+    OptionalTarget<Dataset> rdf(RDF rdf);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
new file mode 100644
index 0000000..42c4921
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentparser/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 org.apache.commons.rdf.api.fluentparser;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
new file mode 100644
index 0000000..e7edcf4
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/Async.java
@@ -0,0 +1,14 @@
+package org.apache.commons.rdf.api.fluentwriter;
+
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.Written;
+
+public interface Async extends _Buildable {
+    
+    Async build();    
+    <V> Async option(Option<V> option, V value);
+    
+    Future<Written> writeAsync();
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/96fb0f06/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
new file mode 100644
index 0000000..3070427
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/fluentwriter/NeedSource.java
@@ -0,0 +1,20 @@
+package org.apache.commons.rdf.api.fluentwriter;
+
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.TripleLike;
+import org.apache.commons.rdf.api.io.Option;
+import org.apache.commons.rdf.api.io.WriterSource;
+
+public interface NeedSource extends _Buildable {
+    
+    NeedSource build();    
+    <V> NeedSource option(Option<V> option, V value);
+    
+    Sync source(Dataset dataset);
+    Sync source(Graph graph);
+    Sync source(Stream<? extends TripleLike> stream);
+    Sync source(WriterSource source);
+}


[16/17] commons-rdf git commit: AbstractParserFactory -> AbstractParserBuilder

Posted by st...@apache.org.
AbstractParserFactory -> AbstractParserBuilder


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/0e43e6e2
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/0e43e6e2
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/0e43e6e2

Branch: refs/heads/fluent-parser
Commit: 0e43e6e288c632f53275893a1807e891f2f48568
Parents: 10928ea
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Feb 15 01:25:57 2018 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Feb 15 01:25:57 2018 +0000

----------------------------------------------------------------------
 .../rdf/api/io/AbstractParserBuilder.java       | 188 +++++++++++++++++++
 .../rdf/api/io/AbstractParserFactory.java       | 188 -------------------
 .../org/apache/commons/rdf/api/io/Parser.java   |   1 +
 3 files changed, 189 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/0e43e6e2/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
new file mode 100644
index 0000000..c51cabb
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
@@ -0,0 +1,188 @@
+/*
+ * 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 org.apache.commons.rdf.api.io;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.nio.file.Path;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentparser.Async;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDFOrSyntax;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Sync;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public final class AbstractParserBuilder implements Cloneable, Serializable, NeedTargetOrRDF, NeedTargetOrRDFOrSyntax,
+		NeedSourceOrBase, NeedSourceBased, OptionalTarget, Sync, Async {
+
+	private static final long serialVersionUID = 1L;
+
+	public AbstractParserBuilder(RDF rdf) {
+		
+	}
+	
+	@Override
+	public AbstractParserBuilder clone() {
+		try {
+			AbstractParserBuilder c = (AbstractParserBuilder) super.clone();
+			c.config = (ParserConfigImpl) config.clone();
+			return c;
+		} catch (CloneNotSupportedException e) {
+			throw new IllegalStateException("AbstractParserBuilder was not Cloneable", e);
+		}
+	}
+
+	private boolean mutable = false;
+	private ParserConfigImpl config = new ParserConfigImpl();
+
+	@Override
+	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+		AbstractParserBuilder c = mutable();
+		c.config.withSyntax(syntax);
+		return c;
+	}
+
+	private AbstractParserBuilder mutable(boolean mutable) {
+		if (this.mutable == mutable) {
+			return this;
+		} else {
+			AbstractParserBuilder c = clone();
+			c.mutable = mutable;
+			return c;
+		}
+	}
+
+	private AbstractParserBuilder mutable() {
+		return mutable(true);
+	}
+
+	@Override
+	public AbstractParserBuilder build() {
+		return mutable(false);
+	}
+
+	@Override
+	public NeedSourceOrBase target(Dataset dataset) {
+		return target(dataset::add);
+
+	}
+
+	@Override
+	public NeedSourceOrBase<Graph> target(Graph graph) {
+		return target(q -> {
+			if (q.getGraphName().isPresent()) {
+				// Only add if q is in default graph
+				graph.add(q.asTriple());
+			}
+		});
+	}
+
+	@Override
+	public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
+		AbstractParserBuilder c = mutable();
+		c.config.withTarget(target);
+		return c;
+	}
+
+	@Override
+	public NeedSourceBased base(IRI iri) {
+		AbstractParserBuilder c = mutable();
+		c.config.withBase(iri);
+		return c;
+	}
+
+	@Override
+	public NeedSourceBased base(String iri) {
+		AbstractParserBuilder c = mutable();
+		c.config.withBase(new IRIImpl(iri));
+		return c;
+	}
+
+	@Override
+	public Sync source(final IRI iri) {
+		return source(new IRIParserSource(iri));
+	}
+
+	public Sync source(Path path) {
+		return source(new PathParserSource(path));
+	}
+
+	@Override
+	public OptionalTarget<Dataset> rdf(RDF rdf) {
+		AbstractParserBuilder c = mutable();
+		c.config.withRDF(rdf);
+		return c;
+	}
+
+	@Override
+	public Sync source(ParserSource source) {
+		AbstractParserBuilder c = mutable();
+		c.config.withSource(source);
+		return c;
+	}
+
+	@Override
+	public Sync source(String iri) {
+		return source(new IRIImpl(iri));
+	}
+
+	@Override
+	public AbstractParserBuilder option(Option option, Object value) {
+		AbstractParserBuilder c = mutable();
+		c.config.withOption(option, value);
+		return c;
+	}
+
+	@Override
+	public Future parseAsync() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async async() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async async(ExecutorService executor) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Parsed parse() {
+		return null;
+	}
+
+	@Override
+	public Sync source(InputStream is) {
+		return source(new InputParserSource(is));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/0e43e6e2/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
deleted file mode 100644
index 141b2f1..0000000
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
+++ /dev/null
@@ -1,188 +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 org.apache.commons.rdf.api.io;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.nio.file.Path;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.fluentparser.Async;
-import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
-import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
-import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
-import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDFOrSyntax;
-import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
-import org.apache.commons.rdf.api.fluentparser.Sync;
-
-@SuppressWarnings({ "unchecked", "rawtypes" })
-public final class AbstractParserFactory implements Cloneable, Serializable, NeedTargetOrRDF, NeedTargetOrRDFOrSyntax,
-		NeedSourceOrBase, NeedSourceBased, OptionalTarget, Sync, Async {
-
-	private static final long serialVersionUID = 1L;
-
-	public AbstractParserFactory(RDF rdf) {
-		
-	}
-	
-	@Override
-	public AbstractParserFactory clone() {
-		try {
-			AbstractParserFactory c = (AbstractParserFactory) super.clone();
-			c.config = (ParserConfigImpl) config.clone();
-			return c;
-		} catch (CloneNotSupportedException e) {
-			throw new IllegalStateException("AbstractParserFactory was not Cloneable", e);
-		}
-	}
-
-	private boolean mutable = false;
-	private ParserConfigImpl config = new ParserConfigImpl();
-
-	@Override
-	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
-		AbstractParserFactory c = mutable();
-		c.config.withSyntax(syntax);
-		return c;
-	}
-
-	private AbstractParserFactory mutable(boolean mutable) {
-		if (this.mutable == mutable) {
-			return this;
-		} else {
-			AbstractParserFactory c = clone();
-			c.mutable = mutable;
-			return c;
-		}
-	}
-
-	private AbstractParserFactory mutable() {
-		return mutable(true);
-	}
-
-	@Override
-	public AbstractParserFactory build() {
-		return mutable(false);
-	}
-
-	@Override
-	public NeedSourceOrBase target(Dataset dataset) {
-		return target(dataset::add);
-
-	}
-
-	@Override
-	public NeedSourceOrBase<Graph> target(Graph graph) {
-		return target(q -> {
-			if (q.getGraphName().isPresent()) {
-				// Only add if q is in default graph
-				graph.add(q.asTriple());
-			}
-		});
-	}
-
-	@Override
-	public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
-		AbstractParserFactory c = mutable();
-		c.config.withTarget(target);
-		return c;
-	}
-
-	@Override
-	public NeedSourceBased base(IRI iri) {
-		AbstractParserFactory c = mutable();
-		c.config.withBase(iri);
-		return c;
-	}
-
-	@Override
-	public NeedSourceBased base(String iri) {
-		AbstractParserFactory c = mutable();
-		c.config.withBase(new IRIImpl(iri));
-		return c;
-	}
-
-	@Override
-	public Sync source(final IRI iri) {
-		return source(new IRIParserSource(iri));
-	}
-
-	public Sync source(Path path) {
-		return source(new PathParserSource(path));
-	}
-
-	@Override
-	public OptionalTarget<Dataset> rdf(RDF rdf) {
-		AbstractParserFactory c = mutable();
-		c.config.withRDF(rdf);
-		return c;
-	}
-
-	@Override
-	public Sync source(ParserSource source) {
-		AbstractParserFactory c = mutable();
-		c.config.withSource(source);
-		return c;
-	}
-
-	@Override
-	public Sync source(String iri) {
-		return source(new IRIImpl(iri));
-	}
-
-	@Override
-	public AbstractParserFactory option(Option option, Object value) {
-		AbstractParserFactory c = mutable();
-		c.config.withOption(option, value);
-		return c;
-	}
-
-	@Override
-	public Future parseAsync() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Async async() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Async async(ExecutorService executor) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Parsed parse() {
-		return null;
-	}
-
-	@Override
-	public Sync source(InputStream is) {
-		return source(new InputParserSource(is));
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/0e43e6e2/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
index fc0da77..9e9a18a 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
@@ -18,6 +18,7 @@ package org.apache.commons.rdf.api.io;
 
 public interface Parser {
 
+	@SuppressWarnings("rawtypes")
 	Parsed parse(ParserConfig config);
 
 }