|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--CiaoJava.PLConnection
Starts and handles a connection to a Prolog process
via sockets.
The PLConnection can be used in two ways, so the
CiaoJava
interface can work as a Java
object server (using the constructor with no arguments),
or as a connection to a Prolog query server.
Working with a Prolog server using the Java side as a
client, the Prolog goals can be launched using the launchGoal
method with a PLTerm
object representing a goal
(those terms where the isRunnable() method returns true),
or creating and using PLGoal
objects.
Field Summary | |
private boolean |
allowThreads
|
private static PLTerm |
DATA_SYNC
|
private static PLTerm |
EVENT_SYNC
|
private java.io.BufferedReader |
evIn
|
private java.io.PrintWriter |
evOut
|
private java.io.BufferedReader |
plIn
|
private java.io.PrintWriter |
plOut
|
private java.lang.Process |
plProc
Private fields. |
Constructor Summary | |
PLConnection()
Creates a PLConnection for the Prolog-to-Java interface: waits for a Prolog process that wants to connect to it. |
|
PLConnection(java.lang.String where)
Creates a PLConnection to use the Java-to-Prolog interface. |
Method Summary | |
boolean |
allowThreads()
Asks the Prolog server if it can work with threads. |
private void |
createSockets(java.io.PrintStream out)
This private method creates and synchronizes the sockets for communication with the Prolog process. |
protected PLTerm |
fromProlog()
Prolog-to-Java communication. |
private PLTerm |
fromProlog(java.io.BufferedReader in)
Low level Prolog-to-Java communication. |
PLGoal |
query(PLTerm term)
Goal launching. |
protected void |
toProlog(PLTerm term)
Low level Java-to-Prolog communication. |
private void |
toProlog(java.io.PrintWriter out,
PLTerm term)
Low level Java-to-Prolog communication. |
protected void |
toPrologEvent(PLTerm term)
Low level Java-to-Prolog event communication. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.lang.Process plProc
private boolean allowThreads
private java.io.BufferedReader plIn
private java.io.PrintWriter plOut
private java.io.BufferedReader evIn
private java.io.PrintWriter evOut
private static final PLTerm DATA_SYNC
private static final PLTerm EVENT_SYNC
Constructor Detail |
public PLConnection(java.lang.String where) throws java.io.IOException, PLException
where
- command used to start the Prolog server process.public PLConnection() throws java.io.IOException, PLException
Method Detail |
public boolean allowThreads()
private void createSockets(java.io.PrintStream out) throws java.io.IOException, PLException
public PLGoal query(PLTerm term) throws PLException, java.io.IOException
goal
- Prolog term that will be evaluated as a Prolog
goal.PLGoal
created to manage the goal.protected void toProlog(PLTerm term)
term
- is an object representing a Prolog term.protected void toPrologEvent(PLTerm term)
term
- is an object representing a Prolog term.private void toProlog(java.io.PrintWriter out, PLTerm term)
out
- is the socket output stream to send the
term through.term
- is an object representing a Prolog term.protected PLTerm fromProlog() throws java.io.IOException, PLException
private PLTerm fromProlog(java.io.BufferedReader in) throws java.io.IOException, PLException
in
- socket input stream to receive the Prolog data.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |