public interface PrologEngine
Modifier and Type | Field and Description |
---|---|
static int |
MAX_INT_VALUE
Maximum integer value in any supported Prolog.
|
static int |
MIN_INT_VALUE
Minimum integer value.
|
static String |
version
InterProlog version
|
Modifier and Type | Method and Description |
---|---|
boolean |
command(String s)
Execute a Prolog "command".
|
boolean |
consultAbsolute(File f)
Consults a Prolog file
|
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 reconsult it.
|
String |
consultFromPackage(String filename,
Object requester,
boolean firstTimeOnly)
Subsequent calls will be ignored
|
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.
|
PrologImplementationPeer |
getImplementationPeer() |
String |
getPrologBaseDirectory()
Returns the installation directory for the Prolog system, without the trailing separator char
|
String |
getPrologVersion()
Returns the Prolog system 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).
|
SolutionIterator |
goal(String G,
String RVars) |
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.
|
boolean |
inPrologShell() |
void |
interrupt()
Interrupt Prolog and make it return to its top level.
|
boolean |
isAvailable()
Returns a boolean value indicating whether the engine is available (that
is, ready to accept requests).
|
boolean |
isDebug()
Debug messages are being written, both Java and Prolog side, cf.
|
boolean |
isIdle()
This method returns true if this engine is idle (doing nothing: no pending Prolog goals nor Java callbacks), false otherwise.
|
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.
|
int |
registerJavaObject(Object x)
Register an object with this Engine, so it later can be referred from Prolog without serializing it.
|
void |
setDebug(boolean d)
Show (or hide) debug messages, both Java and Prolog side, cf.
|
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 |
shutdown()
Release Prolog engine resources, making it unusable
|
boolean |
teachMoreObjects(Object[] examples)
Same as #teachMoreObjects(ObjectExamplePair[]), but example pairs are
constructed with (2) repeated examples for each object.
|
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) |
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()
This method blocks until
isIdle() returns true. |
static final String version
static final int MAX_INT_VALUE
ObjectOutputStream
, because
static final int MIN_INT_VALUE
String getPrologVersion()
void shutdown()
String consultFromPackage(String filename, Object requester)
filename
- The Prolog file name, including extension; if it has no extension, the Prolog file extensions are appended in turn until a file is foundrequester
- Defines where the Prolog file residesconsultRelative(String, Object)
,
load_dynRelative(String, Object)
String consultFromPackage(String filename, Object requester, boolean firstTimeOnly)
void interrupt()
boolean command(String s)
boolean isDebug()
void setDebug(boolean d)
Object[] deterministicGoal(String G, String OVar, Object[] objectsP, String RVars)
G
- Prolog goal termOVar
- Prolog variable that will be bound to objectsP arrayobjectsP
- Array of Java objects to pass to Prolog goalRVars
- 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 solutiondeterministicGoal(String)
,
deterministicGoal(String,String)
,
deterministicGoal(String,String,Object[])
boolean deterministicGoal(String G)
Object[] deterministicGoal(String G, String RVars)
boolean deterministicGoal(String G, String OVar, Object[] objectsP)
TermModel deterministicGoal(TermModel G)
buildTermModel(G,GM), javaMessage(E,SM,deterministicGoal(GM)), recoverTermModel(SM,Solution)
SolutionIterator goal(String G, String OVar, Object[] objectsP, String RVars)
SolutionIterator goal(String G, String RVars)
boolean lastSolutionUndefined()
int registerJavaObject(Object x)
x
- Object to be registeredInvisibleObject
Object makeInvisible(Object x)
x
- Object to be registeredInvisibleObject
Object getRealJavaObject(InvisibleObject o)
o
- An InvisibleObjectInvisibleObject
Object getRealJavaObject(int ID)
Object getRealJavaObject(Object o)
boolean unregisterJavaObject(int ID)
boolean unregisterJavaObject(Object obj)
boolean unregisterJavaObjects(Class<?> cls)
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.boolean isAvailable()
void waitUntilAvailable()
isAvailable()
returns true.boolean isIdle()
void waitUntilIdle()
isIdle()
returns true.boolean teachOneObject(Object example)
teachMoreObjects(ObjectExamplePair[])
boolean teachMoreObjects(Object[] examples)
teachMoreObjects(ObjectExamplePair[])
boolean teachMoreObjects(ObjectExamplePair[] examples)
examples
- The examplesObjectExamplePair
boolean consultAbsolute(File f)
boolean load_dynAbsolute(File f)
String consultRelative(String filename, Object requester)
filename
- The Prolog file name, including suffix; if a path it should use '/' as the separator, independently of the OSrequester
- Defines where the Prolog file residesPrologImplementationPeer getImplementationPeer()
String getPrologBaseDirectory()
void setThreadedCallbacks(boolean yes)
boolean inPrologShell()