本文整理匯總了Java中org.openrdf.query.TupleQuery.setIncludeInferred方法的典型用法代碼示例。如果您正苦於以下問題:Java TupleQuery.setIncludeInferred方法的具體用法?Java TupleQuery.setIncludeInferred怎麽用?Java TupleQuery.setIncludeInferred使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openrdf.query.TupleQuery
的用法示例。
在下文中一共展示了TupleQuery.setIncludeInferred方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeSelectQuery
import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
public static TupleQueryResult executeSelectQuery(final Repository repo, final String query,
final QueryLanguage ql) throws OpenRDFException {
RepositoryConnection cxn;
if (repo instanceof BigdataSailRepository) {
cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
} else {
cxn = repo.getConnection();
}
try {
final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
tupleQuery.setIncludeInferred(true /* includeInferred */);
return tupleQuery.evaluate();
} finally {
// close the repository connection
cxn.close();
}
}
示例2: executeSelectQuery
import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
public static TupleQueryResult executeSelectQuery(Repository repo, String query,
QueryLanguage ql) throws OpenRDFException {
RepositoryConnection cxn;
if (repo instanceof BigdataSailRepository) {
cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
} else {
cxn = repo.getConnection();
}
try {
final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
tupleQuery.setIncludeInferred(true /* includeInferred */);
return tupleQuery.evaluate();
} finally {
// close the repository connection
cxn.close();
}
}
示例3: getSelect
import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
public static final <T> T getSelect( QueryExecutor<T> query,
RepositoryConnection rc, boolean dobindings ) throws RepositoryException,
MalformedQueryException, QueryEvaluationException {
String sparql = processNamespaces( dobindings ? query.getSparql()
: query.bindAndGetSparql(), query.getNamespaces() );
ValueFactory vfac = new ValueFactoryImpl();
TupleQuery tq = rc.prepareTupleQuery( QueryLanguage.SPARQL, sparql );
if ( null != query.getContext() ) {
DatasetImpl dataset = new DatasetImpl();
dataset.addDefaultGraph( query.getContext() );
tq.setDataset( dataset );
}
if ( dobindings ) {
tq.setIncludeInferred( query.usesInferred() );
query.setBindings( tq, vfac );
}
TupleQueryResult rslt = tq.evaluate();
query.start( rslt.getBindingNames() );
while ( rslt.hasNext() ) {
query.handleTuple( rslt.next(), vfac );
}
query.done();
rslt.close();
return query.getResults();
}
示例4: testSPARQLQueryWithDefaultInferred
import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
@Test
public void testSPARQLQueryWithDefaultInferred()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 2 ";
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setIncludeInferred(true);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
BindingSet bindingSet1 = results.next();
Value sV1 = bindingSet1.getValue("s");
Value pV1 = bindingSet1.getValue("p");
Value oV1 = bindingSet1.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#BabylonGeodata", sV1.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV1.stringValue());
Assert.assertEquals("0", oV1.stringValue());
results.close();
}