|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fuberlin.wiwiss.ng4j.triql.TriQLQuery
public class TriQLQuery
A TriQL
query. The data source can be a NamedGraphSet
, or any RDF document
given in the query's FROM clause.
A query is executed by creating a
new TriQLQuery instance and calling its getResults()
method.
The static exec(String)
and exec(NamedGraphSet, String)
methods
combine both steps into a single call.
TriQL query results are iterators over a list of maps. The map's keys are the names of the result variables. The map's values are the corresponding result values.
The class provides methods for assembling a query programmatically. This
is an alternative to creating the query from a String. For example, one can
add prefix bindings using the setPrefix(String, String)
method,
instead of the ususal USING ... FOR clauses.
Constructor Summary | |
---|---|
TriQLQuery()
Constructor for assembling a TriQL query programmatically. |
|
TriQLQuery(NamedGraphSet dataSource,
String queryString)
Creates a new query instance whose data source is a NamedGraphSet. |
|
TriQLQuery(String queryString)
Creates a new query instance whose data source is an URL given in the query's FROM clause, or is passed later to the setSource(de.fuberlin.wiwiss.ng4j.NamedGraphSet)
or setSourceURL(java.lang.String) method. |
Method Summary | |
---|---|
void |
addBoundVar(String name)
TODO: Is this necessary? We can find them all by going throug the patterns. |
void |
addConstraint(Constraint constraint)
Programmatically adds a constraint to the query. |
void |
addGraphPattern(GraphPattern graphPattern)
Programmatically adds a graph pattern to the query. |
void |
addResultVar(String name)
Programmatically adds a result variable. |
static Iterator |
exec(NamedGraphSet dataSource,
String queryString)
Convenience method for quick query execution. |
static Iterator |
exec(String queryString)
Convenience method for quick query execution. |
URL |
getBaseURL()
|
List |
getBoundVars()
|
List |
getConstraints()
|
List |
getGraphPatterns()
|
Map |
getPreboundVariableValues()
Gets all pre-bound variables. |
PrefixMapping |
getPrefixMapping()
|
Iterator |
getResults()
Executes the query and delivers results as an iterator over maps. |
List |
getResultsAsList()
Executes the query and delivers results as a list of maps. |
List |
getResultVars()
|
NamedGraphSet |
getSource()
|
String |
getSourceURL()
|
void |
prebindVariableValue(String variable,
Node value)
Fixes the value of a variable before executing the query. |
void |
setBaseURL(URL baseURL)
If the FROM URI of the query is relative, it will be evaluated relative to this base URI. |
void |
setPrefix(String prefix,
String expansion)
Programmatically adds a prefix mapping. |
void |
setSource(NamedGraphSet source)
Programmatically sets the NamedGraphSet on which the query will run. |
void |
setSourceURL(String sourceURL)
Programmatically sets the source URL. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TriQLQuery(NamedGraphSet dataSource, String queryString)
dataSource
- The NamedGraphSet on which to execute the queryqueryString
- The TriQL querypublic TriQLQuery(String queryString)
setSource(de.fuberlin.wiwiss.ng4j.NamedGraphSet)
or setSourceURL(java.lang.String)
method.
queryString
- The TriQL querypublic TriQLQuery()
Method Detail |
---|
public static Iterator exec(NamedGraphSet dataSource, String queryString)
Convenience method for quick query execution. A NamedGraphSet is the data source.
Iterator results = TriQLQuery.exec(mySet, "SELECT ?x, ?y FROM ...")
is equivalent to
TriQLQuery query = new TriQLQuery(mySet, "SELECT ?x, ?y FROM ..."); Iterator results = query.getResults();
dataSource
- The datasourcequeryString
- The TriQL query to be executed
getResults()
public static Iterator exec(String queryString)
Convenience method for quick query execution. The data source is an URL which must be given in the query's FROM clause.
Iterator results = TriQLQuery.exec("SELECT ?x, ?y FROM ...")
is equivalent to
TriQLQuery query = new TriQLQuery("SELECT ?x, ?y FROM ..."); Iterator results = query.getResults();
queryString
- The TriQL query to be executed
getResults()
public Iterator getResults()
Node
s.
public List getResultsAsList()
Node
s.
public void setBaseURL(URL baseURL)
baseURL
- public URL getBaseURL()
public void setSource(NamedGraphSet source)
source
- public NamedGraphSet getSource()
public void setSourceURL(String sourceURL)
sourceURL
- public String getSourceURL()
public void addResultVar(String name)
name
- public List getResultVars()
public void addBoundVar(String name)
name
- public List getBoundVars()
public void addGraphPattern(GraphPattern graphPattern)
graphPattern
- public List getGraphPatterns()
public void addConstraint(Constraint constraint)
constraint
- public List getConstraints()
public void setPrefix(String prefix, String expansion)
prefix
- The namespace prefix to be addedexpansion
- The full namespace URIpublic PrefixMapping getPrefixMapping()
public void prebindVariableValue(String variable, Node value)
variable
- A variable namevalue
- The value required for that variablegetPreboundVariableValues()
public Map getPreboundVariableValues()
Node
sprebindVariableValue(java.lang.String, com.hp.hpl.jena.graph.Node)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |