Author: claude Date: Sun Oct 12 18:34:51 2014 New Revision: 1631237 URL: http://svn.apache.org/r1631237 Log: Added documentation for Extras and QueryBuilder
Added: jena/site/trunk/content/documentation/extras/ jena/site/trunk/content/documentation/extras/index.mdtext jena/site/trunk/content/documentation/extras/querybuilder/ jena/site/trunk/content/documentation/extras/querybuilder/index.mdtext Modified: jena/site/trunk/content/documentation/ (props changed) jena/site/trunk/content/documentation/index.mdtext Propchange: jena/site/trunk/content/documentation/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sun Oct 12 18:34:51 2014 @@ -0,0 +1 @@ +.project Added: jena/site/trunk/content/documentation/extras/index.mdtext URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/extras/index.mdtext?rev=1631237&view=auto ============================================================================== --- jena/site/trunk/content/documentation/extras/index.mdtext (added) +++ jena/site/trunk/content/documentation/extras/index.mdtext Sun Oct 12 18:34:51 2014 @@ -0,0 +1,9 @@ +Title: Jena Extras - Extra packages for Jena development. + +Jena Extra modules are modules that provide utilities and larger packages that make Apache Jena +development or usage easier but that do not fall within the standard Jena framework. + +## Sub Packages + +- [Query Builder](querybuilder/index.html) + Added: jena/site/trunk/content/documentation/extras/querybuilder/index.mdtext URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/extras/querybuilder/index.mdtext?rev=1631237&view=auto ============================================================================== --- jena/site/trunk/content/documentation/extras/querybuilder/index.mdtext (added) +++ jena/site/trunk/content/documentation/extras/querybuilder/index.mdtext Sun Oct 12 18:34:51 2014 @@ -0,0 +1,52 @@ +Title: Jena Query Builder - A query builder for Jena. + + +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> . }` + Modified: jena/site/trunk/content/documentation/index.mdtext URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/index.mdtext?rev=1631237&r1=1631236&r2=1631237&view=diff ============================================================================== --- jena/site/trunk/content/documentation/index.mdtext (original) +++ jena/site/trunk/content/documentation/index.mdtext Sun Oct 12 18:34:51 2014 @@ -22,4 +22,6 @@ sections. * [JDBC](./jdbc/) - a SPARQL over JDBC driver framework * [SQL DB](./sdb/) - constructing persistent Jena models using SQL databases as the storage layer * [Tools](./tools/) - various command-line tools and utilities to help developers manage RDF data and other aspects of Jena +* [Extras](./extras/) - various modules that provide utilities and larger packages that make Apache Jena development or usage easier but that do not fall within the standard Jena framework. +