Class JIPPrologEngine

java.lang.Object
  |
  +--JIPPrologEngine
All Implemented Interfaces:
PrologEngine

public class JIPPrologEngine
extends java.lang.Object
implements PrologEngine

A wrapper for the prolog engine-- this allows us to switch the implementation if need be. Designed around JIProlog.


Constructor Summary
JIPPrologEngine()
          Create a prolog engine.
 
Method Summary
 java.util.LinkedList multilineQuery(java.lang.String multiline)
          Query prolog with a bunch of lines, then get back the solution set for the last line.
 java.util.LinkedList query(java.lang.String prologCode)
          Query prolog and get back its replies.
 java.util.LinkedList query(java.lang.String prologCode, java.lang.String[] variableNames)
          Queries and returns the values of variables in the answer.
 void readFile(java.lang.String fileName)
          Read a file into the engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JIPPrologEngine

public JIPPrologEngine()
Create a prolog engine.

Method Detail

readFile

public void readFile(java.lang.String fileName)
Read a file into the engine.

Specified by:
readFile in interface PrologEngine
Throws:
java.lang.RuntimeException - if the load fails.

query

public java.util.LinkedList query(java.lang.String prologCode)
Query prolog and get back its replies.

Specified by:
query in interface PrologEngine
Parameters:
prologCode - the prolog code that forms the query.
Returns:
strings of the replies.
Throws:
java.lang.RuntimeException - for the inevitable screwup.

multilineQuery

public java.util.LinkedList multilineQuery(java.lang.String multiline)
Query prolog with a bunch of lines, then get back the solution set for the last line. Lines are split over the period character.

Specified by:
multilineQuery in interface PrologEngine
Parameters:
multiline - the multiline code, delimited by periods, that forms the query.
Returns:
the last response, and only the last response.
Throws:
java.lang.RuntimeException - when things go wrong.

query

public java.util.LinkedList query(java.lang.String prologCode,
                                  java.lang.String[] variableNames)
Queries and returns the values of variables in the answer.

Specified by:
query in interface PrologEngine
Parameters:
prologCode - the query.
Returns:
a LinkedList of string arrays parallel to the variables.
Throws:
java.lang.RuntimeException - for the usual bloody stupid mistakes you always make.