本文整理了Java中org.apache.jena.query.ResultSet.nextSolution
方法的一些代码示例,展示了ResultSet.nextSolution
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultSet.nextSolution
方法的具体详情如下:
包路径:org.apache.jena.query.ResultSet
类名称:ResultSet
方法名:nextSolution
[英]Moves onto the next result (legacy - use .next()).
[中]移动到下一个结果(legacy-use.next())。
代码示例来源:origin: com.github.galigator.openllet/openllet-jena
/**
* {@inheritDoc}
*/
@Override
public QuerySolution nextSolution()
{
_row++;
return _results.nextSolution();
}
代码示例来源:origin: Galigator/openllet
/**
* {@inheritDoc}
*/
@Override
public QuerySolution nextSolution()
{
_row++;
return _results.nextSolution();
}
代码示例来源:origin: Galigator/openllet
/**
* {@inheritDoc}
*/
@Override
public QuerySolution nextSolution()
{
_row++;
return _results.nextSolution();
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public QuerySolution nextSolution() {
return decoratee.nextSolution();
}
代码示例来源:origin: apache/jena
@Override
public QuerySolution nextSolution() {
check() ;
return other.nextSolution() ;
}
代码示例来源:origin: apache/jena
@Override
public QuerySolution nextSolution() {
return get().nextSolution();
}
代码示例来源:origin: vivo-project/Vitro
private List<QuerySolution> getSolutionList(ResultSet resultSet) {
List<QuerySolution> solnList = new ArrayList<QuerySolution>();
while (resultSet.hasNext()) {
QuerySolution soln = resultSet.nextSolution();
solnList.add(soln);
}
return solnList;
}
代码示例来源:origin: vivo-project/Vitro
private List<Map<String, String>> mapResultsForQuery(ResultSet results,
Set<String> fieldNames) {
List<Map<String, String>> mapping = new ArrayList<>();
while (results.hasNext()) {
Map<String, String> rowMapping = mapResultsForRow(
results.nextSolution(), fieldNames);
if (!rowMapping.isEmpty()) {
mapping.add(rowMapping);
}
}
return mapping;
}
代码示例来源:origin: vivo-project/Vitro
/**
* Converts a ResultSet into a List of Maps.
*/
private List<Map<String, String>> parseResults(ResultSet results) {
List<Map<String,String>> rows = new ArrayList<Map<String,String>>();
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
rows.add( toRow( soln ) );
}
return rows;
}
代码示例来源:origin: apache/jena
/**
* Turn the result set into a java.util.List
* @param resultSet The result set
* @return List of QuerySolutions
*/
static public List<QuerySolution> toList(ResultSet resultSet)
{
List<QuerySolution> list = new ArrayList<>() ;
for ( ; resultSet.hasNext() ; ) {
QuerySolution result = resultSet.nextSolution() ;
materialize(result);
list.add(result) ;
}
return list ;
}
代码示例来源:origin: vivo-project/Vitro
/**
* Assumes single bound variable in solution.
*/
protected List<String> executeQueryToList(QueryExecution qex){
List<String> rv = new LinkedList<String>();
ResultSet results = qex.execSelect();
while (results.hasNext()) {
rv.add(querySolutionToString( results.nextSolution() ));
}
return rv;
}
代码示例来源:origin: apache/jena
/** This operation faithfully walks the results but does nothing with them.
* @return The count of the number of solutions.
*/
public static int consume(ResultSet resultSet)
{
int count = 0 ;
for ( ; resultSet.hasNext() ; )
{
// Force nodes to be materialized.
QuerySolution result = resultSet.nextSolution() ;
materialize(result);
count++ ;
}
return count ;
}
代码示例来源:origin: apache/jena
/**
* Execute, expecting the result to be one row, one column. Return that one.
* RDFNode or throw an exception.
* Use with {@code try ( QueryExecution qExec = ....)}.
*/
public static RDFNode getExactlyOne(QueryExecution qExec, String varname) {
ResultSet rs = qExec.execSelect() ;
if ( !rs.hasNext() )
throw new ARQException("Not found: var ?" + varname) ;
QuerySolution qs = rs.nextSolution() ;
RDFNode r = qs.get(varname) ;
if ( rs.hasNext() )
throw new ARQException("More than one: var ?" + varname) ;
return r ;
}
代码示例来源:origin: apache/jena
@Test public void testReuseQueryObject2()
{
String queryString = "SELECT (count(?o) AS ?c) {?s ?p ?o} GROUP BY ?s";
Query q = QueryFactory.create(queryString) ;
try(QueryExecution qExec = QueryExecutionFactory.create(q, m)) {
ResultSet rs = qExec.execSelect() ;
QuerySolution qs = rs.nextSolution() ;
assertEquals(3, qs.getLiteral("c").getInt()) ;
}
try(QueryExecution qExec = QueryExecutionFactory.create(q, m)) {
ResultSet rs = qExec.execSelect() ;
QuerySolution qs = rs.nextSolution() ;
assertEquals(3, qs.getLiteral("c").getInt()) ;
}
}
代码示例来源:origin: apache/jena
@Test public void testInitialBindings3()
{
try(QueryExecution qExec = makeQExec("SELECT * {?s ?p 'x1'}")) {
QuerySolutionMap init = new QuerySolutionMap() ;
init.add("z", m.createLiteral("zzz"));
qExec.setInitialBinding(init) ;
ResultSet rs = qExec.execSelect() ;
QuerySolution qs = rs.nextSolution() ;
assertTrue("Initial setting not set correctly now", qs.getLiteral("z").getLexicalForm().equals("zzz")) ;
}
}
代码示例来源:origin: apache/jena
@Test(expected=QueryCancelledException.class)
public void test_Cancel_API_1()
{
try(QueryExecution qExec = makeQExec("SELECT * {?s ?p ?o}")) {
ResultSet rs = qExec.execSelect() ;
assertTrue(rs.hasNext()) ;
qExec.abort();
assertTrue(rs.hasNext()) ;
rs.nextSolution();
assertFalse("Results not expected after cancel.", rs.hasNext()) ;
}
}
代码示例来源:origin: apache/jena
@Test(expected=QueryCancelledException.class)
public void test_Cancel_API_2()
{
try(QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> SELECT * {?s ?p ?o . FILTER ex:wait(100) }")) {
ResultSet rs = qExec.execSelect() ;
assertTrue(rs.hasNext()) ;
qExec.abort();
assertTrue(rs.hasNext()) ;
rs.nextSolution();
assertFalse("Results not expected after cancel.", rs.hasNext()) ;
}
}
代码示例来源:origin: apache/jena
@Test public void customAgg_20() {
Graph g = SSE.parseGraph("(graph (:s :p :o) (:s :p 1))") ;
Model m = ModelFactory.createModelForGraph(g) ;
String qs = "SELECT (<"+aggIRI+">(?o) AS ?x) {?s ?p ?o } GROUP BY ?s" ;
Query q = QueryFactory.create(qs, Syntax.syntaxARQ) ;
try (QueryExecution qExec = QueryExecutionFactory.create(q, m) ) {
ResultSet rs = qExec.execSelect() ;
QuerySolution soln = rs.nextSolution() ;
assertFalse(rs.hasNext());
int v = soln.getLiteral("x").getInt() ;
assertEquals(1, v) ;
}
}
代码示例来源:origin: apache/jena
@Test public void customAgg_21() {
// No GROUP BY, no match => default value
Graph g = SSE.parseGraph("(graph (:s :p :o) (:s :p 1))") ;
Model m = ModelFactory.createModelForGraph(g) ;
String qs = "SELECT (<"+aggIRI+">(?o) AS ?x) {?s ?p ?o FILTER (false) }" ;
Query q = QueryFactory.create(qs, Syntax.syntaxARQ) ;
try (QueryExecution qExec = QueryExecutionFactory.create(q, m) ) {
ResultSet rs = qExec.execSelect() ;
QuerySolution soln = rs.nextSolution() ;
assertFalse(rs.hasNext());
int v = soln.getLiteral("x").getInt() ;
assertEquals(-1, v) ;
}
}
代码示例来源:origin: apache/jena
@Test public void test_API1()
{
try(QueryExecution qExec = makeQExec("SELECT * {?s ?p ?o}")) {
ResultSet rs = qExec.execSelect() ;
assertTrue("No results", rs.hasNext()) ;
QuerySolution qs = rs.nextSolution() ;
Resource qr = qs.getResource("s") ;
//assertSame("Not the same model as queried", qr.getModel(), m) ;
Set<Statement> s1 = qr.getModel().listStatements().toSet() ;
Set<Statement> s2 = m.listStatements().toSet() ;
assertEquals(s1,s2) ;
}
}
内容来源于网络,如有侵权,请联系作者删除!