ubc.cs.JLog.Foundation
Class jAPIQueryThread

java.lang.Object
  extended by java.lang.Thread
      extended by ubc.cs.JLog.Foundation.jPrologServiceThread
          extended by ubc.cs.JLog.Foundation.jRetryQueryThread
              extended by ubc.cs.JLog.Foundation.jAPIQueryThread
All Implemented Interfaces:
java.lang.Runnable

public class jAPIQueryThread
extends jRetryQueryThread

This class is the thread that attempts to prove a query. It can parse an input string into the predicates of a user query, and it contains the Prolog prover itself. The prover runs as part of this thread. It is similar to jUserQueryThread, but is designed for use via jPrologAPI where the caller is responsible to handling exceptions.

Author:
Glendon Holst

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  jPrologServiceBroadcaster beginq
           
protected  jPrologServiceBroadcaster debugm
           
protected  jPrologServiceBroadcaster endq
           
protected  jProver prover
           
protected  java.lang.String qinput
           
protected  jPredicateTerms query
           
protected  boolean result
           
protected  java.lang.RuntimeException result_exception
           
protected  int retry
           
protected  jPrologServiceBroadcaster retryq
           
protected  java.util.Hashtable var_prebindings
           
protected  jVariableVector var_vector
           
 
Fields inherited from class ubc.cs.JLog.Foundation.jPrologServiceThread
allow_release, prolog, stopped
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
jAPIQueryThread(jPrologServices ps, java.util.Hashtable bindings, java.lang.String qin)
           
jAPIQueryThread(jPrologServices ps, java.lang.String qin)
           
 
Method Summary
 java.lang.RuntimeException getResultException()
          Returns the RuntimeException thrown by an unsucessful query / retry (e.g., UnknownPredicateException).
 java.util.Hashtable getResultHashtable()
          Returns a hashtable of the variable bindings, as a result of a sucessful query / retry.
protected  void internal_prove()
           
protected  void internal_retry()
           
protected  void query()
           
 void retry()
           
 void run()
           
 void setListeners(jPrologServiceBroadcaster b, jPrologServiceBroadcaster r, jPrologServiceBroadcaster e, jPrologServiceBroadcaster s, jPrologServiceBroadcaster d)
           
protected  boolean waitForRetry()
           
 
Methods inherited from class ubc.cs.JLog.Foundation.jPrologServiceThread
broadcasted_stop, getPrologServices, isCurrentlyConsulting, printOutput, setAllowRelease, setStoppedListeners
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

qinput

protected java.lang.String qinput

beginq

protected jPrologServiceBroadcaster beginq

retryq

protected jPrologServiceBroadcaster retryq

endq

protected jPrologServiceBroadcaster endq

debugm

protected jPrologServiceBroadcaster debugm

prover

protected jProver prover

query

protected jPredicateTerms query

result

protected boolean result

retry

protected int retry

var_vector

protected jVariableVector var_vector

var_prebindings

protected java.util.Hashtable var_prebindings

result_exception

protected java.lang.RuntimeException result_exception
Constructor Detail

jAPIQueryThread

public jAPIQueryThread(jPrologServices ps,
                       java.lang.String qin)

jAPIQueryThread

public jAPIQueryThread(jPrologServices ps,
                       java.util.Hashtable bindings,
                       java.lang.String qin)
Method Detail

setListeners

public void setListeners(jPrologServiceBroadcaster b,
                         jPrologServiceBroadcaster r,
                         jPrologServiceBroadcaster e,
                         jPrologServiceBroadcaster s,
                         jPrologServiceBroadcaster d)

retry

public void retry()
Specified by:
retry in class jRetryQueryThread

waitForRetry

protected boolean waitForRetry()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

query

protected void query()

internal_prove

protected void internal_prove()

internal_retry

protected void internal_retry()

getResultHashtable

public java.util.Hashtable getResultHashtable()
Returns a hashtable of the variable bindings, as a result of a sucessful query / retry.

Returns:
Returns a hashtable with all the variables in the query, and their bindings. Each key in the hashtable is a variable name, and the associated value is the jTerm the variable was bound to. Returns null if the query failed.

getResultException

public java.lang.RuntimeException getResultException()
Returns the RuntimeException thrown by an unsucessful query / retry (e.g., UnknownPredicateException).

Returns:
Returns a RuntimeException if the query failed. Returns null if the query did not throw an exception.