Class QueryResult
java.lang.Object
org.projog.api.QueryResult
Represents an executing query.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQueryResult(PredicateFactory predicateFactory, Term query, Map<String, Variable> variables) Evaluates a query. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanevaluate()getAtomName(String variableId) Returns the name of the atom instantiated to the variable with the specified id.doubleReturns thedoublevalue instantiated to the variable with the specified id.longReturns thelongvalue instantiated to the variable with the specified id.Returns the term instantiated to the variable with the specified id.Returns id's of all variables defined in the query this object represents.booleanReturnstrueif it is known that all possible solutions have been found, elsefalse.booleannext()Attempts to evaluate the query this object represents.
-
Field Details
-
predicate
-
variables
-
hasBeenEvaluated
private boolean hasBeenEvaluated -
hasFailed
private boolean hasFailed
-
-
Constructor Details
-
QueryResult
QueryResult(PredicateFactory predicateFactory, Term query, Map<String, Variable> variables) Evaluates a query.- Parameters:
query- represents the query statement being evaluatedvariables- collection of variables contained in the query (keyed by variable id)PredicateFactory- thePredicateFactorythat will be used to evaluate the query- See Also:
-
-
Method Details
-
next
public boolean next()Attempts to evaluate the query this object represents.Subsequent calls of the
next()method attempt to reevaluate the query, and because it returnsfalsewhen the are no more results, it can be used in awhileloop to iterate through all the results.- Returns:
trueif the query was (re)evaluated successfully orfalseif there are no more results. Oncefalsehas been returned bynext()thenext()method should no longer be called on that object.- Throws:
ProjogException- if an error occurs while evaluating the query
-
evaluate
private boolean evaluate() -
isExhausted
public boolean isExhausted()Returnstrueif it is known that all possible solutions have been found, elsefalse.- Returns:
trueif it is known that all possible solutions have been found, elsefalse.- See Also:
-
getAtomName
Returns the name of the atom instantiated to the variable with the specified id.- Parameters:
variableId- the id of the variable from which to return the instantiated term- Returns:
- the name of the atom instantiated to the variable with the specified id
- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or if the term instantiated to the variable is not an atom- See Also:
-
getDouble
Returns thedoublevalue instantiated to the variable with the specified id.- Parameters:
variableId- the id of the variable from which to return the instantiated term- Returns:
- the name of the atom instantiated to the variable with the specified id
- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or if the term instantiated to the variable is not a number- See Also:
-
getLong
Returns thelongvalue instantiated to the variable with the specified id.- Parameters:
variableId- the id of the variable from which to return the instantiated term- Returns:
- the value instantiated to the variable with the specified id
- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or if the term instantiated to the variable is not a number- See Also:
-
getTerm
Returns the term instantiated to the variable with the specified id.next()must be called before this method.- Parameters:
variableId- the id of the variable from which to return the instantiated term- Returns:
- the term instantiated to the variable with the specified id (or the
Variableof representing the variable if it is uninstantiated) - Throws:
ProjogException- if no variable with the specified id exists in the query this object represents- See Also:
-
getVariableIds
-