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:55:03 UTC
[08/17] commons-rdf git commit: new packages fluentparser/fluentwriter
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);