com.hp.hpl.jena.rdql
Class Query

java.lang.Object
  extended bycom.hp.hpl.jena.rdql.Query

public class Query
extends java.lang.Object

The data structure for a query. There are two ways of creating a query - use the parser to turn a string description of the query into the executable form, and the programmatic way (the parser is calling the programmatic operations driven by the quyery string). The declarative approach of passing in a string is preferred. Once a query is built, it can be passed to a query engine.

Version:
$Id: Query.java,v 1.9 2003/07/15 13:26:58 andy_seaborne Exp $
Author:
Andy Seaborne
See Also:
QueryEngine, QueryResults

Field Summary
 long buildTime
           
 long executeTime
           
 long loadTime
           
 long parseTime
           
 
Constructor Summary
Query()
          Create a blank query.
Query(java.lang.String s)
          Create a query from the given string by calling the parser.
 
Method Summary
 void addBoundVar(java.lang.String varName)
          Programmatic API operation
 void addConstraint(Constraint c)
          Programmatic API operation
 void addResultVar(java.lang.String varName)
          Programmatic API operation
 void addTriplePattern(Node s, Node p, Node o)
           
 void addTriplePattern(Triple t)
          Programmatic API operation
static QueryResults exec(java.lang.String queryString)
          Convenience function to parse and execute a query.
static QueryResults exec(java.lang.String queryString, Model model)
          Convenience function to parse and execute a query against an existing model.
static QueryResults exec(java.lang.String queryString, java.lang.String dataURL)
          Convenience function to parse and execute a query against a remote model.
 java.util.List getBoundVars()
          Programmatic API operation
 java.lang.String getPrefix(java.lang.String prefix)
          Lookup a prefix for this query, including the default prefixes
 java.util.List getResultVars()
          Programmatic API operation
 Model getSource()
          Return the model that this query executes against.
 java.lang.String getSourceURL()
           
 java.util.List getTriplePatterns()
          Programmatic API operation
 void setPrefix(java.lang.String prefix, java.lang.String expansion)
          Set a prefix for this query
 void setSource(Model m)
          The data target for the query as a Jena model.
 void setSourceURL(java.lang.String s)
          Location of the source for the data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parseTime

public long parseTime

buildTime

public long buildTime

loadTime

public long loadTime

executeTime

public long executeTime
Constructor Detail

Query

public Query(java.lang.String s)
Create a query from the given string by calling the parser. After it has been created, an application should set the data source, then call the QueryEngine.

Parameters:
s - The query string
Throws:
QueryException - Thrown when a parse error occurs

Query

public Query()
Create a blank query. The application is expected to complete the query parts needed by calling the various "add" operations later,

Method Detail

exec

public static QueryResults exec(java.lang.String queryString)
Convenience function to parse and execute a query.

Parameters:
queryString - The query: should include FROM clause to provide the data
Throws:
QueryException - Runtime exception

exec

public static QueryResults exec(java.lang.String queryString,
                                Model model)
Convenience function to parse and execute a query against an existing model.

Parameters:
queryString - The query: the FROM clause will be overridden
model - The data
Throws:
QueryException - Runtime exception

exec

public static QueryResults exec(java.lang.String queryString,
                                java.lang.String dataURL)
Convenience function to parse and execute a query against a remote model. The remote data is loaded into the local application.

Parameters:
queryString - The query: the FROM clause will be overridden
dataURL - The remote data source
Throws:
QueryException - Runtime exception

setSource

public void setSource(Model m)
The data target for the query as a Jena model. Applications must call this whther using the parser or not.


getSource

public Model getSource()
Return the model that this query executes against.


setSourceURL

public void setSourceURL(java.lang.String s)
Location of the source for the data. If the model is not set, then the QueryEngine will attempt to load the data from this URL.


getSourceURL

public java.lang.String getSourceURL()

getResultVars

public java.util.List getResultVars()
Programmatic API operation


addResultVar

public void addResultVar(java.lang.String varName)
Programmatic API operation


getBoundVars

public java.util.List getBoundVars()
Programmatic API operation


addBoundVar

public void addBoundVar(java.lang.String varName)
Programmatic API operation


addConstraint

public void addConstraint(Constraint c)
Programmatic API operation


addTriplePattern

public void addTriplePattern(Triple t)
Programmatic API operation


addTriplePattern

public void addTriplePattern(Node s,
                             Node p,
                             Node o)

getTriplePatterns

public java.util.List getTriplePatterns()
Programmatic API operation


setPrefix

public void setPrefix(java.lang.String prefix,
                      java.lang.String expansion)
Set a prefix for this query


getPrefix

public java.lang.String getPrefix(java.lang.String prefix)
Lookup a prefix for this query, including the default prefixes


toString

public java.lang.String toString()


Copyright © 2001-2003 Hewlett-Packard. All Rights Reserved.