com.hp.hpl.jena.rdf.query
Class Query

java.lang.Object
  |
  +--com.hp.hpl.jena.rdf.query.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.

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 addConstraint(Constraint c)
          Programmatic API operation
 void addResultVar(java.lang.String varName)
          Programmatic API operation
 void addTriplePattern(TriplePattern tp)
          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.
 Log getLog()
          Get the current log
 boolean getLogging()
          See if we are logging
 java.util.List getResultVars()
          Programmatic API operation
 Model getSource()
          Return the model that this query executes against.
 java.lang.String getSourceURL()
           
 void setLog(Log newLog)
          Set the log destination.
 void setLogging(boolean loggingSwitch)
          Switch for logging.
 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:
String - 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
datatURL - 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

addConstraint

public void addConstraint(Constraint c)
Programmatic API operation

addTriplePattern

public void addTriplePattern(TriplePattern tp)
Programmatic API operation

setLog

public void setLog(Log newLog)
Set the log destination. By default the log does to the Jena system log

getLog

public Log getLog()
Get the current log

setLogging

public void setLogging(boolean loggingSwitch)
Switch for logging. This is in addition to log levels. Default is off

getLogging

public boolean getLogging()
See if we are logging

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2001 Hewlett-Packard. All Rights Reserved.