com.declarativa.interprolog
Class AbstractPrologEngine

java.lang.Object
  extended by com.declarativa.interprolog.AbstractPrologEngine
All Implemented Interfaces:
PrologEngine
Direct Known Subclasses:
AbstractNativeEngine, SubprocessEngine

public abstract class AbstractPrologEngine
extends Object
implements PrologEngine

The heart of InterProlog; a PrologEngine represents a Prolog machine instance. This is an abstract class; you should use it just to declare variables, but must instantiate only subclasses.


Field Summary
 String firstJavaMessageName
          Name of first message sent to Java
 boolean interPrologFileLoaded
          Determines wether deterministicGoal machinery is in place...
 boolean interrupting
          Prolog is handling an interrupt
 String nl
          Convenience for newline; value for the OS where Prolog is running (which may be different from the Java side).
 String prologBinDirectoryOrCommand
          File path to directory with Prolog machine, or command path; this may NOT have options appended (Windows oblige), use specific constructors in subclasses for that
 
Fields inherited from interface com.declarativa.interprolog.PrologEngine
MAX_INT_VALUE, MIN_INT_VALUE, version
 
Constructor Summary
AbstractPrologEngine(String prologBinDirectoryOrCommand, boolean debug, boolean loadFromJar)
          Create a Prolog executor, possibly spawning it in a different process or loading it into memory, depending on the implementation by our subclass.
 
Method Summary
 void abortTasks()
          Do not invoke this.
 void addPrologEngineListener(PrologEngineListener L)
           
static boolean assignableType(Class<?> left, Class<?> right)
          It is OK to assign an expression typed right to a variable typed left.
 boolean command(String s)
          Execute a Prolog "command"; except until the basic InterProlog is loaded, this in fact delegates to deterministicGoal, which synchonizes at the end and returns a reliable result.
 boolean consultAbsolute(File f)
          Consults a Prolog file
 boolean consultAbsolute(String f)
           
 String consultFromPackage(String filename, Object requester)
          Extracts a Prolog file from the jar file or directory where the requester's class came from, and asks Prolog process to consult it.
 String consultRelative(String filename, Object requester)
          Consults a Prolog file from the directory where the requester's class would come from if it did not come from a jar file.
 boolean deterministicGoal(String G)
          A parameterless goal with no result other than success/failure.
 Object[] deterministicGoal(String G, String RVars)
          Useful when you're constructing objects from Prolog, but don't need to pass any from Java.
 boolean deterministicGoal(String G, String OVar, Object[] objectsP)
          Useful when you want to pass objects to Prolog but don't need objects returned.
 Object[] deterministicGoal(String G, String OVar, Object[] objectsP, String RVars)
          Synchronously calls a Prolog goal.
 TermModel deterministicGoal(TermModel G)
          Useful for inter-Prolog goal calling through Java.
 ResultFromJava doCallback(Object x)
          Execute a Prolog->Java call
 void endAllTasks(Exception e)
          Do not invoke this
 void exec(String S)
          A command expected to always succeed; throws an IPException if it fails
static Constructor findConstructor(Class<?> targetClass, Class<?>[] formalArguments)
          Similar to findMethod(), but for constructors rather than regular methods
static Method findMethod(Class<?> targetClass, String name, Class<?>[] formalArguments)
          An utility building on the functionality of getMethod(), to provide the javaMessage predicate with method argument polimorphism.
 void firstJavaMessage()
          Dummy method, whose name is used to start the callback thread
 PrologImplementationPeer getImplementationPeer()
           
 String getInterprologPath()
           
 File getJarDirectory()
          Returns the directory containing the jar with the engine class
