forked from apache/jena
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,277 changed files
with
6,549 additions
and
330,892 deletions.
There are no files selected for viewing
Submodule jena-querybuilder
deleted from
dc4dbd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
querybuilder | ||
============ | ||
|
||
Query Builder for Jena. Implementations of Ask, Construct and Select builders that allow developers to create queries without resorting to StringBuilders or similar solutions. | ||
|
||
Each of the builders has a series of methods to define the query. Each method returns the builder for easy chaing. The example: | ||
|
||
``` | ||
SelectBuilder sb = new SelectBuilder() | ||
.addVar( "*" ) | ||
.addWhere( "?s", "?o", "?p" ); | ||
Query q = sb.build(); | ||
``` | ||
|
||
produces `SELECT * WHERE { ?s ?o ?p . }` | ||
|
||
Template Usage | ||
============== | ||
|
||
In addition to making it easier to build valid queries the QueryBuilder has a clone method. Using this a developer can create as "Template" query and add to it as necessary. | ||
|
||
for example using the above query as the "template" the this code: | ||
|
||
``` | ||
SelectBuilder sb2 = sb.clone(); | ||
sb2.addPrefix( "foaf", "http://xmlns.com/foaf/0.1/" ).addWhere( ?s, RDF.type, foaf:Person) | ||
``` | ||
|
||
produces `PREFIX foaf: http://xmlns.com/foaf/0.1/ SELECT * WHERE { ?s ?o ?p . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> foaf:person . }` | ||
|
||
Prepared Statement Usage | ||
======================== | ||
|
||
The query builders have the ability to replace variables with other values. This can be | ||
|
||
``` | ||
SelectBuilder sb = new SelectBuilder() | ||
.addVar( "*" ) | ||
.addWhere( "?s", "?o", "?p" ); | ||
sb.setVar( Var.alloc( "?p" ), NodeFactory.createURI( "http://xmlns.com/foaf/0.1/Person" ) | ||
Query q = sb.build(); | ||
``` | ||
|
||
produces `SELECT * WHERE { ?s ?o <http://xmlns.com/foaf/0.1/Person> . }` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>jena-querybuilder</artifactId> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>apache-jena-libs</artifactId> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.xenei</groupId> | ||
<artifactId>junit-contracts</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<name>Apache Jena Query Builder- jena-querybulder</name> | ||
<inceptionYear>2014</inceptionYear> | ||
<organization> | ||
<name>The Apache Software Foundation</name> | ||
<url>http://www.apache.org/</url> | ||
</organization> | ||
<properties> | ||
|
||
</properties> | ||
<scm> | ||
<!-- <url>https://svn.apache.org/repos/asf/jena/Experimental/jena-common/</url> | ||
<connection>scm:svn:https://svn.apache.org/repos/asf/jena/Experimental/jena-common/</connection> | ||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/jena/Experimental/jena-common/</developerConnection> | ||
--> | ||
</scm> | ||
<parent> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-extras</artifactId> | ||
<relativePath>..</relativePath> | ||
<version>2.12.2-SNAPSHOT</version> | ||
</parent> | ||
<description>A utility package to simplify the building of ARQ queries in code. Provides both a simple builder interface for queries as well as simple prepared statement processing.</description> | ||
</project> |
Oops, something went wrong.