se.sics.jasper
Class PrologEngine

java.lang.Object
  |
  +--se.sics.jasper.PrologEngine

public class PrologEngine
extends java.lang.Object

Objects of this class represent a Prolog engine running in a separate process.


Constructor Summary
PrologEngine(java.lang.String[] cmdarray)
          Starts a new Prolog process on the local machine
PrologEngine(java.lang.String machine, int portNum)
          Connect to a running Prolog process on 'machine:portNum'.
 
Method Summary
static int cbTestMethod(int x, double y)
           
static java.lang.Object cbTestMethod(java.lang.Integer obj, int x, double y)
           
 boolean compile(java.lang.String filename)
          Instruct the Prolog engine to compile a file.
 boolean consult(java.lang.String filename)
          Instruct the Prolog engine to consult a file.
protected  void finalize()
           
static java.lang.String getNextLine(java.io.BufferedReader reader)
          Returns next non-empty line from 'reader' which does not start with '#'.
 void halt()
           
static void main(java.lang.String[] argv)
           
 boolean query(java.lang.Object[] querySpec)
          Ask a Prolog query given an array of Java objects.
 boolean query(java.lang.String query)
          Ask a query to the Prolog engine
 boolean restore(java.lang.String filename)
          Instruct the Prolog engine to restore a saved state.
static void writeLine(java.io.BufferedWriter writer, java.lang.String str)
          Writes a string to a BufferedWriter, adds a newline and flushes the stream
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrologEngine

public PrologEngine(java.lang.String[] cmdarray)
             throws java.io.IOException,
                    ConnectionFailedException,
                    PrologException
Starts a new Prolog process on the local machine

PrologEngine

public PrologEngine(java.lang.String machine,
                    int portNum)
             throws java.io.IOException,
                    ConnectionFailedException,
                    PrologException
Connect to a running Prolog process on 'machine:portNum'.
Method Detail

cbTestMethod

public static int cbTestMethod(int x,
                               double y)

cbTestMethod

public static java.lang.Object cbTestMethod(java.lang.Integer obj,
                                            int x,
                                            double y)

getNextLine

public static java.lang.String getNextLine(java.io.BufferedReader reader)
                                    throws java.io.IOException
Returns next non-empty line from 'reader' which does not start with '#'. Returns null on EOF.

writeLine

public static void writeLine(java.io.BufferedWriter writer,
                             java.lang.String str)
                      throws java.io.IOException
Writes a string to a BufferedWriter, adds a newline and flushes the stream

finalize

protected void finalize()
                 throws java.io.IOException,
                        java.lang.InterruptedException
Overrides:
finalize in class java.lang.Object

halt

public void halt()
          throws java.io.IOException,
                 java.lang.InterruptedException

query

public boolean query(java.lang.String query)
              throws java.io.IOException,
                     PrologException
Ask a query to the Prolog engine

query

public boolean query(java.lang.Object[] querySpec)
              throws java.io.IOException,
                     PrologException
Ask a Prolog query given an array of Java objects. This method is used if you need to send (references to) Java objects to Prolog.

consult

public boolean consult(java.lang.String filename)
                throws java.io.IOException,
                       PrologException
Instruct the Prolog engine to consult a file. This will cause the Prolog engine to perform the query "['']."

compile

public boolean compile(java.lang.String filename)
                throws java.io.IOException,
                       PrologException
Instruct the Prolog engine to compile a file. This will cause the Prolog engine to perform the query "compile('')."

restore

public boolean restore(java.lang.String filename)
                throws java.io.IOException,
                       PrologException
Instruct the Prolog engine to restore a saved state. This will cause the Prolog engine to perform the query "restore('')."

main

public static void main(java.lang.String[] argv)