static File getJarDirectory(Class aClass)
          Returns the directory containing the jar with the given class
 boolean getLoadFromJar()
           
 String getPrologBaseDirectory()
          Returns the installation directory for the Prolog system, without the trailing separator char
 String getPrologNumericVersion()
          Returns the Prolog numeric version for this engine; useful for functionality that depends on features of a particular version.
 String getPrologVersion()
          Returns the Prolog system name and version for this engine
 Object getRealJavaObject(int ID)
          Same as getRealJavaObject(InvisibleObject), but accepts an integer ID as argument instead
 Object getRealJavaObject(InvisibleObject o)
          Get the object referred by the integer in a InvisibleObject wrapper.
 Object getRealJavaObject(Object o)
          Just returns the object, untouched (but "dereferenced" if called from Prolog).
 PrologEngineListener getThePrologListener()
          Kludgy method to be used only if a single listener exists; will throw an exception otherwise
 SolutionIterator goal(String G, String RVars)
          Useful when you're constructing objects from Prolog, but don't need to pass any from Java.
 SolutionIterator goal(String G, String OVar, Object[] objectsP, String RVars)
          Similar to deterministicGoal, but rather than just the first solution returns an Iterator which lazily returns bindings for solutions.
 Object handleCallback(Object x)
          Handling of javaMessages and deterministicGoals.
 boolean inPrologShell()
          We know the engine to be in the Prolog shell, so Prolog goals do not need a postfix.
 void interrupt()
          Interrupt Prolog and make it return to its top level.
 void interruptTasks()
          Do not invoke this.
static boolean is64WindowsOS()
           
 boolean isAvailable()
          Present implementation is always available, so this always returns true.
 boolean isDebug()
          Debug messages are being written, both Java and Prolog side, cf.
 boolean isIdle()
          The engine is doing nothing: no pending Prolog goals nor Java callbacks
static boolean isMacOS()
           
 boolean isProfiling()
           
static boolean isSerializable(Object x)
          Returns true if the object is Serializable or, being an array, its element type is primitive or Serializable
 boolean isShutingDown()
          The engine is in the process of shuting down
 boolean isThreadedCallbacks()
           
static boolean isWindowsOS()
          whether we (Java side) are re under Windows -- isWindowsOS
 boolean lastSolutionUndefined()
           
 boolean load_dynAbsolute(File f)
           
 String load_dynRelative(String filename, Object requester)
           
 Object makeInvisible(Object x)
          Register an object with this Engine, so it later can be referred from Prolog without serializing it, and returns an InvisibleObject encapsulating the reference.
static String printAllStackTraces()
           
static String printAllStackTraces(boolean quiet)
          If !quite, does not print to the standard (error) output
static void printBindings(Object[] b)
          Convenience for debugging deterministicGoal() messages
static void printStackTrace()
           
 void profilingMessage(String s)
          Profiling aid
 void progressMessage(String s)
          Debugging aid
 void progressMessage(String s, Object X)
           
 String prologBinToBaseDirectory(String binDirectoryOrStartCommand)
          Computes the installation directory for the Prolog system, without the trailing separator char
 String prologCanWork()
          Never call this directly; the Prolog side does call this automatically during timed calls
