se.sics.prologbeans
Class QueryAnswer


QueryAnswer is the representation of an answer from the Prolog server. The QueryAnswer is returned by null in response to a query and contains variable bindings, errors, and success/failure information. It also contains the variable bindings specified in the query.


 
Constructor Summary
QueryAnswer(PBTerm answer, Bindings bindings)
Creates a new QueryAnswer instance with the specified information.
 
Method Summary
public PBTerm getValue(string variable)
Returns the value of the specified variable or null if the variable is not bound.
public bool queryFailed()
Returns true if the query failed (i.e. the Prolog responded with 'no') and false otherwise.
public bool isError()
Returns true if an error occurred while processing the query and false otherwise.
public string getError()
Returns the error reason or null if an error has not occurred or if no error reason is known.
public string toString()
Returns a string description of this answer.
   
Constructor Detail

QueryAnswer

QueryAnswer(PBTerm answer, Bindings bindings)
Creates a new QueryAnswer instance with the specified information.

Parameters:
answer - a {@link se.sics.prologbeans.PBTerm} value representing the Prolog response
bindings - the variable bindings for the query to which this is an answer

 
Method Detail

getValue

public PBTerm getValue(string variable)
Returns the value of the specified variable or null if the variable is not bound.

Parameters:
variable - the name of the variable
Returns:
the value of the variable as a {@link se.sics.prologbeans.PBTerm} or null if the variable is not bound

queryFailed

public bool queryFailed()
Returns true if the query failed (i.e. the Prolog responded with 'no') and false otherwise.

Returns:
whether the query failed

isError

public bool isError()
Returns true if an error occurred while processing the query and false otherwise.

Returns:
whether the query threw an exception

getError

public string getError()
Returns the error reason or null if an error has not occurred or if no error reason is known.

Returns:
the error, or null, if none

toString

public string toString()
Returns a string description of this answer.