commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [02/10] incubator-commonsrdf git commit: also map JsonLdBlankNode from other unique prefixes
Date Wed, 28 Sep 2016 13:48:09 GMT
also map JsonLdBlankNode from other unique prefixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/be7bfc82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/be7bfc82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/be7bfc82

Branch: refs/heads/jsonld-java
Commit: be7bfc82845d5b79d27f8348e8c021d17d6882e8
Parents: 0928ddb
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Sep 23 17:56:30 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Sep 23 17:56:30 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jsonldjava/JsonLdRDFTermFactory.java      | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/be7bfc82/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
index 88b9bef..310fd24 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
@@ -86,8 +86,14 @@ public final class JsonLdRDFTermFactory implements RDFTermFactory {
 	}
 
 	public Node asJsonLdNode(RDFTerm term) {
-		if (term instanceof JsonLdTerm) {
-			// Return original Node
+		if (term instanceof JsonLdBlankNode) {
+			JsonLdBlankNode jsonLdBlankNode = (JsonLdBlankNode) term;
+			if (jsonLdBlankNode.uniqueReference().startsWith(bnodePrefix)) {
+				// Only return blank nodes 'as is' if they have the same prefix
+				return jsonLdBlankNode.asJsonLdNode();
+			}
+		} else if (term instanceof JsonLdTerm) {
+			// non-Bnodes can always be return as-is
 			return ((JsonLdTerm) term).asJsonLdNode();
 		}
 		if (term instanceof IRI) {


Mime
View raw message