|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--CiaoJava.PLConnection
Class for managing communication to Prolog.
Starts and handles a connection to a Prolog process via sockets.
The PLConnection can be used in two ways, using the
CiaoJava
interface as a Java
object server (using PLConnection()
),
or as a connection to a Prolog query server
(using PLConnection(java.lang.String)
).
Working with a Prolog server using the Java side as a
client, the Prolog goals can be launched using
query(CiaoJava.PLTerm)
method with a PLTerm
object representing a goal
(PLAtoms
and PLStructures
)
or creating and using PLGoal
objects.
Constructor Summary | |
PLConnection()
Creates a new PLConnection object, establishing
a new socket server and listening Prolog connections on a
free port. |
|
PLConnection(java.net.ServerSocket ss)
Creates a new PLConnection object, given an existing socket server. |
|
PLConnection(java.lang.String where)
Creates a new PLConnection object that executes the
Prolog server, and starts it. |
Method Summary | |
void |
close()
Deprecated. This method is deprecated. Use stop
method instead. |
CiaoJava.PLInterpreter |
getInterpreter()
Gets the Prolog Interpreter object used to interpret Prolog terms received from the Prolog side of the interface. |
static PLConnection |
getPreviousConnection()
Returns the last started connection to a Prolog process. |
void |
join()
Waits until all the internal threads terminate. |
PLGoal |
query(PLTerm term)
Goal launching. |
void |
start()
Starts the PLConnection for the Prolog-to-Java interface: waits for a Prolog connection. |
void |
stop()
Stops the interface. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PLConnection() throws PLException, java.io.IOException
PLConnection
object, establishing
a new socket server and listening Prolog connections on a
free port.
The port number on which it listens is printed out on the
standard output stream.
Once a Prolog process connects to it, starts the internal
threads to manage the communication.public PLConnection(java.lang.String where) throws PLException, java.io.IOException
PLConnection
object that executes the
Prolog server, and starts it.where
- The command-line to start the Prolog process.
This constructor forces that the connection be
established to the newly created Prolog
process, instead of waiting for any Prolog
client that wants to connect to it.public PLConnection(java.net.ServerSocket ss) throws PLException, java.io.IOException
ss
- ServerSocket
object representing a new
Prolog/Java server socket object.Method Detail |
public void start() throws java.io.IOException, PLException
java.io.IOException
- if there are I/O problems.PLException
- if there are problems regarding the Prolog
process.public CiaoJava.PLInterpreter getInterpreter()
public PLGoal query(PLTerm term) throws PLException, java.io.IOException
goal
- Prolog term that will be evaluated as a Prolog
goal.PLGoal
object created to manage the goal.java.io.IOException
- if there are I/O problems.PLException
- if there are problems regarding the Prolog
process.public void close() throws java.lang.InterruptedException, java.io.IOException, PLException
stop
method instead.
java.io.IOException
- if the socket stream has been broken.PLException
- if there are problems regarding the Prolog
process.public void stop() throws java.lang.InterruptedException, java.io.IOException, PLException
java.io.IOException
- if the socket stream has been broken.PLException
- if there are problems regarding the Prolog
process.public void join() throws java.lang.InterruptedException
public static PLConnection getPreviousConnection()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |