public final class QueryStatement extends Object
single use, not multi-threaded
Modifier and Type | Method and Description |
---|---|
void |
executeOnce()
Evaluate once the query represented by this statement.
|
QueryResult |
executeQuery()
Returns a new
QueryResult for the query represented by this object. |
List<String> |
findAllAsAtomName()
Find all solutions generated by the query and return String representations of the atoms the single query variable
was unified with.
|
List<Double> |
findAllAsDouble()
Find all solutions generated by the query and return the
double values the single query variable was
unified with. |
List<Long> |
findAllAsLong()
Find all solutions generated by the query and return the
long values the single query variable was unified
with. |
List<Term> |
findAllAsTerm()
Find all solutions generated by the query and return the
Term values the single query variable was unified
with. |
String |
findFirstAsAtomName()
Execute the query once and return a String representation of the atom the single query variable was unified with.
|
double |
findFirstAsDouble()
Execute the query once and return a
double representation of the term the single query variable was
unified with. |
long |
findFirstAsLong()
Execute the query once and return a
long representation of the term the single query variable was unified
with. |
Optional<String> |
findFirstAsOptionalAtomName()
Attempt to execute the query once and return a String representation of the atom the single query variable was
unified with.
|
Optional<Double> |
findFirstAsOptionalDouble()
Attempt to execute the query once and return a
Double representation of the term the single query variable
was unified with. |
Optional<Long> |
findFirstAsOptionalLong()
Attempt to execute the query once and return a
Long representation of the term the single query variable
was unified with. |
Optional<Term> |
findFirstAsOptionalTerm()
Attempt to execute the query once and return a
Term representation of the term the single query variable
was unified with. |
Term |
findFirstAsTerm()
Execute the query once and return the
Term the single query variable was unified with. |
void |
setAtomName(String variableId,
String atomName)
Attempts to unify the specified
String value as an Atom to the variable with the specified id. |
void |
setDouble(String variableId,
double value)
Attempts to unify the specified
double as a DecimalFraction to the variable with the specified id. |
void |
setListOfAtomNames(String variableId,
List<String> atomNames)
Attempts to unify the specified
String values as a Prolog list of atoms to the variable with the specified
id. |
void |
setListOfAtomNames(String variableId,
String... atomNames)
Attempts to unify the specified
String values as a Prolog list of atoms to the variable with the specified
id. |
void |
setListOfDoubles(String variableId,
double... doubles)
Attempts to unify the specified
double values as a Prolog list to the variable with the specified id. |
void |
setListOfDoubles(String variableId,
List<Double> doubles)
Attempts to unify the specified
Double values as a Prolog list to the variable with the specified id. |
void |
setListOfLongs(String variableId,
List<Long> longs)
Attempts to unify the specified
Long values as a Prolog list to the variable with the specified id. |
void |
setListOfLongs(String variableId,
long... longs)
Attempts to unify the specified
long values as a Prolog list to the variable with the specified id. |
void |
setListOfTerms(String variableId,
List<? extends Term> terms)
Attempts to unify the specified
Term values as a Prolog list to the variable with the specified id. |
void |
setListOfTerms(String variableId,
Term... terms)
Attempts to unify the specified
Term values as a Prolog list to the variable with the specified id. |
void |
setLong(String variableId,
long value)
Attempts to unify the specified
long as a IntegerNumber to the variable with the specified id. |
void |
setTerm(String variableId,
Term term)
Attempts to unify the specified term to the variable with the specified id.
|
public void setTerm(String variableId, Term term)
variableId
- the id of the variableterm
- the term to unify to the variableProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetAtomName(String, String)
,
setDouble(String, double)
,
setLong(String, long)
,
setListOfAtomNames(String, List)
,
setListOfAtomNames(String, String...)
,
setListOfDoubles(String, List)
,
setListOfDoubles(String, double...)
,
setListOfLongs(String, List)
,
setListOfLongs(String, long...)
,
setListOfTerms(String, List)
,
setListOfTerms(String, Term...)
public void setAtomName(String variableId, String atomName)
String
value as an Atom
to the variable with the specified id.variableId
- the id of the variableatomName
- the value to use as the name of the Atom
that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setDouble(String variableId, double value)
double
as a DecimalFraction
to the variable with the specified id.variableId
- the id of the variablevalue
- the value to use as the name of the DecimalFraction
that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setLong(String variableId, long value)
long
as a IntegerNumber
to the variable with the specified id.variableId
- the id of the variablevalue
- the value to use as the name of the IntegerNumber
that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfAtomNames(String variableId, String... atomNames)
String
values as a Prolog list of atoms to the variable with the specified
id.variableId
- the id of the variableatomNames
- the values to use as atom elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfAtomNames(String variableId, List<String> atomNames)
String
values as a Prolog list of atoms to the variable with the specified
id.variableId
- the id of the variableatomNames
- the values to use as atom elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfDoubles(String variableId, double... doubles)
double
values as a Prolog list to the variable with the specified id.variableId
- the id of the variabledoubles
- the values to use as elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfDoubles(String variableId, List<Double> doubles)
Double
values as a Prolog list to the variable with the specified id.variableId
- the id of the variabledoubles
- the values to use as elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfLongs(String variableId, long... longs)
long
values as a Prolog list to the variable with the specified id.variableId
- the id of the variablelongs
- the values to use as elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfLongs(String variableId, List<Long> longs)
Long
values as a Prolog list to the variable with the specified id.variableId
- the id of the variablelongs
- the values to use as elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfTerms(String variableId, Term... terms)
Term
values as a Prolog list to the variable with the specified id.variableId
- the id of the variableterms
- the values to use as elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public void setListOfTerms(String variableId, List<? extends Term> terms)
Term
values as a Prolog list to the variable with the specified id.variableId
- the id of the variableterms
- the values to use as elements in the list that the variable will be unified withProjogException
- if no variable with the specified id exists in the query this object represents, or the
given term cannot be unified with the variablesetTerm(String, Term)
public QueryResult executeQuery()
QueryResult
for 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 of
QueryResult.next()
that the first attempt to evaluate the query will be made.
QueryResult
for the query represented by this object.public void executeOnce()
The query will only be evaluated once, even if further solutions could of been found on backtracking.
ProjogException
- if no solution can be foundexecuteQuery()
public String findFirstAsAtomName()
ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic double findFirstAsDouble()
double
representation of the term the single query variable was
unified with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic long findFirstAsLong()
long
representation of the term the single query variable was unified
with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic Term findFirstAsTerm()
Term
the single query variable was unified with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic Optional<String> findFirstAsOptionalAtomName()
ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic Optional<Double> findFirstAsOptionalDouble()
Double
representation of the term the single query variable
was unified with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic Optional<Long> findFirstAsOptionalLong()
Long
representation of the term the single query variable
was unified with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic Optional<Term> findFirstAsOptionalTerm()
Term
representation of the term the single query variable
was unified with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic List<String> findAllAsAtomName()
ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic List<Double> findAllAsDouble()
double
values the single query variable was
unified with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic List<Long> findAllAsLong()
long
values the single query variable was unified
with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representspublic List<Term> findAllAsTerm()
Term
values the single query variable was unified
with.ProjogException
- if the query could not be evaluated successfullyProjogException
- of there is not exactly one named variable in the query this statement representsCopyright © 2024. All rights reserved.