You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/10/05 12:56:12 UTC

[2/5] jena git commit: Code for recursively unwrapping a DatasetGraphWrapped

Code for recursively unwrapping a DatasetGraphWrapped

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

Branch: refs/heads/master
Commit: f19fe84bdc98d4fdd30253de8c39438858d2e559
Parents: e8f6f29
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Oct 5 10:22:10 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Oct 5 10:22:10 2015 +0100

----------------------------------------------------------------------
 .../apache/jena/sparql/core/DatasetGraphWrapper.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f19fe84b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
index dbe725e..a54f5b1 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWrapper.java
@@ -35,10 +35,21 @@ public class DatasetGraphWrapper implements DatasetGraph, Sync
     
     /** Return the DatasetGraph being wrapped. */
     public final DatasetGraph getWrapped() { 
-        // Maybe should be "getQueryExecutionDatasetGraph"
         return get() ;
     }
     
+    /** Recursively unwrap a DatasetGraphWrapped.
+     * 
+     * @return the first found {@link DatasetGraph} that is not an instance of {@link DatasetGraphWrapper}
+     */
+    public final DatasetGraph getBase() { 
+        DatasetGraph dsgw = dsg ;
+        while (dsgw instanceof DatasetGraphWrapper) {
+            dsgw = ((DatasetGraphWrapper)dsg).getWrapped() ;
+        }
+        return dsgw ;
+    }
+
     /** The dataset to use for redirection - can be overridden.
      *  It is also guarantee that this is called only once per
      *  delegated call.  Changes to the wrapped object can be