You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by afs <gi...@git.apache.org> on 2018/03/06 16:42:27 UTC
[GitHub] jena pull request #372: Reformatting + two RiotChars functions.
GitHub user afs opened a pull request:
https://github.com/apache/jena/pull/372
Reformatting + two RiotChars functions.
Minor : reformatting around blank node allocation and two library functions, triggered by checking blank nodes formats.
* `RiotChars.isHexCharLC`
* `RiotChars.isHexCharUC`
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/afs/jena blanknodes
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jena/pull/372.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #372
----
commit 7163eb824724a568df96f508ed31abd38b6f9b80
Author: Andy Seaborne <an...@...>
Date: 2017-12-25T13:08:47Z
Check comments and tidy up.
commit dc8fb522d6b9cacea7440c6aa36f1d9fe02d5a89
Author: Andy Seaborne <an...@...>
Date: 2017-12-28T21:08:46Z
More tests for hexadecimal digits.
----
---
[GitHub] jena pull request #372: Reformatting + two RiotChars functions.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/jena/pull/372
---
[GitHub] jena pull request #372: Reformatting + two RiotChars functions.
Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:
https://github.com/apache/jena/pull/372#discussion_r172582451
--- Diff: jena-arq/src/main/java/org/apache/jena/riot/lang/BlankNodeAllocatorGlobal.java ---
@@ -18,41 +18,39 @@
package org.apache.jena.riot.lang;
-import java.util.HashMap ;
-import java.util.Map ;
+import java.util.HashMap;
+import java.util.Map;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
-/** Allocate blank nodes by creating a randomly generated blank node.
- * This allocator has arbitrary sized state.
+/**
+ * Allocate blank nodes by creating a randomly generated blank node.
+ * This allocator has arbitrary sized internal state needed to record
+ * the label to node mapping.
*/
public class BlankNodeAllocatorGlobal implements BlankNodeAllocator
{
- Map<String, Node> map = new HashMap<>() ;
+ Map<String, Node> map = new HashMap<>();
public BlankNodeAllocatorGlobal() {}
@Override
- public void reset() { map.clear() ; }
+ public void reset() { map.clear(); }
@Override
- public Node alloc(String label)
- {
- Node b = map.get(label) ;
- if ( b == null )
- {
- b = create() ;
- map.put(label, b) ;
+ public Node alloc(String label) {
+ Node b = map.get(label);
--- End diff --
Maybe just `return map.computeIfAbsent(x->create())`?
---
[GitHub] jena pull request #372: Reformatting + two RiotChars functions.
Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:
https://github.com/apache/jena/pull/372#discussion_r172610615
--- Diff: jena-arq/src/main/java/org/apache/jena/riot/lang/BlankNodeAllocatorGlobal.java ---
@@ -18,41 +18,39 @@
package org.apache.jena.riot.lang;
-import java.util.HashMap ;
-import java.util.Map ;
+import java.util.HashMap;
+import java.util.Map;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
-/** Allocate blank nodes by creating a randomly generated blank node.
- * This allocator has arbitrary sized state.
+/**
+ * Allocate blank nodes by creating a randomly generated blank node.
+ * This allocator has arbitrary sized internal state needed to record
+ * the label to node mapping.
*/
public class BlankNodeAllocatorGlobal implements BlankNodeAllocator
{
- Map<String, Node> map = new HashMap<>() ;
+ Map<String, Node> map = new HashMap<>();
public BlankNodeAllocatorGlobal() {}
@Override
- public void reset() { map.clear() ; }
+ public void reset() { map.clear(); }
@Override
- public Node alloc(String label)
- {
- Node b = map.get(label) ;
- if ( b == null )
- {
- b = create() ;
- map.put(label, b) ;
+ public Node alloc(String label) {
+ Node b = map.get(label);
--- End diff --
Good idea. (Some of this code is moderately old.)
---