MCPcopy Create free account
hub / github.com/SWI-Prolog/packages-jpl / fetchNextSolution

Method fetchNextSolution

src/main/java/org/jpl7/Query.java:428–444  ·  view source on GitHub ↗

Tell Prolog engine to fetch the next solution for the current active query (like hitting ;) If there are no more solutions, then just close the query @return whether a new solutions was found or there are no more solutions @throws PrologException with the term of the error from Prolog (e.g., syntax

()

Source from the content-addressed store, hash-verified

426 * @throws PrologException with the term of the error from Prolog (e.g., syntax error in query or non existence of predicates)
427 */
428 private boolean fetchNextSolution() { // try to get the next solution; if none,
429 // close the query;
430 if (Prolog.next_solution(qid)) {
431 return true;
432 } else { // if failure was due to throw/1, build exception term and
433 // throw it
434 term_t exception_term_t = Prolog.exception(qid);
435 if (exception_term_t.value != 0L) {
436 Term exception_term = Term.getTerm(new HashMap<term_t, Variable>(), exception_term_t);
437 close();
438 throw new PrologException(exception_term);
439 } else { // no more solution, close the query
440 close();
441 return false;
442 }
443 }
444 }
445
446 /**
447 * Returns the next solution of the query

Callers 2

hasMoreSolutionsMethod · 0.95
getSubstWithNameVarsMethod · 0.95

Calls 4

next_solutionMethod · 0.95
exceptionMethod · 0.95
getTermMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected