You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commonsrdf.apache.org by wi...@apache.org on 2015/03/27 19:15:34 UTC

[36/50] [abbrv] incubator-commonsrdf git commit: make sure the default blank node id triggers branch in ntriplesString

make sure the default blank node id triggers branch in ntriplesString

Otherwise all "bNNNN" ids would overlap. At least with "b:NNNN" the
identifier is much less likely to have come from a concrete syntax and
will never be emitted directly by ntriplesString, where all identifiers
from concrete syntaxes such as N-Triples itself will be round-tripped in
the simple implementation.

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

Branch: refs/heads/master
Commit: 61f97fc9d54393261215b671b30c032845387bc7
Parents: d13f481
Author: Peter Ansell <p_...@yahoo.com>
Authored: Tue Jan 27 15:09:08 2015 +1100
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Tue Jan 27 15:09:08 2015 +1100

----------------------------------------------------------------------
 .../com/github/commonsrdf/simple/BlankNodeImpl.java   | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/61f97fc9/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java b/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
index 51ebdbf..709a5b9 100644
--- a/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
+++ b/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
@@ -14,6 +14,7 @@
 package com.github.commonsrdf.simple;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.UUID;
@@ -22,19 +23,18 @@ import java.util.concurrent.atomic.AtomicLong;
 import com.github.commonsrdf.api.BlankNode;
 import com.github.commonsrdf.api.Graph;
 
-/** 
+/**
  * A simple implementation of BlankNode.
  *
  */
 class BlankNodeImpl implements BlankNode {
 
-	private static final Charset UTF8 = Charset.forName("UTF-8");
 	private static AtomicLong bnodeCounter = new AtomicLong();
-	private String id;
-	private Optional<Graph> localScope;
+	private final String id;
+	private final Optional<Graph> localScope;
 
 	public BlankNodeImpl() {
-		this(Optional.empty(), "b" + bnodeCounter.incrementAndGet());
+		this(Optional.empty(), "b:" + bnodeCounter.incrementAndGet());
 	}
 
 	public BlankNodeImpl(Optional<Graph> localScope, String id) {
@@ -55,7 +55,9 @@ class BlankNodeImpl implements BlankNode {
 	@Override
 	public String ntriplesString() {
 		if (id.contains(":")) {
-			return "_:u" + UUID.nameUUIDFromBytes(id.getBytes(UTF8));
+			return "_:u"
+					+ UUID.nameUUIDFromBytes(id
+							.getBytes(StandardCharsets.UTF_8));
 		}
 		return "_:" + id;
 	}