You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by gi...@apache.org on 2024/03/01 22:04:25 UTC

(jena-site) branch asf-site updated: Updated site from main (aec37028bc3390f2bd5bff20ed8e30f18d875aaa)

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

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/jena-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 77a262e23 Updated site from main (aec37028bc3390f2bd5bff20ed8e30f18d875aaa)
77a262e23 is described below

commit 77a262e23136fe072cc24c9462e0a5231b306a4a
Author: jenkins <bu...@apache.org>
AuthorDate: Fri Mar 1 22:04:20 2024 +0000

    Updated site from main (aec37028bc3390f2bd5bff20ed8e30f18d875aaa)
---
 .../documentation/extras/querybuilder/index.html   | 52 +++++++++++++++++++---
 content/index.json                                 |  2 +-
 content/sitemap.xml                                |  2 +-
 3 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/content/documentation/extras/querybuilder/index.html b/content/documentation/extras/querybuilder/index.html
index 5ff50be5d..1e1e59d21 100644
--- a/content/documentation/extras/querybuilder/index.html
+++ b/content/documentation/extras/querybuilder/index.html
@@ -184,7 +184,9 @@
     <nav id="TableOfContents">
   <ul>
     <li><a href="#overview">Overview</a></li>
-    <li><a href="#constructing-expressions">Constructing Expressions</a></li>
+  </ul>
+
+  <ul>
     <li><a href="#update-builder">Update Builder</a></li>
     <li><a href="#where-builder">Where Builder</a></li>
     <li><a href="#template-usage">Template Usage</a></li>
@@ -207,15 +209,51 @@ Query q = sb.build() ;
 WHERE
   { ?s ?p ?o }
 </code></pre>
