Class QueryResult

java.lang.Object
org.projog.api.QueryResult

public final class QueryResult extends Object
Represents an executing query.
  • Method Summary

    Modifier and Type
    Method
    Description
    getAtomName(String variableId)
    Returns the name of the atom instantiated to the variable with the specified id.
    double
    getDouble(String variableId)
    Returns the double value instantiated to the variable with the specified id.
    long
    getLong(String variableId)
    Returns the long value instantiated to the variable with the specified id.
    getTerm(String variableId)
    Returns the term instantiated to the variable with the specified id.
    Returns id's of all variables defined in the query this object represents.
    boolean
    Returns true if it is known that all possible solutions have been found, else false.
    boolean
    Attempts to evaluate the query this object represents.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 returns false when the are no more results, it can be used in a while loop to iterate through all the results.

      Returns:
      true if the query was (re)evaluated successfully or false if there are no more results. Once false has been returned by next() the next() method should no longer be called on that object.
      Throws:
      ProjogException - if an error occurs while evaluating the query
    • isExhausted

      public boolean isExhausted()
      Returns true if it is known that all possible solutions have been found, else false.
      Returns:
      true if it is known that all possible solutions have been found, else false.
      See Also:
    • getAtomName

      public String getAtomName(String variableId)
      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

      public double getDouble(String variableId)
      Returns the double value 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

      public long getLong(String variableId)
      Returns the long value 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

      public Term getTerm(String variableId)
      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 Variable of 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

      public Set<String> getVariableIds()
      Returns id's of all variables defined in the query this object represents.
      Returns:
      id's of all variables defined in the query this object represents