abstract  boolean realCommand(String s)
          Implementation of a simple parameterless Prolog goal; does not support recursive nor multithreaded operation, use command instead
 int registerJavaObject(Object x)
          Register an object with this Engine, so it later can be referred from Prolog without serializing it.
 void removePrologEngineListener(PrologEngineListener L)
           
 char serverFileSeparatorChar()
           
 boolean serverIsWindows()
          Whether the Prolog machine is a Windows box
 void setDebug(boolean d)
          Show (or hide) debug messages, both Java and Prolog side, cf.
 void setProfiling(boolean d)
           
 void setThreadedCallbacks(boolean yes)
          If true, the Java execution of javaMessage predicates will happen in new threads (default); if false, execution will be under the thread of the deterministicGoal currently executing in Prolog
 void setTimedCallIntervall(int ms)
          If ms>0, all future deterministic goals will be executed under control so that the Java side is messaged (with @see#willWork messages) every ms, with the possibility to abort the Prolog computation, by having the Prolog engine interrupt normal execution periodically; otherwise the goal will run uninterrupted.
static String shortClassName(Class c)
          Returns just the name of the class, with no package information.
 void shutdown()
          Release Prolog engine resources, making it unusable
 void stop()
          Gracefully stop the engine computation, unlike interrupt() which is brutal.
 boolean teachMoreObjects(Object[] examples)
          Same as #teachMoreObjects(ObjectExamplePair[]), but example pairs are constructed with (2) repeated examples for each object
 boolean teachMoreObjects(ObjectExamplePair example)
           
 boolean teachMoreObjects(ObjectExamplePair[] examples)
          Send an array of object example pairs to Prolog and generate ipObjectSpec facts.
 boolean teachOneObject(Object example)
          Same as #teachMoreObjects(ObjectExamplePair[]), but the single example pair is constructed repeating the object
 String unescapedFilePath(String p)
          Some Prologs use '\' as an escape character in atoms, which can affect file paths under Windows.
 boolean unregisterJavaObject(int ID)
          Removes reference to the object from the registry.
 boolean unregisterJavaObject(Object obj)
          Removes reference to the object from the registry.
 boolean unregisterJavaObjects(Class cls)
          Removes references to objects of class cls from the registry.
 void waitUntilAvailable()
          This method blocks until isAvailable() returns true.
 void waitUntilIdle()
          Sleeps the current Java thread until this engine is idle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prologBinDirectoryOrCommand

public String prologBinDirectoryOrCommand
File path to directory with Prolog machine, or command path; this may NOT have options appended (Windows oblige), use specific constructors in subclasses for that


nl

public String nl
Convenience for newline; value for the OS where Prolog is running (which may be different from the Java side). So this may or not coincide with System.getProperty("line.separator")


interrupting

public boolean interrupting
Prolog is handling an interrupt


interPrologFileLoaded

public boolean interPrologFileLoaded
Determines wether deterministicGoal machinery is in place...


firstJavaMessageName

public final String firstJavaMessageName
Name of first message sent to Java

See Also:
Constant Field Values
Constructor Detail

AbstractPrologEngine

public AbstractPrologEngine(String prologBinDirectoryOrCommand,
                            boolean debug,
                            boolean loadFromJar)
Create a Prolog executor, possibly spawning it in a different process or loading it into memory, depending on the implementation by our subclass.

Parameters:
prologBinDirectoryOrCommand - File path to Prolog machine, see subclass docs for precise semantics
debug - if true, print progress messages to aid debugging
loadFromJar - if true, startup files should be loaded from the jar file, rather than directly from the file system

IF prologBinDirectoryOrCommand is null then InterProlog needs to find values for one or more properties, XSB_BIN_DIRECTORY and/or others, depending on which Prolog(s) you're using.

First it looks for an 'interprolog.defs' file (a Properties file in the format described in http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html, in the directory where the jar file containing the InterProlog classes is).
If 'interprolog.defs' does not exist, an attempt is made to get the property through System.getProperties(); in this scenario you can define the property by using the -D java (command) switch; if it doesn't find it, it will try to find an environment variable

Method Detail

getInterprologPath

public String getInterprologPath()

getImplementationPeer

public PrologImplementationPeer getImplementationPeer()
Specified by:
getImplementationPeer in interface PrologEngine

getPrologVersion

public String getPrologVersion()
Returns the Prolog system name and version for this engine

Specified by:
getPrologVersion in interface PrologEngine

getPrologNumericVersion

public String getPrologNumericVersion()
Returns the Prolog numeric version for this engine; useful for functionality that depends on features of a particular version. It is requested to Prolog dynamically, but only once. Should not be used only after the engine objects is initialized (constructed).


getPrologBaseDirectory

public String getPrologBaseDirectory()
Returns the installation directory for the Prolog system, without the trailing separator char

Specified by:
getPrologBaseDirectory in interface PrologEngine

prologBinToBaseDirectory

public String prologBinToBaseDirectory(String binDirectoryOrStartCommand)
Computes the installation directory for the Prolog system, without the trailing separator char


serverIsWindows

public boolean serverIsWindows()
Whether the Prolog machine is a Windows box


serverFileSeparatorChar

public char serverFileSeparatorChar()

isWindowsOS

public static boolean isWindowsOS()
whether we (Java side) are re under Windows -- isWindowsOS


is64WindowsOS

public static boolean is64WindowsOS()

isMacOS

public static boolean isMacOS()

shutdown

public void shutdown()
Release Prolog engine resources, making it unusable

Specified by:
shutdown in interface PrologEngine

isShutingDown

public boolean isShutingDown()
The engine is in the process of shuting down


getJarDirectory

public File getJarDirectory()
Returns the directory containing the jar with the engine class


getJarDirectory

public static File getJarDirectory(Class aClass)
Returns the directory containing the jar with the given class


unescapedFilePath

public String unescapedFilePath(String p)
Some Prologs use '\' as an escape character in atoms, which can affect file paths under Windows. Use this method to preprocess all file paths passed to Prolog.

Specified by:
unescapedFilePath in interface PrologEngine

consultFromPackage

public String consultFromPackage(String filename,
                                 Object requester)
Extracts a Prolog file from the jar file or directory where the requester's class came from, and asks Prolog process to consult it. You should use this method only after your program is stable. The Prolog file is extracted into a temporary file, that is automatically deleted on exiting the application.

Specified by:
consultFromPackage in interface PrologEngine
Parameters:
filename - The Prolog file name, including extension; if it has no extension, the Prolog file extensions are appended in turn until a file is found
requester - Defines where the Prolog file resides
See Also:
consultRelative(String, Object), load_dynRelative(String, Object)

consultAbsolute

public boolean consultAbsolute(File f)
Consults a Prolog file

Specified by:
consultAbsolute in interface PrologEngine

consultAbsolute

public boolean consultAbsolute(String f)

load_dynAbsolute

public boolean load_dynAbsolute(File f)
Specified by:
load_dynAbsolute in interface PrologEngine

consultRelative

public final String consultRelative(String filename,
                                    Object requester)
Consults a Prolog file from the directory where the requester's class would come from if it did not come from a jar file. Adds that directory to the library_directory relation, so modules can be found there

Specified by:
consultRelative in interface PrologEngine
Parameters:
filename - The Prolog file name, including suffix; if a path it should use '/' as the separator, independently of the OS
requester - Defines where the Prolog file resides

load_dynRelative

public String load_dynRelative(String filename,
                               Object requester)
Specified by:
load_dynRelative in interface PrologEngine

interrupt

public void interrupt()
Interrupt Prolog and make it return to its top level. This is the equivalent to performing a ctrl+c or similar command when using Prolog under a standard console shell.

Specified by:
interrupt in interface PrologEngine

command

public boolean command(String s)
Execute a Prolog "command"; except until the basic InterProlog is loaded, this in fact delegates to deterministicGoal, which synchonizes at the end and returns a reliable result.

Specified by:
command in interface PrologEngine

exec

public void exec(String S)
A command expected to always succeed; throws an IPException if it fails


realCommand

public abstract boolean realCommand(String s)
Implementation of a simple parameterless Prolog goal; does not support recursive nor multithreaded operation, use command instead

See Also:
command(String)

progressMessage

public void progressMessage(String s)
Debugging aid


progressMessage

public void progressMessage(String s,
                            Object X)

profilingMessage

public void profilingMessage(String s)
Profiling aid


isDebug

public boolean isDebug()
Debug messages are being written, both Java and Prolog side, cf. ipIsDebugging/0

Specified by:
isDebug in interface PrologEngine

setDebug

public void setDebug(boolean d)
Show (or hide) debug messages, both Java and Prolog side, cf. ipIsDebugging/0. Beware that this may try to assert/retract a flag (ipIsDebugging/0) on the Prolog side, be sure to invoke this method sooner rather than later as it may get "stuck" if there are problems communicating with the Prolog engine

Specified by:
setDebug in interface PrologEngine

isProfiling

public boolean isProfiling()

setProfiling

public void setProfiling(boolean d)

getLoadFromJar

public boolean getLoadFromJar()

printBindings

public static void printBindings(Object[] b)
Convenience for debugging deterministicGoal() messages


teachOneObject

public boolean teachOneObject(Object example)
Same as #teachMoreObjects(ObjectExamplePair[]), but the single example pair is constructed repeating the object

Specified by:
teachOneObject in interface PrologEngine
See Also:
teachMoreObjects(ObjectExamplePair[])

teachMoreObjects

public boolean teachMoreObjects(Object[] examples)
Same as #teachMoreObjects(ObjectExamplePair[]), but example pairs are constructed with (2) repeated examples for each object

Specified by:
teachMoreObjects in interface PrologEngine
See Also:
teachMoreObjects(ObjectExamplePair[])

teachMoreObjects

public boolean teachMoreObjects(ObjectExamplePair[] examples)
Send an array of object example pairs to Prolog and generate ipObjectSpec facts. Returns true if this succeeds, false otherwise.

Specified by:
teachMoreObjects in interface PrologEngine
Parameters:
examples - The examples
See Also:
ObjectExamplePair

teachMoreObjects

public boolean teachMoreObjects(ObjectExamplePair example)

deterministicGoal

public Object[] deterministicGoal(String G,
                                  String OVar,
                                  Object[] objectsP,
                                  String RVars)
Synchronously calls a Prolog goal. Only the first solution is considered. G should contain a syntactically correct Prolog term, without the trailing dot (.). Throws an IPAbortedException if a Prolog abort happens, and an IPInterruptedException if the interrupt() method was invoked.

Specified by:
deterministicGoal in interface PrologEngine
Parameters:
G - Prolog goal term
OVar - Prolog variable that will be bound to objectsP array
objectsP - Array of Java objects to pass to Prolog goal; nonserializable objects are encapsulated in InvisibleObject references
RVars - Prolog list with object specifications, typically containing variables occurring in g. If null a single binding will be returned, containing a TermModel object representing the goal term solution
Returns:
a new array containing an object for each term in the rVars list, or null if goal fails
See Also:
deterministicGoal(String), deterministicGoal(String,String), deterministicGoal(String,String,Object[])

deterministicGoal

public boolean deterministicGoal(String G)
A parameterless goal with no result other than success/failure. Same as deterministicGoal(G, null,null,"[]")

Specified by:
deterministicGoal in interface PrologEngine

deterministicGoal

public Object[] deterministicGoal(String G,
                                  String RVars)
Useful when you're constructing objects from Prolog, but don't need to pass any from Java. Same as deterministicGoal(G,null,null,RVars)

Specified by:
deterministicGoal in interface PrologEngine

deterministicGoal

public boolean deterministicGoal(String G,
                                 String OVar,
                                 Object[] objectsP)
Useful when you want to pass objects to Prolog but don't need objects returned. Same as deterministicGoal(G, OVar,objectsP,"[]")

Specified by:
deterministicGoal in interface PrologEngine

deterministicGoal

public TermModel deterministicGoal(TermModel G)
Useful for inter-Prolog goal calling through Java. For example, to call a goal G in another PrologEngine E: buildTermModel(G,GM), javaMessage(E,SM,deterministicGoal(GM)), recoverTermModel(SM,Solution)

Specified by:
deterministicGoal in interface PrologEngine

goal

public SolutionIterator goal(String G,
                             String OVar,
                             Object[] objectsP,
                             String RVars)
Similar to deterministicGoal, but rather than just the first solution returns an Iterator which lazily returns bindings for solutions. This method returns immediately, because the actual Prolog execution will happen on a different thread during the messages sent to the iterator. If G fails, the Iterator will have no elements.

Specified by:
goal in interface PrologEngine

goal

public SolutionIterator goal(String G,
                             String RVars)
Useful when you're constructing objects from Prolog, but don't need to pass any from Java. Same as goal(G,null,null,RVars)

Specified by:
goal in interface PrologEngine

lastSolutionUndefined

public boolean lastSolutionUndefined()
Specified by:
lastSolutionUndefined in interface PrologEngine

isIdle

public boolean isIdle()
The engine is doing nothing: no pending Prolog goals nor Java callbacks

Specified by:
isIdle in interface PrologEngine

endAllTasks

public void endAllTasks(Exception e)
Do not invoke this


abortTasks

public void abortTasks()
Do not invoke this. Due to the use of several Java packages in InterProlog this method must be qualified as public


interruptTasks

public void interruptTasks()
Do not invoke this. Due to the use of several Java packages in InterProlog this method must be qualified as public


isAvailable

public boolean isAvailable()
Present implementation is always available, so this always returns true. Subclass implementations should return false if the Prolog engine is not available for work, e.g. prompt was not yet recognized in a subprocess (socket) engine

Specified by:
isAvailable in interface PrologEngine

waitUntilAvailable

public void waitUntilAvailable()
Description copied from interface: PrologEngine
This method blocks until isAvailable() returns true.

Specified by:
waitUntilAvailable in interface PrologEngine

waitUntilIdle

public void waitUntilIdle()
Sleeps the current Java thread until this engine is idle. If this never happens, we're in trouble.

Specified by:
waitUntilIdle in interface PrologEngine

handleCallback

public Object handleCallback(Object x)
Handling of javaMessages and deterministicGoals. This is where most things happen.

Parameters:
x - Argument of the callback predicate

firstJavaMessage

public final void firstJavaMessage()
Dummy method, whose name is used to start the callback thread


doCallback

public ResultFromJava doCallback(Object x)
Execute a Prolog->Java call


isSerializable

public static boolean isSerializable(Object x)
Returns true if the object is Serializable or, being an array, its element type is primitive or Serializable


findMethod

public static Method findMethod(Class<?> targetClass,
                                String name,
                                Class<?>[] formalArguments)
                         throws NoSuchMethodException
An utility building on the functionality of getMethod(), to provide the javaMessage predicate with method argument polimorphism. If the type signatures do not match exactly, searches all method signatures to see if their arguments are type-compatible.

Throws:
NoSuchMethodException

findConstructor

public static Constructor findConstructor(Class<?> targetClass,
                                          Class<?>[] formalArguments)
                                   throws NoSuchMethodException
Similar to findMethod(), but for constructors rather than regular methods

Throws:
NoSuchMethodException

assignableType

public static boolean assignableType(Class<?> left,
                                     Class<?> right)
It is OK to assign an expression typed right to a variable typed left. Delegates on isAssignableFrom


shortClassName

public static String shortClassName(Class c)
Returns just the name of the class, with no package information. That is, if foo.bar.Mumble were the class passed in, the string "Mumble" would be returned. Similarly, if the class that is passed in is a.b.Class$InnerClass the string returned would be InnerClass.


registerJavaObject

public int registerJavaObject(Object x)
Register an object with this Engine, so it later can be referred from Prolog without serializing it.

Specified by:
registerJavaObject in interface PrologEngine
Parameters:
x - Object to be registered
Returns:
Integer denoting the object. In Prolog one can then refer to it by using the InvisibleObject class.
See Also:
InvisibleObject

makeInvisible

public Object makeInvisible(Object x)
Register an object with this Engine, so it later can be referred from Prolog without serializing it, and returns an InvisibleObject encapsulating the reference.

Specified by:
makeInvisible in interface PrologEngine
Parameters:
x - Object to be registered
Returns:
InvisibleObject denoting the object. In Prolog one can then refer to it by using the InvisibleObject class.
See Also:
InvisibleObject

getRealJavaObject

public Object getRealJavaObject(InvisibleObject o)
Get the object referred by the integer in a InvisibleObject wrapper.

Specified by:
getRealJavaObject in interface PrologEngine
Parameters:
o - An InvisibleObject
Returns:
The real object denoted by o in the context of this engine
See Also:
InvisibleObject

getRealJavaObject

public Object getRealJavaObject(int ID)
Same as getRealJavaObject(InvisibleObject), but accepts an integer ID as argument instead

Specified by:
getRealJavaObject in interface PrologEngine

getRealJavaObject

public Object getRealJavaObject(Object o)
Just returns the object, untouched (but "dereferenced" if called from Prolog). This serves the need to get objects in javaMessage because of the way CallbackHandler.doCallback works. For example: ipPrologEngine(_E), stringArraytoList(_O,[miguel,calejo]), javaMessage(_E,_R,getRealJavaObject(_O)),stringArraytoList(_R,List). ... will bind List to [miguel,calejo] and not to an InvisibleObject specification as ordinarly would happen

Specified by:
getRealJavaObject in interface PrologEngine

unregisterJavaObject

public boolean unregisterJavaObject(int ID)
Removes reference to the object from the registry. This method should be used with extreme caution since any further prolog calls to the object by means of reference to it in the registry might result in unpredictable behaviour.

Specified by:
unregisterJavaObject in interface PrologEngine

unregisterJavaObject

public boolean unregisterJavaObject(Object obj)
Removes reference to the object from the registry. This method should be used with extreme caution since any further prolog calls to the object by means of reference to it in the registry might result in unpredictable behaviour.

Specified by:
unregisterJavaObject in interface PrologEngine

unregisterJavaObjects

public boolean unregisterJavaObjects(Class cls)
Removes references to objects of class cls from the registry. This method should be used with extreme caution since any further prolog calls to the unregistered objects by means of reference to them in the registry might result in unpredictable behaviour.

Specified by:
unregisterJavaObjects in interface PrologEngine

setThreadedCallbacks

public void setThreadedCallbacks(boolean yes)
If true, the Java execution of javaMessage predicates will happen in new threads (default); if false, execution will be under the thread of the deterministicGoal currently executing in Prolog

Specified by:
setThreadedCallbacks in interface PrologEngine

isThreadedCallbacks

public boolean isThreadedCallbacks()

printAllStackTraces

public static String printAllStackTraces(boolean quiet)
If !quite, does not print to the standard (error) output


printAllStackTraces

public static String printAllStackTraces()

printStackTrace

public static void printStackTrace()

inPrologShell

public boolean inPrologShell()
We know the engine to be in the Prolog shell, so Prolog goals do not need a postfix. Subclasses supporting other languages over Prolog may need to redefine this

Specified by:
inPrologShell in interface PrologEngine

addPrologEngineListener

public void addPrologEngineListener(PrologEngineListener L)

removePrologEngineListener

public void removePrologEngineListener(PrologEngineListener L)

getThePrologListener

public PrologEngineListener getThePrologListener()
Kludgy method to be used only if a single listener exists; will throw an exception otherwise


stop

public void stop()
Gracefully stop the engine computation, unlike interrupt() which is brutal. Requires an EngineController to be set as the single PrologEngineListener


setTimedCallIntervall

public void setTimedCallIntervall(int ms)
If ms>0, all future deterministic goals will be executed under control so that the Java side is messaged (with @see#willWork messages) every ms, with the possibility to abort the Prolog computation, by having the Prolog engine interrupt normal execution periodically; otherwise the goal will run uninterrupted. At startup goals execute without willWork messages


prologCanWork

public String prologCanWork()
Never call this directly; the Prolog side does call this automatically during timed calls