You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2017/10/30 14:57:17 UTC
[17/22] commons-rdf git commit: Module names, directory names,
and artifact names should match.
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/Triple.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/Triple.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/Triple.java
new file mode 100644
index 0000000..36bd187
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/Triple.java
@@ -0,0 +1,129 @@
+/**
+ * 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;
+
+import java.util.Objects;
+
+/**
+ * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple" >RDF-1.1
+ * Triple</a>, as defined by
+ * <a href= "http://www.w3.org/TR/rdf11-concepts/#section-triples" >RDF-1.1 Concepts and
+ * Abstract Syntax</a>, a W3C Recommendation published on 25 February 2014.
+ * <p>
+ * A <code>Triple</code> object in Commons RDF is considered
+ * <strong>immutable</strong>, that is, over its life time it will have
+ * consistent behaviour for its {@link #equals(Object)}, and the {@link RDFTerm}
+ * instances returned from {@link #getSubject()}, {@link #getPredicate()} and
+ * {@link #getObject()} will have consistent {@link RDFTerm#equals(Object)}
+ * behaviour.
+ * <p>
+ * Note that <code>Triple</code> methods are not required to return object
+ * identical (<code>==</code>) instances as long as they are equivalent
+ * according to {@link RDFTerm#equals(Object)}. Specialisations of
+ * <code>Triple</code> may provide additional methods that are documented to be
+ * mutable.
+ * <p>
+ * <code>Triple</code> methods are <strong>thread-safe</strong>, however
+ * specialisations may provide additional methods that are documented to not be
+ * thread-safe.
+ * <p>
+ * <code>Triple</code>s can be safely used in hashing collections like
+ * {@link java.util.HashSet} and {@link java.util.HashMap}.
+ * <p>
+ * Any <code>Triple</code> can be used interchangeably across Commons RDF
+ * implementations.
+ *
+ * @see Quad
+ * @see RDF#createTriple(BlankNodeOrIRI,IRI,RDFTerm)
+ * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple" >RDF-1.1
+ * Triple</a>
+ */
+public interface Triple extends TripleLike {
+
+ /**
+ * The subject of this triple, which may be either a {@link BlankNode} or an
+ * {@link IRI}, which are represented in Commons RDF by the interface
+ * {@link BlankNodeOrIRI}.
+ *
+ * @return The subject {@link BlankNodeOrIRI} of this triple.
+ * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-subject">RDF-1.1
+ * Triple subject</a>
+ */
+ @Override
+ BlankNodeOrIRI getSubject();
+
+ /**
+ * The predicate {@link IRI} of this triple.
+ *
+ * @return The predicate {@link IRI} of this triple.
+ * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-predicate">RDF-1.1
+ * Triple predicate</a>
+ */
+ @Override
+ IRI getPredicate();
+
+ /**
+ * The object of this triple, which may be either a {@link BlankNode}, an
+ * {@link IRI}, or a {@link Literal}, which are represented in Commons RDF
+ * by the interface {@link RDFTerm}.
+ *
+ * @return The object {@link RDFTerm} of this triple.
+ * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-object">RDF-1.1
+ * Triple object</a>
+ */
+ @Override
+ RDFTerm getObject();
+
+ /**
+ * Check it this Triple is equal to another Triple.
+ * <p>
+ * Two Triples are equal if and only if their {@link #getSubject()},
+ * {@link #getPredicate()} and {@link #getObject()} are equal.
+ * </p>
+ * <p>
+ * Implementations MUST also override {@link #hashCode()} so that two equal
+ * Triples produce the same hash code.
+ * </p>
+ *
+ * @param other
+ * Another object
+ * @return true if other is a Triple and is equal to this
+ * @see Object#equals(Object)
+ */
+ @Override
+ public boolean equals(Object other);
+
+ /**
+ * Calculate a hash code for this Triple.
+ * <p>
+ * The returned hash code MUST be equal to the result of
+ * {@link Objects#hash(Object...)} with the arguments {@link #getSubject()},
+ * {@link #getPredicate()}, {@link #getObject()}.
+ * <p>
+ * This method MUST be implemented in conjunction with
+ * {@link #equals(Object)} so that two equal {@link Triple}s produce the
+ * same hash code.
+ *
+ * @return a hash code value for this Triple.
+ * @see Object#hashCode()
+ * @see Objects#hash(Object...)
+ */
+ @Override
+ public int hashCode();
+
+}
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/TripleLike.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/TripleLike.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/TripleLike.java
new file mode 100644
index 0000000..1427f17
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/TripleLike.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rdf.api;
+
+/**
+ * A generalised "triple-like" interface, extended by {@link Triple} and
+ * {@link Quad}.
+ * <p>
+ * A TripleLike statement has at least a {@link #getSubject()},
+ * {@link #getPredicate()} and {@link #getObject()}, but unlike a {@link Triple}
+ * does not have a formalised {@link Triple#equals(Object)} or
+ * {@link Triple#hashCode()} semantics and is not required to be
+ * <em>immutable</em> or <em>thread-safe</em>. This interfaced can also be used
+ * for <em>generalised triples</em> (e.g. a {@link BlankNode} as predicate).
+ * <p>
+ * Implementations should specialise which specific {@link RDFTerm} types they
+ * return by overriding {@link #getSubject()}, {@link #getPredicate()} and
+ * {@link #getObject()}.
+ *
+ *
+ * @since 0.3.0-incubating
+ * @see Triple
+ * @see Quad
+ * @see QuadLike
+ */
+public interface TripleLike {
+
+ /**
+ * The subject of this statement.
+ *
+ * @return The subject, typically an {@link IRI} or {@link BlankNode}.
+ */
+ RDFTerm getSubject();
+
+ /**
+ * The predicate of this statement.
+ *
+ * @return The predicate, typically an {@link IRI}.
+ */
+ RDFTerm getPredicate();
+
+ /**
+ * The object of this statement.
+ *
+ * @return The object, typically an {@link IRI}, {@link BlankNode} or
+ * {@link Literal}.
+ */
+ RDFTerm getObject();
+}
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/W3CRDFSyntax.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/W3CRDFSyntax.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/W3CRDFSyntax.java
new file mode 100644
index 0000000..6b88955
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/W3CRDFSyntax.java
@@ -0,0 +1,206 @@
+/**
+ * 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;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * W3C RDF 1.1 serialization syntax.
+ * <p>
+ * This defines the W3C standardized RDF 1.1 syntaxes like {@link #TURTLE} and
+ * {@link #JSONLD}. Note the existence of other RDF syntaxes that are not
+ * included here, e.g. <a href="http://www.w3.org/TeamSubmission/n3/">N3</a> and
+ * <a href="https://en.wikipedia.org/wiki/TriX_%28syntax%29">TriX</a>.
+ * <p>
+ * This class is package-protected, its static constants are exposed through
+ * {@link RDFSyntax}.
+ *
+ * @see RDFSyntax#w3cSyntaxes()
+ * @see <a href="https://www.w3.org/TR/rdf11-primer/#section-graph-syntax">RDF
+ * 1.1 Primer</a>
+ * @see org.apache.commons.rdf.experimental.RDFParser
+ */
+class W3CRDFSyntax implements RDFSyntax {
+
+ /**
+ * IRI representing a <a href="https://www.w3.org/ns/formats/">W3C RDF
+ * format</a>.
+ */
+ private final static class FormatIRI implements IRI {
+ private static String BASE = "http://www.w3.org/ns/formats/";
+ private final String format;
+
+ private FormatIRI(final String format) {
+ this.format = format;
+ }
+
+ @Override
+ public String getIRIString() {
+ return BASE + format;
+ }
+
+ @Override
+ public String ntriplesString() {
+ return "<" + getIRIString() + ">";
+ }
+
+ @Override
+ public String toString() {
+ return ntriplesString();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || !(obj instanceof IRI)) {
+ return false;
+ }
+ final IRI other = (IRI) obj;
+ return getIRIString().equals(other.getIRIString());
+ }
+
+ @Override
+ public int hashCode() {
+ return getIRIString().hashCode();
+ }
+ }
+
+
+ static final RDFSyntax JSONLD, TURTLE, NQUADS, NTRIPLES, RDFA, RDFXML, TRIG;
+ static final Set<RDFSyntax> syntaxes;
+
+ static {
+ // Initialize within static block to avoid inserting nulls
+ JSONLD = new W3CRDFSyntax("JSON-LD", "JSON-LD 1.0", "application/ld+json", ".jsonld", true);
+ TURTLE = new W3CRDFSyntax("Turtle", "RDF 1.1 Turtle", "text/turtle", ".ttl", false);
+ NQUADS = new W3CRDFSyntax("N-Quads", "RDF 1.1 N-Quads", "application/n-quads", ".nq", true);
+ NTRIPLES = new W3CRDFSyntax("N-Triples", "RDF 1.1 N-Triples", "application/n-triples", ".nt", false);
+ RDFXML = new W3CRDFSyntax("RDF_XML", "RDF 1.1 XML Syntax", "application/rdf+xml", ".rdf", false);
+ TRIG = new W3CRDFSyntax("TriG", "RDF 1.1 TriG", "application/trig", ".trig", true);
+ RDFA = new W3CRDFSyntax("RDFa", "HTML+RDFa 1.1", "text/html", ".html", false) {
+ private Set<String> types = Collections.unmodifiableSet(new LinkedHashSet<>(
+ Arrays.asList("text/html", "application/xhtml+xml")));
+ private Set<String> extensions = Collections.unmodifiableSet(new LinkedHashSet<>(
+ Arrays.asList(".html", ".xhtml")));
+ @Override
+ public Set<String> mediaTypes() {
+ return types;
+ }
+ @Override
+ public Set<String> fileExtensions() {
+ return extensions;
+ }
+ };
+ syntaxes = Collections.unmodifiableSet(new LinkedHashSet<>(
+ Arrays.asList(JSONLD, NQUADS, NTRIPLES, RDFA, RDFXML, TRIG, TURTLE)));
+ }
+
+ private final String title;
+
+ private final String mediaType;
+
+ private final String fileExtension;
+
+ private final boolean supportsDataset;
+
+ private final String name;
+
+ private final IRI iri;
+
+ private W3CRDFSyntax(String name, String title, String mediaType, String fileExtension, boolean supportsDataset) {
+ this.name = name;
+ this.title = title;
+ this.mediaType = mediaType.toLowerCase(Locale.ROOT);
+ this.fileExtension = fileExtension.toLowerCase(Locale.ROOT);
+ this.supportsDataset = supportsDataset;
+ this.iri = new FormatIRI(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * {@link W3CRDFSyntax} always defines media type in lower case, so
+ * {@link String#toLowerCase(Locale)} need not be called.
+ *
+ */
+ @Override
+ public String mediaType() {
+ return mediaType;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * {@link W3CRDFSyntax} always defines file extensions in lower case, so
+ * {@link String#toLowerCase(Locale)} need not be called.
+ *
+ */
+ @Override
+ public String fileExtension() {
+ return fileExtension;
+ }
+
+ @Override
+ public boolean supportsDataset() {
+ return supportsDataset;
+ }
+
+ @Override
+ public String title() {
+ return title;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public IRI iri() {
+ return iri;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof RDFSyntax)) {
+ return false;
+ }
+ RDFSyntax other = (RDFSyntax) obj;
+ return mediaType.equals(other.mediaType().toLowerCase(Locale.ROOT));
+ }
+
+ @Override
+ public int hashCode() {
+ return mediaType.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/package-info.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/package-info.java
new file mode 100644
index 0000000..5099cb0
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/package-info.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.
+ */
+/**
+ * Commons RDF, a common library of RDF 1.1 concepts.
+ * <p>
+ * The core <a href="http://www.w3.org/TR/rdf11-concepts/">RDF 1.1 concepts</a>
+ * are represented by corresponding interfaces:
+ * <p>
+ * A {@link org.apache.commons.rdf.api.Graph} is a collection of
+ * {@link org.apache.commons.rdf.api.Triple}s, which have a <em>subject</em>,
+ * <em>predicate</em> and <em>object</em> of
+ * {@link org.apache.commons.rdf.api.RDFTerm}s. The three types of RDF terms are
+ * {@link org.apache.commons.rdf.api.IRI},
+ * {@link org.apache.commons.rdf.api.Literal} and
+ * {@link org.apache.commons.rdf.api.BlankNode}.
+ * <p>
+ * Implementations of this API should provide an
+ * {@link org.apache.commons.rdf.api.RDF} to facilitate creation of these
+ * objects.
+ * <p>
+ * All the {@link org.apache.commons.rdf.api.RDFTerm} objects are immutable,
+ * while a {@link org.apache.commons.rdf.api.Graph} MAY be mutable (e.g. support
+ * methods like {@link org.apache.commons.rdf.api.Graph#add(Triple)}).
+ * <p>
+ * {@link org.apache.commons.rdf.api.RDFSyntax} enumerates the W3C standard RDF
+ * 1.1 syntaxes and their media types.
+ * <p>
+ * For further documentation and contact details, see the
+ * <a href="http://commonsrdf.incubator.apache.org/">Commons RDF</a> web site.
+ *
+ */
+package org.apache.commons.rdf.api;
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/RDFParser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/RDFParser.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/RDFParser.java
new file mode 100644
index 0000000..1b4ac2e
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/RDFParser.java
@@ -0,0 +1,485 @@
+/**
+ * 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.experimental;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.util.Optional;
+import java.util.concurrent.Future;
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.BlankNode;
+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.RDFSyntax;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.Triple;
+
+/**
+ * Parse an RDF source into a target (e.g. a Graph/Dataset).
+ * <h2>Experimental</h2> This interface (and its implementations) should be
+ * considered <strong>at risk</strong>; they might change or be removed in the
+ * next minor update of Commons RDF. It may move to the the
+ * {@link org.apache.commons.rdf.api} package when it has stabilized.
+ * <h2>Description</h2>
+ * <p>
+ * This interface follows the
+ * <a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder pattern</a>,
+ * allowing to set parser settings like {@link #contentType(RDFSyntax)} and
+ * {@link #base(IRI)}. A caller MUST call one of the <code>source</code> methods
+ * (e.g. {@link #source(IRI)}, {@link #source(Path)},
+ * {@link #source(InputStream)}), and MUST call one of the <code>target</code>
+ * methods (e.g. {@link #target(Consumer)}, {@link #target(Dataset)},
+ * {@link #target(Graph)}) before calling {@link #parse()} on the returned
+ * RDFParser - however methods can be called in any order.
+ * <p>
+ * The call to {@link #parse()} returns a {@link Future}, allowing asynchronous
+ * parse operations. Callers are recommended to check {@link Future#get()} to
+ * ensure parsing completed successfully, or catch exceptions thrown during
+ * parsing.
+ * <p>
+ * Setting a method that has already been set will override any existing value
+ * in the returned builder - regardless of the parameter type (e.g.
+ * {@link #source(IRI)} will override a previous {@link #source(Path)}. Settings
+ * can be unset by passing <code>null</code> - note that this may require
+ * casting, e.g. <code>contentType( (RDFSyntax) null )</code> to undo a previous
+ * call to {@link #contentType(RDFSyntax)}.
+ * <p>
+ * It is undefined if a RDFParser is mutable or thread-safe, so callers should
+ * always use the returned modified RDFParser from the builder methods. The
+ * builder may return itself after modification, or a cloned builder with the
+ * modified settings applied. Implementations are however encouraged to be
+ * immutable, thread-safe and document this. As an example starting point, see
+ * <code>org.apache.commons.rdf.simple.AbstractRDFParser</code>.
+ * <p>
+ * Example usage:
+ * </p>
+ *
+ * <pre>
+ * Graph g1 = rDFTermFactory.createGraph();
+ * new ExampleRDFParserBuilder().source(Paths.get("/tmp/graph.ttl")).contentType(RDFSyntax.TURTLE).target(g1).parse()
+ * .get(30, TimeUnit.Seconds);
+ * </pre>
+ *
+ */
+public interface RDFParser {
+
+ /**
+ * The result of {@link RDFParser#parse()} indicating parsing completed.
+ * <p>
+ * This is a marker interface that may be subclassed to include parser
+ * details, e.g. warning messages or triple counts.
+ */
+ public interface ParseResult {
+ }
+
+ /**
+ * Specify which {@link RDF} to use for generating {@link RDFTerm}s.
+ * <p>
+ * This option may be used together with {@link #target(Graph)} to override
+ * the implementation's default factory and graph.
+ * <p>
+ * <strong>Warning:</strong> Using the same {@link RDF} for multiple
+ * {@link #parse()} calls may accidentally merge {@link BlankNode}s having
+ * the same label, as the parser may use the
+ * {@link RDF#createBlankNode(String)} method from the parsed blank node
+ * labels.
+ *
+ * @see #target(Graph)
+ * @param rdfTermFactory
+ * {@link RDF} to use for generating RDFTerms.
+ * @return An {@link RDFParser} that will use the specified rdfTermFactory
+ */
+ RDFParser rdfTermFactory(RDF rdfTermFactory);
+
+ /**
+ * Specify the content type of the RDF syntax to parse.
+ * <p>
+ * This option can be used to select the RDFSyntax of the source, overriding
+ * any <code>Content-Type</code> headers or equivalent.
+ * <p>
+ * The character set of the RDFSyntax is assumed to be
+ * {@link StandardCharsets#UTF_8} unless overridden within the document
+ * (e.g. {@code <?xml version="1.0" encoding="iso-8859-1"?>} in
+ * {@link RDFSyntax#RDFXML}).
+ * <p>
+ * This method will override any contentType set with
+ * {@link #contentType(String)}.
+ *
+ * @see #contentType(String)
+ * @param rdfSyntax
+ * An {@link RDFSyntax} to parse the source according to, e.g.
+ * {@link RDFSyntax#TURTLE}.
+ * @throws IllegalArgumentException
+ * If this RDFParser does not support the specified RDFSyntax.
+ * @return An {@link RDFParser} that will use the specified content type.
+ */
+ RDFParser contentType(RDFSyntax rdfSyntax) throws IllegalArgumentException;
+
+ /**
+ * Specify the content type of the RDF syntax to parse.
+ * <p>
+ * This option can be used to select the RDFSyntax of the source, overriding
+ * any <code>Content-Type</code> headers or equivalent.
+ * <p>
+ * The content type MAY include a <code>charset</code> parameter if the RDF
+ * media types permit it; the default charset is
+ * {@link StandardCharsets#UTF_8} unless overridden within the document.
+ * <p>
+ * This method will override any contentType set with
+ * {@link #contentType(RDFSyntax)}.
+ *
+ * @see #contentType(RDFSyntax)
+ * @param contentType
+ * A content-type string, e.g. <code>application/ld+json</code>
+ * or <code>text/turtle;charset="UTF-8"</code> as specified by
+ * <a href="https://tools.ietf.org/html/rfc7231#section-3.1.1.1">
+ * RFC7231</a>.
+ * @return An {@link RDFParser} that will use the specified content type.
+ * @throws IllegalArgumentException
+ * If the contentType has an invalid syntax, or this RDFParser
+ * does not support the specified contentType.
+ */
+ RDFParser contentType(String contentType) throws IllegalArgumentException;
+
+ /**
+ * Specify a {@link Graph} to add parsed triples to.
+ * <p>
+ * If the source supports datasets (e.g. the {@link #contentType(RDFSyntax)}
+ * set has {@link RDFSyntax#supportsDataset} is true)), then only quads in
+ * the <em>default graph</em> will be added to the Graph as {@link Triple}s.
+ * <p>
+ * It is undefined if any triples are added to the specified {@link Graph}
+ * if {@link #parse()} throws any exceptions. (However implementations are
+ * free to prevent this using transaction mechanisms or similar). If
+ * {@link Future#get()} does not indicate an exception, the parser
+ * implementation SHOULD have inserted all parsed triples to the specified
+ * graph.
+ * <p>
+ * Calling this method will override any earlier targets set with
+ * {@link #target(Graph)}, {@link #target(Consumer)} or
+ * {@link #target(Dataset)}.
+ * <p>
+ * The default implementation of this method calls {@link #target(Consumer)}
+ * with a {@link Consumer} that does {@link Graph#add(Triple)} with
+ * {@link Quad#asTriple()} if the quad is in the default graph.
+ *
+ * @param graph
+ * The {@link Graph} to add triples to.
+ * @return An {@link RDFParser} that will insert triples into the specified
+ * graph.
+ */
+ default RDFParser target(final Graph graph) {
+ return target(q -> {
+ if (!q.getGraphName().isPresent()) {
+ graph.add(q.asTriple());
+ }
+ });
+ }
+
+ /**
+ * Specify a {@link Dataset} to add parsed quads to.
+ * <p>
+ * It is undefined if any quads are added to the specified {@link Dataset}
+ * if {@link #parse()} throws any exceptions. (However implementations are
+ * free to prevent this using transaction mechanisms or similar). On the
+ * other hand, if {@link #parse()} does not indicate an exception, the
+ * implementation SHOULD have inserted all parsed quads to the specified
+ * dataset.
+ * <p>
+ * Calling this method will override any earlier targets set with
+ * {@link #target(Graph)}, {@link #target(Consumer)} or
+ * {@link #target(Dataset)}.
+ * <p>
+ * The default implementation of this method calls {@link #target(Consumer)}
+ * with a {@link Consumer} that does {@link Dataset#add(Quad)}.
+ *
+ * @param dataset
+ * The {@link Dataset} to add quads to.
+ * @return An {@link RDFParser} that will insert triples into the specified
+ * dataset.
+ */
+ default RDFParser target(final Dataset dataset) {
+ return target(dataset::add);
+ }
+
+ /**
+ * Specify a consumer for parsed quads.
+ * <p>
+ * The quads will include triples in all named graphs of the parsed source,
+ * including any triples in the default graph. When parsing a source format
+ * which do not support datasets, all quads delivered to the consumer will
+ * be in the default graph (e.g. their {@link Quad#getGraphName()} will be
+ * as {@link Optional#empty()}), while for a source
+ * <p>
+ * It is undefined if any quads are consumed if {@link #parse()} throws any
+ * exceptions. On the other hand, if {@link #parse()} does not indicate an
+ * exception, the implementation SHOULD have produced all parsed quads to
+ * the specified consumer.
+ * <p>
+ * Calling this method will override any earlier targets set with
+ * {@link #target(Graph)}, {@link #target(Consumer)} or
+ * {@link #target(Dataset)}.
+ * <p>
+ * The consumer is not assumed to be thread safe - only one
+ * {@link Consumer#accept(Object)} is delivered at a time for a given
+ * {@link RDFParser#parse()} call.
+ * <p>
+ * This method is typically called with a functional consumer, for example:
+ *
+ * <pre>
+ * {@code
+ * List<Quad> quads = new ArrayList<Quad>;
+ * parserBuilder.target(quads::add).parse();
+ * }
+ * </pre>
+ *
+ * @param consumer
+ * A {@link Consumer} of {@link Quad}s
+ * @return An {@link RDFParser} that will call the consumer for into the
+ * specified dataset.
+ */
+ RDFParser target(Consumer<Quad> consumer);
+
+ /**
+ * Specify a base IRI to use for parsing any relative IRI references.
+ * <p>
+ * Setting this option will override any protocol-specific base IRI (e.g.
+ * <code>Content-Location</code> header) or the {@link #source(IRI)} IRI,
+ * but does not override any base IRIs set within the source document (e.g.
+ * <code>@base</code> in Turtle documents).
+ * <p>
+ * If the source is in a syntax that does not support relative IRI
+ * references (e.g. {@link RDFSyntax#NTRIPLES}), setting the
+ * <code>base</code> has no effect.
+ * <p>
+ * This method will override any base IRI set with {@link #base(String)}.
+ *
+ * @see #base(String)
+ * @param base
+ * An absolute IRI to use as a base.
+ * @return An {@link RDFParser} that will use the specified base IRI.
+ */
+ RDFParser base(IRI base);
+
+ /**
+ * Specify a base IRI to use for parsing any relative IRI references.
+ * <p>
+ * Setting this option will override any protocol-specific base IRI (e.g.
+ * <code>Content-Location</code> header) or the {@link #source(IRI)} IRI,
+ * but does not override any base IRIs set within the source document (e.g.
+ * <code>@base</code> in Turtle documents).
+ * <p>
+ * If the source is in a syntax that does not support relative IRI
+ * references (e.g. {@link RDFSyntax#NTRIPLES}), setting the
+ * <code>base</code> has no effect.
+ * <p>
+ * This method will override any base IRI set with {@link #base(IRI)}.
+ *
+ * @see #base(IRI)
+ * @param base
+ * An absolute IRI to use as a base.
+ * @return An {@link RDFParser} that will use the specified base IRI.
+ * @throws IllegalArgumentException
+ * If the base is not a valid absolute IRI string
+ */
+ RDFParser base(String base) throws IllegalArgumentException;
+
+ /**
+ * Specify a source {@link InputStream} to parse.
+ * <p>
+ * The source set will not be read before the call to {@link #parse()}.
+ * <p>
+ * The InputStream will not be closed after parsing. The InputStream does
+ * not need to support {@link InputStream#markSupported()}.
+ * <p>
+ * The parser might not consume the complete stream (e.g. an RDF/XML parser
+ * may not read beyond the closing tag of
+ * <code></rdf:Description></code>).
+ * <p>
+ * The {@link #contentType(RDFSyntax)} or {@link #contentType(String)}
+ * SHOULD be set before calling {@link #parse()}.
+ * <p>
+ * The character set is assumed to be {@link StandardCharsets#UTF_8} unless
+ * the {@link #contentType(String)} specifies otherwise or the document
+ * declares its own charset (e.g. RDF/XML with a
+ * <code><?xml encoding="iso-8859-1"></code> header).
+ * <p>
+ * The {@link #base(IRI)} or {@link #base(String)} MUST be set before
+ * calling {@link #parse()}, unless the RDF syntax does not permit relative
+ * IRIs (e.g. {@link RDFSyntax#NTRIPLES}).
+ * <p>
+ * This method will override any source set with {@link #source(IRI)},
+ * {@link #source(Path)} or {@link #source(String)}.
+ *
+ * @param inputStream
+ * An InputStream to consume
+ * @return An {@link RDFParser} that will use the specified source.
+ */
+ RDFParser source(InputStream inputStream);
+
+ /**
+ * Specify a source file {@link Path} to parse.
+ * <p>
+ * The source set will not be read before the call to {@link #parse()}.
+ * <p>
+ * The {@link #contentType(RDFSyntax)} or {@link #contentType(String)}
+ * SHOULD be set before calling {@link #parse()}.
+ * <p>
+ * The character set is assumed to be {@link StandardCharsets#UTF_8} unless
+ * the {@link #contentType(String)} specifies otherwise or the document
+ * declares its own charset (e.g. RDF/XML with a
+ * <code><?xml encoding="iso-8859-1"></code> header).
+ * <p>
+ * The {@link #base(IRI)} or {@link #base(String)} MAY be set before calling
+ * {@link #parse()}, otherwise {@link Path#toUri()} will be used as the base
+ * IRI.
+ * <p>
+ * This method will override any source set with {@link #source(IRI)},
+ * {@link #source(InputStream)} or {@link #source(String)}.
+ *
+ * @param file
+ * A Path for a file to parse
+ * @return An {@link RDFParser} that will use the specified source.
+ */
+ RDFParser source(Path file);
+
+ /**
+ * Specify an absolute source {@link IRI} to retrieve and parse.
+ * <p>
+ * The source set will not be read before the call to {@link #parse()}.
+ * <p>
+ * If this builder does not support the given IRI protocol (e.g.
+ * <code>urn:uuid:ce667463-c5ab-4c23-9b64-701d055c4890</code>), this method
+ * should succeed, while the {@link #parse()} should throw an
+ * {@link IOException}.
+ * <p>
+ * The {@link #contentType(RDFSyntax)} or {@link #contentType(String)} MAY
+ * be set before calling {@link #parse()}, in which case that type MAY be
+ * used for content negotiation (e.g. <code>Accept</code> header in HTTP),
+ * and SHOULD be used for selecting the RDFSyntax.
+ * <p>
+ * The character set is assumed to be {@link StandardCharsets#UTF_8} unless
+ * the protocol's equivalent of <code>Content-Type</code> specifies
+ * otherwise or the document declares its own charset (e.g. RDF/XML with a
+ * <code><?xml encoding="iso-8859-1"></code> header).
+ * <p>
+ * The {@link #base(IRI)} or {@link #base(String)} MAY be set before calling
+ * {@link #parse()}, otherwise the source IRI will be used as the base IRI.
+ * <p>
+ * This method will override any source set with {@link #source(Path)},
+ * {@link #source(InputStream)} or {@link #source(String)}.
+ *
+ * @param iri
+ * An IRI to retrieve and parse
+ * @return An {@link RDFParser} that will use the specified source.
+ */
+ RDFParser source(IRI iri);
+
+ /**
+ * Specify an absolute source IRI to retrieve and parse.
+ * <p>
+ * The source set will not be read before the call to {@link #parse()}.
+ * <p>
+ * If this builder does not support the given IRI (e.g.
+ * <code>urn:uuid:ce667463-c5ab-4c23-9b64-701d055c4890</code>), this method
+ * should succeed, while the {@link #parse()} should throw an
+ * {@link IOException}.
+ * <p>
+ * The {@link #contentType(RDFSyntax)} or {@link #contentType(String)} MAY
+ * be set before calling {@link #parse()}, in which case that type MAY be
+ * used for content negotiation (e.g. <code>Accept</code> header in HTTP),
+ * and SHOULD be used for selecting the RDFSyntax.
+ * <p>
+ * The character set is assumed to be {@link StandardCharsets#UTF_8} unless
+ * the protocol's equivalent of <code>Content-Type</code> specifies
+ * otherwise or the document declares its own charset (e.g. RDF/XML with a
+ * <code><?xml encoding="iso-8859-1"></code> header).
+ * <p>
+ * The {@link #base(IRI)} or {@link #base(String)} MAY be set before calling
+ * {@link #parse()}, otherwise the source IRI will be used as the base IRI.
+ * <p>
+ * This method will override any source set with {@link #source(Path)},
+ * {@link #source(InputStream)} or {@link #source(IRI)}.
+ *
+ * @param iri
+ * An IRI to retrieve and parse
+ * @return An {@link RDFParser} that will use the specified source.
+ * @throws IllegalArgumentException
+ * If the base is not a valid absolute IRI string
+ *
+ */
+ RDFParser source(String iri) throws IllegalArgumentException;
+
+ /**
+ * Parse the specified source.
+ * <p>
+ * A source method (e.g. {@link #source(InputStream)}, {@link #source(IRI)},
+ * {@link #source(Path)}, {@link #source(String)} or an equivalent subclass
+ * method) MUST have been called before calling this method, otherwise an
+ * {@link IllegalStateException} will be thrown.
+ * <p>
+ * A target method (e.g. {@link #target(Consumer)},
+ * {@link #target(Dataset)}, {@link #target(Graph)} or an equivalent
+ * subclass method) MUST have been called before calling parse(), otherwise
+ * an {@link IllegalStateException} will be thrown.
+ * <p>
+ * It is undefined if this method is thread-safe, however the
+ * {@link RDFParser} may be reused (e.g. setting a different source) as soon
+ * as the {@link Future} has been returned from this method.
+ * <p>
+ * The RDFParser SHOULD perform the parsing as an asynchronous operation,
+ * and return the {@link Future} as soon as preliminary checks (such as
+ * validity of the {@link #source(IRI)} and {@link #contentType(RDFSyntax)}
+ * settings) have finished. The future SHOULD not mark
+ * {@link Future#isDone()} before parsing is complete. A synchronous
+ * implementation MAY be blocking on the <code>parse()</code> call and
+ * return a Future that is already {@link Future#isDone()}.
+ * <p>
+ * The returned {@link Future} contains a {@link ParseResult}.
+ * Implementations may subclass this interface to provide any parser
+ * details, e.g. list of warnings. <code>null</code> is a possible return
+ * value if no details are available, but parsing succeeded.
+ * <p>
+ * If an exception occurs during parsing, (e.g. {@link IOException} or
+ * <code>org.apache.commons.rdf.simple.experimental.RDFParseException</code>),
+ * it should be indicated as the
+ * {@link java.util.concurrent.ExecutionException#getCause()} in the
+ * {@link java.util.concurrent.ExecutionException} thrown on
+ * {@link Future#get()}.
+ *
+ * @return A Future that will return the populated {@link Graph} when the
+ * parsing has finished.
+ * @throws IOException
+ * If an error occurred while starting to read the source (e.g.
+ * file not found, unsupported IRI protocol). Note that IO
+ * errors during parsing would instead be the
+ * {@link java.util.concurrent.ExecutionException#getCause()} of
+ * the {@link java.util.concurrent.ExecutionException} thrown on
+ * {@link Future#get()}.
+ * @throws IllegalStateException
+ * If the builder is in an invalid state, e.g. a
+ * <code>source</code> has not been set.
+ */
+ Future<? extends ParseResult> parse() throws IOException, IllegalStateException;
+}
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/package-info.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/package-info.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/package-info.java
new file mode 100644
index 0000000..5b9e489
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/experimental/package-info.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.
+ */
+/**
+ * Experimental Commons RDF features.
+ * <p>
+ * Interfaces/classes in this package should be considered <strong>at
+ * risk</strong>; they might change or be removed in the next minor update of
+ * Commons RDF.
+ * <p>
+ * When class/interface has stabilized, it will move to the
+ * {@link org.apache.commons.rdf.api} package.
+ * <ul>
+ * <li>{@link RDFParser} - a builder-like interface for parsing RDF to a
+ * {@link org.apache.commons.rdf.api.Graph} or
+ * {@link org.apache.commons.rdf.api.Dataset}.</li>
+ * </ul>
+ */
+package org.apache.commons.rdf.experimental;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/resources/META-INF/LICENSE b/commons-rdf-api/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/commons-rdf-api/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/resources/META-INF/NOTICE b/commons-rdf-api/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..6147016
--- /dev/null
+++ b/commons-rdf-api/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,5 @@
+Apache Commons RDF
+Copyright 2015-2016 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/site/resources/profile.jacoco b/commons-rdf-api/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/site/resources/profile.japicmp
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/site/resources/profile.japicmp b/commons-rdf-api/src/site/resources/profile.japicmp
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/d59203ce/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
new file mode 100644
index 0000000..c123cdc
--- /dev/null
+++ b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
@@ -0,0 +1,208 @@
+/**
+ * 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;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+/**
+ * Abstract test class for the BlankNode interface.
+ */
+public abstract class AbstractBlankNodeTest {
+
+ /**
+ * This method must be overridden by the implementing test to create a
+ * {@link BlankNode} to be tested.
+ * <p>
+ * Each call to this method must provide a new, unique BlankNode.
+ *
+ * @return {@link RDF} instance to be tested.
+ */
+ protected abstract BlankNode getBlankNode();
+
+ /**
+ * Gets a new blank node object based on the given identifier.
+ * <p>
+ * Subsequent calls to this method during a single test with the same
+ * identifier must return BlankNode objects that are equals and have the
+ * same hashCode. The objects returned from successive calls during a single
+ * test may be the same object, or they may be different objects.
+ * </p>
+ *
+ * @param identifier
+ * The identifier to use as the reference for creating the blank
+ * node that is returned.
+ * @return A new blank node based on the
+ */
+ protected abstract BlankNode getBlankNode(String identifier);
+
+ /**
+ * Test method for {@link BlankNode#uniqueReference()}.
+ */
+ @Test
+ public final void testInternalIdentifier() {
+ final BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String uniqueReference() {
+ return null;
+ }
+ };
+ final BlankNode testAutomatic1 = getBlankNode();
+ final BlankNode testAutomatic2 = getBlankNode();
+ final BlankNode testManual3a = getBlankNode("3");
+ final BlankNode testManual3b = getBlankNode("3");
+ final BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull.uniqueReference(), testAutomatic1.uniqueReference());
+ assertNotEquals(testAutomatic1.uniqueReference(), testNull.uniqueReference());
+ assertNotEquals(testNull.uniqueReference(), testManual3a.uniqueReference());
+ assertNotEquals(testManual3a.uniqueReference(), testNull.uniqueReference());
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1.uniqueReference(), testAutomatic1.uniqueReference());
+ assertEquals(testAutomatic2.uniqueReference(), testAutomatic2.uniqueReference());
+ assertNotEquals(testAutomatic1.uniqueReference(), testAutomatic2.uniqueReference());
+ assertNotEquals(testAutomatic2.uniqueReference(), testAutomatic1.uniqueReference());
+ assertNotEquals(testAutomatic1.uniqueReference(), testManual3a.uniqueReference());
+ assertEquals(testManual3b.uniqueReference(), testManual3a.uniqueReference());
+ assertNotEquals(testManual3a.uniqueReference(), testManual4.uniqueReference());
+ }
+
+ /**
+ * Test method for {@link BlankNode#equals(java.lang.Object)}.
+ */
+ @Test
+ public final void testEquals() {
+ final BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String uniqueReference() {
+ return null;
+ }
+ };
+ final BlankNode testAutomatic1 = getBlankNode();
+ final BlankNode testAutomatic2 = getBlankNode();
+ final BlankNode testManual3a = getBlankNode("3");
+ final BlankNode testManual3b = getBlankNode("3");
+ final BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull, testAutomatic1);
+ assertNotEquals(testAutomatic1, testNull);
+ assertNotEquals(testNull, testManual3a);
+ assertNotEquals(testManual3a, testNull);
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1, testAutomatic1);
+ assertEquals(testAutomatic2, testAutomatic2);
+ assertNotEquals(testAutomatic1, testAutomatic2);
+ assertNotEquals(testAutomatic2, testAutomatic1);
+ assertNotEquals(testAutomatic1, testManual3a);
+ assertEquals(testManual3b, testManual3a);
+ assertNotEquals(testManual3a, testManual4);
+ }
+
+ /**
+ * Test method for {@link BlankNode#hashCode()}.
+ */
+ @Test
+ public final void testHashCode() {
+ final BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String uniqueReference() {
+ return null;
+ }
+ };
+ final BlankNode testAutomatic1 = getBlankNode();
+ final BlankNode testAutomatic2 = getBlankNode();
+ final BlankNode testManual3a = getBlankNode("3");
+ final BlankNode testManual3b = getBlankNode("3");
+ final BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull.hashCode(), testAutomatic1.hashCode());
+ assertNotEquals(testAutomatic1.hashCode(), testNull.hashCode());
+ assertNotEquals(testNull.hashCode(), testManual3a.hashCode());
+ assertNotEquals(testManual3a.hashCode(), testNull.hashCode());
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1.hashCode(), testAutomatic1.hashCode());
+ assertEquals(testAutomatic2.hashCode(), testAutomatic2.hashCode());
+ assertNotEquals(testAutomatic1.hashCode(), testAutomatic2.hashCode());
+ assertNotEquals(testAutomatic2.hashCode(), testAutomatic1.hashCode());
+ assertNotEquals(testAutomatic1.hashCode(), testManual3a.hashCode());
+ assertEquals(testManual3b.hashCode(), testManual3a.hashCode());
+ assertNotEquals(testManual3a.hashCode(), testManual4.hashCode());
+ }
+
+ /**
+ * Test method for {@link RDFTerm#ntriplesString()}.
+ */
+ @Test
+ public final void testNtriplesString() {
+ final BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String uniqueReference() {
+ return null;
+ }
+ };
+ final BlankNode testAutomatic1 = getBlankNode();
+ final BlankNode testAutomatic2 = getBlankNode();
+ final BlankNode testManual3a = getBlankNode("3");
+ final BlankNode testManual3b = getBlankNode("3");
+ final BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull.ntriplesString(), testAutomatic1.ntriplesString());
+ assertNotEquals(testAutomatic1.ntriplesString(), testNull.ntriplesString());
+ assertNotEquals(testNull.ntriplesString(), testManual3a.ntriplesString());
+ assertNotEquals(testManual3a.ntriplesString(), testNull.ntriplesString());
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1.ntriplesString(), testAutomatic1.ntriplesString());
+ assertEquals(testAutomatic2.ntriplesString(), testAutomatic2.ntriplesString());
+ assertNotEquals(testAutomatic1.ntriplesString(), testAutomatic2.ntriplesString());
+ assertNotEquals(testAutomatic2.ntriplesString(), testAutomatic1.ntriplesString());
+ assertNotEquals(testAutomatic1.ntriplesString(), testManual3a.ntriplesString());
+ assertEquals(testManual3b.ntriplesString(), testManual3a.ntriplesString());
+ assertNotEquals(testManual3a.ntriplesString(), testManual4.ntriplesString());
+ }
+
+}