public interface PrologQuery extends Iterator<Collection<PrologTerm>>, Iterable<Collection<PrologTerm>>
 Prolog query is the mechanism to query the prolog database loaded in prolog
 engine. The way to create a new prolog query is invoking
 PrologEngine.query(String),
 PrologEngine.query(PrologTerm, PrologTerm...) or
 PrologEngine.query(PrologTerm[]). When this methods are called the
 prolog query is open an only with dispose() close the current query
 and release all internal resources.
 
 Prolog query implement Iterable and Iterator. This
 implementation help to obtain successive solutions present in the query.
 
 PrologEngine engine = provider.newEngine("zoo.pl");
 PrologVariable x = provider.newVariable("X", 0);
 PrologQuery query = engine.query(provider.newStructure("dark", x));
 while (query.hasNext()) {
        PrologTerm value = query.nextVariablesSolution().get("X");
        System.out.println(value);
 }
 query.dispose();
 
 
 
 PrologEngine engine = provider.newEngine("zoo.pl");
 PrologVariable x = provider.newVariable("X", 0);
 PrologQuery query = engine.query(provider.newStructure("dark", x));
 for (Collection<PrologTerm> col : query) {
        for (PrologTerm prologTerm : col) {
                System.out.println(prologTerm);
        }
 }
 query.dispose();
 | Modifier and Type | Method and Description | 
|---|---|
List<Map<String,PrologTerm>> | 
all()
Return a list of map of variables name key and Prolog terms as value that
 conform the solution set for the current query. 
 | 
List<List<Object>> | 
allResults()
Return a list of list of Java Objects that conform the solution set for the
 current query. 
 | 
PrologTerm[][] | 
allSolutions()
Return a Prolog terms matrix of n x m order that conform the solution set for
 the current query where n is the solution number and m is a free variable
 number in the query. 
 | 
List<Map<String,Object>> | 
allVariablesResults()
Return a list of map of variables name key and Java objects as value that
 conform the solution set for the current query. 
 | 
Map<String,PrologTerm>[] | 
allVariablesSolutions()
Return an array of map of variables name key and Prolog terms as value that
 conform the solution set for the current query. 
 | 
void | 
dispose()
Release all allocations for the query 
 | 
PrologEngine | 
getEngine()
Engine hold by the current query 
 | 
PrologProvider | 
getProvider()
Provider instance 
 | 
boolean | 
hasMoreSolutions()
 Check if the current query has more solutions. 
 | 
boolean | 
hasSolution()
 Check that the current query has solution. 
 | 
Map<String,PrologTerm> | 
more()
Return the next prolog terms that conform the solution set for the current
 query. 
 | 
List<Object> | 
nextResult()
Return the next Java objects solution list for the current query. 
 | 
PrologTerm[] | 
nextSolution()
Return the next prolog terms solution array for the current query. 
 | 
Map<String,Object> | 
nextVariablesResult()
Return the next Java objects that conform the solution set for the current
 query. 
 | 
Map<String,PrologTerm> | 
nextVariablesSolution()
Return the next prolog terms that conform the solution set for the current
 query. 
 | 
List<List<Object>> | 
nResult(int n)
Return a list of list of Java Objects that conform the solution set for the
 current query where n is the solution number and m is a free variable number
 in the query. 
 | 
PrologTerm[][] | 
nSolutions(int n)
Return a Prolog terms matrix of n x m order that conform the solution set for
 the current query where n is the solution number and m is a free variable
 number in the query. 
 | 
List<Map<String,PrologTerm>> | 
nths(int n)
Return a list of n size with maps of variables name key and Prolog terms as
 value that conform the solution set for the current query where n is the
 solution number. 
 | 
List<Map<String,Object>> | 
nVariablesResults(int n)
Return a list of n size with maps of variables name key and Java objects as
 value that conform the solution set for the current query where n is the
 solution number. 
 | 
Map<String,PrologTerm>[] | 
nVariablesSolutions(int n)
Return an array of n size with maps of variables name key and Prolog terms as
 value that conform the solution set for the current query where n is the
 solution number. 
 | 
Map<String,PrologTerm> | 
one()
Return a map of variables name key and Prolog terms as value that conform the
 solution set for the current query. 
 | 
List<Object> | 
oneResult()
Return the equivalent Java objects that conform the solution set for the
 current query. 
 | 
PrologTerm[] | 
oneSolution()
Return the prolog terms that conform the solution set for the current query. 
 | 
Map<String,Object> | 
oneVariablesResult()
Return the equivalent Java objects that conform the solution set for the
 current query. 
 | 
Map<String,PrologTerm> | 
oneVariablesSolution()
Return the prolog terms that conform the solution set for the current query. 
 | 
forEachRemaining, hasNext, next, removeforEach, iterator, spliteratorPrologProvider getProvider()
PrologEngine getEngine()
boolean hasSolution()
Check that the current query has solution.
boolean hasMoreSolutions()
Check if the current query has more solutions.
PrologTerm[] oneSolution()
Map<String,PrologTerm> oneVariablesSolution()
PrologTerm[] nextSolution()
Map<String,PrologTerm> nextVariablesSolution()
PrologTerm[][] nSolutions(int n)
n - array order or Prolog term rows numberMap<String,PrologTerm>[] nVariablesSolutions(int n)
n - array order or Prolog term items numberPrologTerm[][] allSolutions()
Map<String,PrologTerm>[] allVariablesSolutions()
List<Object> oneResult()
 List<Object> solution = query.oneResult();
 for (int i = 0; i < solution.size(); i++) {
        System.out.println(solution.get(i));
 }
 Map<String,Object> oneVariablesResult()
List<Object> nextResult()
Map<String,Object> nextVariablesResult()
List<List<Object>> nResult(int n)
n - list order or Java objects rows numberList<Map<String,Object>> nVariablesResults(int n)
n - list order or Java objects items numberList<List<Object>> allResults()
List<Map<String,Object>> allVariablesResults()
Map<String,PrologTerm> one()
Map<String,PrologTerm> more()
List<Map<String,PrologTerm>> nths(int n)
n - list order or Prolog term items numberList<Map<String,PrologTerm>> all()
void dispose()
Copyright © 2020–2024 Prolobjectlink Project. All rights reserved.