se.sics.prologbeans
Class QueryAnswer

java.lang.Object
  extended by se.sics.prologbeans.Bindings
      extended by se.sics.prologbeans.QueryAnswer

public class QueryAnswer
extends Bindings

QueryAnswer is the Java representation of an answer from the Prolog server. The QueryAnswer is returned by PrologSession 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
 java.lang.String getError()
          Returns the error reason or null if an error has not occurred or if no error reason is known.
 PBTerm getValue(java.lang.String variable)
          Returns the value of the specified variable or null if the variable is not bound.
 boolean isError()
          Returns true if an error occurred while processing the query and false otherwise.
 boolean queryFailed()
          Returns true if the query failed (i.e. the Prolog responded with 'no') and false otherwise.
 java.lang.String toString()
          Returns a string description of this answer.
 
Methods inherited from class se.sics.prologbeans.Bindings
bind, bind, bind, bind, bind, bind, bindAtom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryAnswer

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

Parameters:
answer - a 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(java.lang.String variable)
Returns the value of the specified variable or null if the variable is not bound.

Overrides:
getValue in class Bindings
Parameters:
variable - the name of the variable
Returns:
the value of the variable as a PBTerm or null if the variable is not bound

queryFailed

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


isError

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


getError

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


toString

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

Overrides:
toString in class Bindings