-<h2 id="constructing-expressions">Constructing Expressions</h2>
+<p>Standard Java variables can be used in the various clauses as long as the datatype has a registered Datatype within Jena.  For example:</p>
+<pre><code>Integer five = Integer.valueof(5);
+SelectBuilder sb = new SelectBuilder()
+    .addVar( &quot;*&quot; )
+    .addWhere( &quot;?s&quot;, &quot;?p&quot;, five );
+
+Query q = sb.build() ;
+</code></pre>
+<p>produces</p>
+<pre><code>SELECT *
+WHERE
+  { ?s ?p &quot;5&quot;^^&lt;http://www.w3.org/2001/XMLSchema#integer&gt; }
+</code></pre>
+<p>Java Collections are properly expanded to RDF collections within the query builder provided there is a registered Datatype for the elements.  Nested collections are expanded. Collections can also be defined with the standard SPARQL shorthand.  So the following produce equivalent queries:</p>
+<pre><code>SelectBuilder sb = new SelectBuilder()
+    .addVar( &quot;*&quot; )
+    .addWhere( &quot;?s&quot;, &quot;?p&quot;, List.of( &quot;a&quot;, &quot;b&quot;, &quot;c&quot;) );
+
+Query q = sb.build() ;
+</code></pre>
+<p>and</p>
+<pre><code>SelectBuilder sb = new SelectBuilder()
+    .addVar( &quot;*&quot; )
+    .addWhere( &quot;?s&quot;, &quot;?p&quot;, &quot;('a' 'b' 'c')&quot; );
+
+Query q = sb.build() ;
+</code></pre>
+<p>It is common to create <code>Var</code> objects and use them in complex queries to make the query more readable.  For example:</p>
+<pre><code>Var node = Var.alloc(&quot;node&quot;);
+Var x = Var.alloc(&quot;x&quot;);
+Var y = Var.alloc(&quot;y&quot;);
+SelectBuilder sb = new SelectBuilder()
+  .addVar(x).addVar(y)
+  .addWhere(node, RDF.type, Namespace.Obst)
+  .addWhere(node, Namespace.x, x)
+  .addWhere(node, Namespace.y, y);
+</code></pre>
+<h1 id="constructing-expressions">Constructing Expressions</h1>
 <p>Expressions are primarily used in <code>filter</code> and <code>bind</code> statements as well as in select clauses.  All the standard expressions are implemented in the <code>ExprFactory</code> class.  An <code>ExprFactory</code> can be retrieved from any Builder by calling the <code>getExprFactory()</code> method.  This will create a Factory that has the same prefix mappings and the query.  An alternative is to construct the <code>ExprFactory</code> directly, this factory will not h [...]
 <pre><code>SelectBuilder builder = new SelectBuilder();
 ExprFactory exprF = builder.getExprFactory()
     .addPrefix( &quot;cf&quot;,
-        &quot;http://vocab.nerc.ac.uk/collection/P07/current/CFSN0023/&quot;)
+        &quot;http://vocab.nerc.ac.uk/collection/P07/current/CFSN0023/&quot;);
 builder.addVar( exprF.floor( ?v ), ?floor )
-
-    .addWhere( ?s, &quot;cf:air_temperature&quot;, ?v )
+    .addWhere( ?s, &quot;cf:air_temperature&quot;, ?v );
 </code></pre>
 <h2 id="update-builder">Update Builder</h2>
 <p>The <code>UpdateBuilder</code> is used to create <code>Update</code>, <code>UpdateDeleteWhere</code> or <code>UpdateRequest</code> objects.  When an <code>UpdateRequest</code> is built is contains a single <code>Update</code> object as defined by the <code>UpdateBuilder</code>.  <code>Update</code> objects can  be added to an UpdateRequest using the <code>appendTo()</code> method.</p>
@@ -322,7 +360,9 @@ WHERE
     <nav id="TableOfContents">
   <ul>
     <li><a href="#overview">Overview</a></li>
-    <li><a href="#constructing-expressions">Constructing Expressions</a></li>
+  </ul>
+
+  <ul>
     <li><a href="#update-builder">Update Builder</a></li>
     <li><a href="#where-builder">Where Builder</a></li>
     <li><a href="#template-usage">Template Usage</a></li>
diff --git a/content/index.json b/content/index.json
index d2d298c50..6bc8f7849 100644
--- a/content/index.json
+++ b/content/index.json
@@ -1 +1 @@
-[{"categories":null,"contents":"This page is historical \u0026ldquo;for information only\u0026rdquo; - there is no Apache release of Eyeball and the code has not been updated for Jena3.\nThe original source code is available. So you\u0026rsquo;ve got Eyeball installed and you\u0026rsquo;ve run it on one of your files, and Eyeball doesn\u0026rsquo;t like it. You\u0026rsquo;re not sure why, or what to do about it. Here\u0026rsquo;s what\u0026rsquo;s going on.\nEyeball inspects your model a [...]
\ No newline at end of file
+[{"categories":null,"contents":"This page is historical \u0026ldquo;for information only\u0026rdquo; - there is no Apache release of Eyeball and the code has not been updated for Jena3.\nThe original source code is available. So you\u0026rsquo;ve got Eyeball installed and you\u0026rsquo;ve run it on one of your files, and Eyeball doesn\u0026rsquo;t like it. You\u0026rsquo;re not sure why, or what to do about it. Here\u0026rsquo;s what\u0026rsquo;s going on.\nEyeball inspects your model a [...]
\ No newline at end of file
diff --git a/content/sitemap.xml b/content/sitemap.xml
index 41cccfa59..12eb975b5 100644
--- a/content/sitemap.xml
+++ b/content/sitemap.xml
@@ -354,7 +354,7 @@
     <lastmod>2021-05-20T19:16:57+01:00</lastmod>
   </url><url>
     <loc>https://jena.apache.org/documentation/extras/querybuilder/</loc>
-    <lastmod>2023-02-05T18:59:30+01:00</lastmod>
+    <lastmod>2023-11-20T10:31:26+01:00</lastmod>
   </url><url>
     <loc>https://jena.apache.org/documentation/io/rdfxml-io.html</loc>
     <lastmod>2023-03-21T21:30:23+00:00</lastmod>