This is an automated email from the ASF dual-hosted git repository.

afs pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git

commit 69de6286772fd90d5b24dd7f43c6d411a1c453c7
Author: Andy Seaborne <[email protected]>
AuthorDate: Wed Jun 24 21:32:44 2026 +0100

    G.listMembers
---
 .../src/main/java/org/apache/jena/system/G.java    | 25 ++++++++++++++++++++--
 .../apache/jena/arq/junit/manifest/Manifest.java   |  4 ++--
 .../org/apache/jena/fuseki/build/BuildLib.java     | 18 +++-------------
 .../org/apache/jena/shacl/engine/ShaclPaths.java   |  4 ++--
 .../org/apache/jena/shacl/parser/Constraints.java  |  2 +-
 5 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/jena-arq/src/main/java/org/apache/jena/system/G.java 
b/jena-arq/src/main/java/org/apache/jena/system/G.java
index 538f41bd33..da96d5d472 100644
--- a/jena-arq/src/main/java/org/apache/jena/system/G.java
+++ b/jena-arq/src/main/java/org/apache/jena/system/G.java
@@ -505,16 +505,23 @@ public class G {
     }
 
     // ---- RDF list.
+    // Most ways to call GList.xxx
 
-    /** Return a java list for an RDF list of data. */
+    /** @deprecated use {@link #listMembers(Graph, Node)} */
+    @Deprecated(forRemoval = true)
     public static List<Node> rdfList(Graph graph, Node node) {
+        return listMembers(graph, node);
+    }
+
+    /** Return a java list of an RDF list of data. */
+    public static List<Node> listMembers(Graph graph, Node node) {
         Objects.requireNonNull(graph, "graph");
         Objects.requireNonNull(node, "node");
         List<Node> nodes = GList.members(graph, node);
         return nodes;
     }
 
-    /** Return a the length of an RDF list. */
+    /** Return a the length of an RDF list. Return -1 if it is not a list. */
     public static int listLength(Graph graph, Node node) {
         Objects.requireNonNull(graph, "graph");
         Objects.requireNonNull(node, "node");
@@ -523,6 +530,20 @@ public class G {
         return (int)GList.listLength(graph, node);
     }
 
+    /**
+     * Test whether node looks like a list (RDF Collection).
+     * The test is whether node is {@code rdf:nil}
+     * or has exactly one of each of {@code rdf:first}
+     * and {@code rdf:next}.
+     * Multiple occurrences of {@code rdf:first}
+     * or {@code rdf:next} are considered errors.
+     */
+    public static boolean isList(Graph graph, Node node) {
+        Objects.requireNonNull(graph, "graph");
+        Objects.requireNonNull(node, "node");
+        return GList.isListNode(graph, node);
+    }
+
     /**
      * Return a java list where the {@code node} is an RDF list of nodes,
      * of if the node is not a list, return the node as a list of one.
diff --git 
a/jena-arq/src/test/java/org/apache/jena/arq/junit/manifest/Manifest.java 
b/jena-arq/src/test/java/org/apache/jena/arq/junit/manifest/Manifest.java
index 92e31fb0f8..edebe55c6d 100644
--- a/jena-arq/src/test/java/org/apache/jena/arq/junit/manifest/Manifest.java
+++ b/jena-arq/src/test/java/org/apache/jena/arq/junit/manifest/Manifest.java
@@ -110,7 +110,7 @@ public class Manifest
         Node entriesNode = G.getZeroOrOneSP(manifestGraph, manifest, 
TestManifest.entries.asNode());
         if ( entriesNode == null )
             return;
-        List<Node> items = G.rdfList(manifestGraph, entriesNode);
+        List<Node> items = G.listMembers(manifestGraph, entriesNode);
 
         List<Node> missingEntries = items.stream().filter(entry -> ! 
G.contains(manifestGraph, entry, null, null)).toList();
         if ( ! missingEntries.isEmpty() ) {
@@ -167,7 +167,7 @@ public class Manifest
         if ( ! r.isBlank() )
             return;
         // Blank node - assumed to be a list.
-        List<Node> includes = G.rdfList(manifestGraph, r);
+        List<Node> includes = G.listMembers(manifestGraph, r);
         for ( Node inc : includes ) {
             if ( inc.isBlank() || inc.isURI() ) {
                 parseOneIncludesList(inc);
diff --git 
a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/BuildLib.java
 
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/BuildLib.java
index 5d595d9c16..9d194cdac1 100644
--- 
a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/BuildLib.java
+++ 
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/BuildLib.java
@@ -48,8 +48,6 @@ import org.apache.jena.sparql.engine.binding.BindingFactory;
 import org.apache.jena.sparql.exec.QueryExec;
 import org.apache.jena.sparql.exec.QueryExecBuilder;
 import org.apache.jena.sparql.exec.RowSet;
-import org.apache.jena.sparql.util.graph.GNode;
-import org.apache.jena.sparql.util.graph.GraphList;
 import org.apache.jena.system.G;
 import org.apache.jena.vocabulary.RDFS;
 
@@ -108,23 +106,13 @@ import org.apache.jena.vocabulary.RDFS;
         List<Node> results = new ArrayList<>();
 
         nodes.forEach(node->{
-            List<Node> members = listMembers(graph, node);
-            if ( members != null )
-                results.addAll(members);
-            else
-                results.add(node);
+            // Returns a List.of(node) if not an RDF List.
+            List<Node> values = G.getOneOrList(graph, node);
+            results.addAll(values);
         });
         return results;
     }
 
-    private static List<Node> listMembers(Graph graph, Node node) {
-        GNode gnode = new GNode(graph, node);
-        if ( ! GraphList.isListNode(gnode) )
-            return null;
-        List<Node> list = GraphList.members(gnode);
-        return list;
-    }
-
     // Node presentation
 
     /*package*/ static String displayStr(Graph graph, Node n) {
diff --git 
a/jena-shacl/src/main/java/org/apache/jena/shacl/engine/ShaclPaths.java 
b/jena-shacl/src/main/java/org/apache/jena/shacl/engine/ShaclPaths.java
index 2f6cb23328..c26f2e79b1 100644
--- a/jena-shacl/src/main/java/org/apache/jena/shacl/engine/ShaclPaths.java
+++ b/jena-shacl/src/main/java/org/apache/jena/shacl/engine/ShaclPaths.java
@@ -102,7 +102,7 @@ public class ShaclPaths {
             return PathFactory.pathLink(node);
 
         if ( isList(graph, node) ) {
-            List<Node> nodes = G.rdfList(graph, node);
+            List<Node> nodes = G.listMembers(graph, node);
             if ( nodes.isEmpty() )
                 throw new ShaclParseException("Empty list for path sequence");
             Path path = null;
@@ -158,7 +158,7 @@ public class ShaclPaths {
                 if ( ! isList(graph, x) ) {
                     throw new ShaclParseException("Not a list for path 
alternativePath");
                 }
-                List<Node> nodes = G.rdfList(graph, x);
+                List<Node> nodes = G.listMembers(graph, x);
                 Path path = null;
                 for ( Node n : nodes ) {
                     Path p = path(graph, n);
diff --git 
a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java 
b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java
index 465a8a042d..e3fd4f3e67 100644
--- a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java
+++ b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/Constraints.java
@@ -305,7 +305,7 @@ public class Constraints {
 
     /** Return the list elements of an RDF list start at {@code node} */
     private static List<Node> list(Graph g, Node node) {
-        return G.rdfList(g, node);
+        return G.listMembers(g, node);
     }
 
     private static List<String> listString(Graph g, Node node) {

Reply via email to