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 2017/02/10 16:55:19 UTC

[17/45] commons-rdf git commit: COMMONSRDF-54: overloads of RDF4J#asRDFTerm

COMMONSRDF-54: overloads of RDF4J#asRDFTerm


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

Branch: refs/heads/COMMONSRDF-47
Commit: 94fb7c6cfaf3c18a8456756758d1beb45983c583
Parents: 42363cf
Author: Guohui Xiao <gh...@gmail.com>
Authored: Wed Jan 25 18:56:09 2017 +0100
Committer: Guohui Xiao <gh...@gmail.com>
Committed: Wed Jan 25 18:57:29 2017 +0100

----------------------------------------------------------------------
 .../org/apache/commons/rdf/rdf4j/RDF4J.java     | 53 ++++++++++++++++++++
 1 file changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/94fb7c6c/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4J.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4J.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4J.java
index 2d39bbd..b6d2544 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4J.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4J.java
@@ -37,6 +37,7 @@ import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.api.TripleLike;
 import org.apache.commons.rdf.rdf4j.impl.InternalRDF4JFactory;
 import org.eclipse.rdf4j.model.BNode;
+import org.eclipse.rdf4j.model.Literal;
 import org.eclipse.rdf4j.model.Model;
 import org.eclipse.rdf4j.model.Resource;
 import org.eclipse.rdf4j.model.Statement;
@@ -233,6 +234,58 @@ public final class RDF4J implements RDF {
     }
 
     /**
+     *
+     * Adapt a RDF4J
+     * {@link org.eclipse.rdf4j.model.BNode} as a Commons RDF
+     * {@link org.apache.commons.rdf.api.BlankNode}
+     * <p>
+     * For the purpose of {@link BlankNode} equivalence, this method will use an
+     * internal salt UUID that is unique per instance of {@link RDF4J}.
+     * <p>
+     * <strong>NOTE:</strong> If combining RDF4J values from multiple
+     * repositories or models, then their {@link BNode}s may have the same
+     * {@link BNode#getID()}, which with this method would become equivalent
+     * according to {@link BlankNode#equals(Object)} and
+     * {@link BlankNode#uniqueReference()}, unless a separate {@link RDF4J}
+     * instance is used per RDF4J repository/model.
+     *
+     * @param value
+     *            The RDF4J {@link BNode} to convert.
+     * @return A {@link RDF4JBlankNode} that corresponds to the RDF4J BNode
+     */
+    public RDF4JBlankNode asRDFTerm(final BNode value) {
+        return rdf4j.createBlankNodeImpl(value, salt);
+    }
+
+    /**
+     *
+     * Adapt a RDF4J
+     * {@link org.eclipse.rdf4j.model.Literal} as a Commons RDF
+     * {@link org.apache.commons.rdf.api.Literal}
+     * <p>
+     * @param value
+     *            The RDF4J {@link Literal} to convert.
+     * @return A {@link RDF4JLiteral} that corresponds to the RDF4J literal
+     */
+    public RDF4JLiteral asRDFTerm(final Literal value) {
+        return rdf4j.createLiteralImpl(value);
+    }
+
+    /**
+     *
+     * Adapt a RDF4J
+     * {@link org.eclipse.rdf4j.model.IRI} as a Commons RDF
+     * {@link org.apache.commons.rdf.api.IRI}
+     * <p>
+     * @param value
+     *            The RDF4J {@link Value} to convert.
+     * @return A {@link RDF4JIRI} that corresponds to the RDF4J IRI
+     */
+    public RDF4JIRI asRDFTerm(final org.eclipse.rdf4j.model.IRI value) {
+        return rdf4j.createIRIImpl(value);
+    }
+
+    /**
      * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
      * <p>
      * The value will be of the same kind as the term, e.g. a