Class QueryStatement
java.lang.Object
org.projog.api.QueryStatement
Represents a query.
single use, not multi-threaded
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidEvaluate once the query represented by this statement.Returns a newQueryResultfor the query represented by this object.Find all solutions generated by the query and return String representations of the atoms the single query variable was unified with.Find all solutions generated by the query and return thedoublevalues the single query variable was unified with.Find all solutions generated by the query and return thelongvalues the single query variable was unified with.Find all solutions generated by the query and return theTermvalues the single query variable was unified with.Execute the query once and return a String representation of the atom the single query variable was unified with.doubleExecute the query once and return adoublerepresentation of the term the single query variable was unified with.longExecute the query once and return alongrepresentation of the term the single query variable was unified with.Attempt to execute the query once and return a String representation of the atom the single query variable was unified with.Attempt to execute the query once and return aDoublerepresentation of the term the single query variable was unified with.Attempt to execute the query once and return aLongrepresentation of the term the single query variable was unified with.Attempt to execute the query once and return aTermrepresentation of the term the single query variable was unified with.Execute the query once and return theTermthe single query variable was unified with.voidsetAtomName(String variableId, String atomName) Attempts to unify the specifiedStringvalue as anAtomto the variable with the specified id.voidAttempts to unify the specifieddoubleas aDecimalFractionto the variable with the specified id.voidsetListOfAtomNames(String variableId, String... atomNames) Attempts to unify the specifiedStringvalues as a Prolog list of atoms to the variable with the specified id.voidsetListOfAtomNames(String variableId, List<String> atomNames) Attempts to unify the specifiedStringvalues as a Prolog list of atoms to the variable with the specified id.voidsetListOfDoubles(String variableId, double... doubles) Attempts to unify the specifieddoublevalues as a Prolog list to the variable with the specified id.voidsetListOfDoubles(String variableId, List<Double> doubles) Attempts to unify the specifiedDoublevalues as a Prolog list to the variable with the specified id.voidsetListOfLongs(String variableId, long... longs) Attempts to unify the specifiedlongvalues as a Prolog list to the variable with the specified id.voidsetListOfLongs(String variableId, List<Long> longs) Attempts to unify the specifiedLongvalues as a Prolog list to the variable with the specified id.voidsetListOfTerms(String variableId, List<? extends Term> terms) Attempts to unify the specifiedTermvalues as a Prolog list to the variable with the specified id.voidsetListOfTerms(String variableId, Term... terms) Attempts to unify the specifiedTermvalues as a Prolog list to the variable with the specified id.voidAttempts to unify the specifiedlongas aIntegerNumberto the variable with the specified id.voidAttempts to unify the specified term to the variable with the specified id.
-
Method Details
-
setTerm
Attempts to unify the specified term to the variable with the specified id.- Parameters:
variableId- the id of the variableterm- the term to unify to the variable- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setAtomName
Attempts to unify the specifiedStringvalue as anAtomto the variable with the specified id.- Parameters:
variableId- the id of the variableatomName- the value to use as the name of theAtomthat the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setDouble
Attempts to unify the specifieddoubleas aDecimalFractionto the variable with the specified id.- Parameters:
variableId- the id of the variablevalue- the value to use as the name of theDecimalFractionthat the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setLong
Attempts to unify the specifiedlongas aIntegerNumberto the variable with the specified id.- Parameters:
variableId- the id of the variablevalue- the value to use as the name of theIntegerNumberthat the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfAtomNames
Attempts to unify the specifiedStringvalues as a Prolog list of atoms to the variable with the specified id.- Parameters:
variableId- the id of the variableatomNames- the values to use as atom elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfAtomNames
Attempts to unify the specifiedStringvalues as a Prolog list of atoms to the variable with the specified id.- Parameters:
variableId- the id of the variableatomNames- the values to use as atom elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfDoubles
Attempts to unify the specifieddoublevalues as a Prolog list to the variable with the specified id.- Parameters:
variableId- the id of the variabledoubles- the values to use as elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfDoubles
Attempts to unify the specifiedDoublevalues as a Prolog list to the variable with the specified id.- Parameters:
variableId- the id of the variabledoubles- the values to use as elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfLongs
Attempts to unify the specifiedlongvalues as a Prolog list to the variable with the specified id.- Parameters:
variableId- the id of the variablelongs- the values to use as elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfLongs
Attempts to unify the specifiedLongvalues as a Prolog list to the variable with the specified id.- Parameters:
variableId- the id of the variablelongs- the values to use as elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfTerms
Attempts to unify the specifiedTermvalues as a Prolog list to the variable with the specified id.- Parameters:
variableId- the id of the variableterms- the values to use as elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
setListOfTerms
Attempts to unify the specifiedTermvalues as a Prolog list to the variable with the specified id.- Parameters:
variableId- the id of the variableterms- the values to use as elements in the list that the variable will be unified with- Throws:
ProjogException- if no variable with the specified id exists in the query this object represents, or the given term cannot be unified with the variable- See Also:
-
executeQuery
Returns a newQueryResultfor the query represented by this object.Note that the query is not evaluated as part of a call to
executeQuery(). It is on the first call ofQueryResult.next()that the first attempt to evaluate the query will be made.- Returns:
- a new
QueryResultfor the query represented by this object.
-
executeOnce
public void executeOnce()Evaluate once the query represented by this statement.The query will only be evaluated once, even if further solutions could of been found on backtracking.
- Throws:
ProjogException- if no solution can be found- See Also:
-
findFirstAsAtomName
Execute the query once and return a String representation of the atom the single query variable was unified with.- Returns:
- the name of the atom the query variable has been unified with as a result of executing the query
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsDouble
public double findFirstAsDouble()Execute the query once and return adoublerepresentation of the term the single query variable was unified with.- Returns:
- the value the query variable has been unified with as a result of executing the query
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsLong
public long findFirstAsLong()Execute the query once and return alongrepresentation of the term the single query variable was unified with.- Returns:
- the value query variable has been unified with as a result of executing the query
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsTerm
Execute the query once and return theTermthe single query variable was unified with.- Returns:
- the value query variable has been unified with as a result of executing the query
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsOptionalAtomName
Attempt to execute the query once and return a String representation of the atom the single query variable was unified with.- Returns:
- the name of the atom the query variable has been unified with, or an empty optional if the query was not successfully evaluated
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsOptionalDouble
Attempt to execute the query once and return aDoublerepresentation of the term the single query variable was unified with.- Returns:
- the value the query variable has been unified with, or an empty optional if the query was not successfully evaluated
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsOptionalLong
Attempt to execute the query once and return aLongrepresentation of the term the single query variable was unified with.- Returns:
- the value the query variable has been unified with, or an empty optional if the query was not successfully evaluated
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findFirstAsOptionalTerm
Attempt to execute the query once and return aTermrepresentation of the term the single query variable was unified with.- Returns:
- the value the query variable has been unified with, or an empty optional if the query was not successfully evaluated
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findAllAsAtomName
Find all solutions generated by the query and return String representations of the atoms the single query variable was unified with.- Returns:
- list of atom names the query variable was been unified with as a result of executing the query until no more solutions were found
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findAllAsDouble
Find all solutions generated by the query and return thedoublevalues the single query variable was unified with.- Returns:
- list of values the query variable was been unified with as a result of executing the query until no more solutions were found
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findAllAsLong
Find all solutions generated by the query and return thelongvalues the single query variable was unified with.- Returns:
- list of values the query variable was been unified with as a result of executing the query until no more solutions were found
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-
findAllAsTerm
Find all solutions generated by the query and return theTermvalues the single query variable was unified with.- Returns:
- list of values the query variable was been unified with as a result of executing the query until no more solutions were found
- Throws:
ProjogException- if the query could not be evaluated successfullyProjogException- of there is not exactly one named variable in the query this statement represents
-