public class PLGoal
extends java.lang.Object
Constructor and Description |
---|
PLGoal(PLConnection where,
PLTerm term)
Goal constructor.
|
PLGoal(PLConnection where,
java.lang.String term)
Goal constructor.
|
PLGoal(PLTerm term)
Goal constructor.
|
PLGoal(java.lang.String term)
Goal constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
execute()
Sends to Prolog process a request for the execution of this
goal, and returns immediately.
|
protected void |
finalize()
Destructor.
|
PLConnection |
getConnection()
Gets connection that this goal uses to communicate to
Prolog.
|
boolean |
isStillRunning()
Checks if Prolog is still running this query, or there are
solutions that have not been requested.
|
PLTerm |
nextSolution()
Sends to Prolog process a request for the next query solution.
|
void |
query()
Goal query.
|
void |
terminate()
Terminates this Prolog goal execution.
|
java.lang.String |
toString()
String representation of a Prolog goal.
|
void |
useModule(PLTerm module)
This method loads a module in the Prolog process.
|
void |
useModule(java.lang.String module)
This method loads a module in the Prolog process.
|
public PLGoal(PLTerm term) throws PLException
term
.term
- Prolog term that represents the goal that
will be evaluated.PLException
- if there is no
connection to Prolog.PLException
public PLGoal(PLConnection where, PLTerm term)
where
Prolog
process, using the Prolog term represented with term
.where
- Prolog process on which the goal must
be evaluated.term
- Prolog term that represents the goal that
will be evaluated. This term must be a
PLStructure
object or a
PLAtom
object.public PLGoal(java.lang.String term) throws java.io.IOException, PLException
term
.term
- String containing the representation of a
well formed Prolog term that represents
the goal that will be evaluated.
This term must be a
PLStructure
object or a
PLAtom
object.PLException
- if there is no
connection to Prolog.java.io.IOException
PLException
public PLGoal(PLConnection where, java.lang.String term) throws java.io.IOException, PLException
where
Prolog
process, using the Prolog term represented with termString
string. This string must be a well formed Prolog term; otherwise a
PLException
will be thrown. This method connects to
Prolog to parse the string containing the goal.where
- Prolog process on which the goal must
be evaluated.term
- String containing the representation of a
well formed Prolog term that represents
the goal that will be evaluated.
This term must be a
PLStructure
object or a
PLAtom
object.java.io.IOException
PLException
public void query() throws java.io.IOException, PLException
PLConnection
associated object the
goal represented by this object. To obtain the solutions of this
goal, the nextSolution()
method must be called, once for
each solution.IOException
,
- PLException
if there is any problem
communicating with the Prolog process, or in the
Prolog side (e.g., the predicate to be launched
does not exist, or the goal has been launched yet).java.io.IOException
PLException
public PLTerm nextSolution() throws java.io.IOException, PLException
IOException
- if there are any error on
the sockets.PLException
- if there are any error on
the Prolog process. If the Prolog goal raises an
exception, it is propagated through the interface,
and a PLException
is raised in the
user Java program.java.io.IOException
PLException
public boolean execute() throws java.io.IOException, PLException
true
if the goal was launched successfullyIOException
- if there are any error on
the sockets.PLException
- if there are any error on
the Prolog process. If the Prolog goal raises an
exception, it is propagated through the interface,
and a PLException
is raised in the
user Java program.java.io.IOException
PLException
public boolean isStillRunning() throws PLException, java.io.IOException
nextSolution()
returns null
to ensure that there are no more solutions to request to
this goal.nextSolution()
requests.IOException
- if there are any error on
the sockets.PLException
- if there are any error on
the Prolog process. If the Prolog goal raises an
exception, it is propagated through the interface,
and a PLException
is raised in the
user Java program.PLException
java.io.IOException
public void terminate() throws java.io.IOException, PLException
java.io.IOException
- if there are any error on the socket
communicationPLException
- if there are any error on the Prolog
processpublic void useModule(PLTerm module) throws java.io.IOException, PLException
module
- Prolog term that represents the name of the module
to be loaded. Can be used the library(module) format.java.io.IOException
- if there are any I/O error with the socketsPLException
- if there are any error in the Prolog processpublic void useModule(java.lang.String module) throws java.io.IOException, PLException
module
- String that contains a Prolog term with the name of
the module to be loaded. Can be used the
library(module) format. The path must be accesible
to the Prolog server.java.io.IOException
- if there are any I/O error with the socketsPLException
- if there are any error in the Prolog processprotected void finalize() throws java.io.IOException, PLException, java.lang.Throwable
finalize
in class java.lang.Object
java.io.IOException
PLException
java.lang.Throwable
public java.lang.String toString()
toString
in class java.lang.Object
String
object representing
this Prolog goal.public PLConnection getConnection()
PLConnection
object representing
current connection to Prolog side.