public interface Prolog
SICStus
and an inner class in
Jasper
inherit from this interface. These methods
should be used to call SICStus runtime in both multi threaded and single
threaded mode. When using the Prolog-Java interface in single thread mode,
the methods of this interface are preferred over the old methods of the class
SICStus
.Modifier and Type | Method and Description |
---|---|
Term |
consFunctor(java.lang.String functor,
Term[] args)
Creates a term initialized to a compound term.
|
Term |
consList(Term head,
Term tail)
Creates a term initialized to a list with given head and tail.
|
se.sics.jasper.Server |
getServer()
For internal use by Jasper.
|
Term |
listFromString(java.lang.String str)
Creates a term initialized to a list of character codes from a Java
String . |
Term |
newObjectTerm(java.lang.Object obj)
Creates a term initialized to a *global* reference to a Java object.
|
Term |
newTerm()
Creates a null-term (i.e. the empty list, '[]').
|
Term |
newTerm(double d)
Creates a term initialized to a Prolog float.
|
Term |
newTerm(float f)
Creates a term initialized to a Prolog float.
|
Term |
newTerm(int i)
Creates a term initialized to a Prolog integer from a Java
int . |
Term |
newTerm(long j)
Creates a term initialized to a Prolog integer from a Java
long . |
Term |
newTerm(java.lang.String a)
Creates a term initialized to a Prolog atom.
|
Term |
newTerm(java.lang.String functor,
Term[] args)
Creates a term initialized to a Prolog compound term.
|
Term |
newTerm(Term t)
Creates a term initialized to an existing term.
|
Term |
newVariable()
Creates a term initialized to an unbound variable.
|
Term |
numberFromString(java.lang.String str)
Creates a term initialized to a Prolog number from a string.
|
Query |
openPrologQuery(java.lang.String string,
java.util.Map varMap)
Opens a query, specified as a string, for obtaining multiple solutions.
|
Term |
prologReadFromString(java.lang.String string,
java.util.Map varMap)
Creates a term by reading from a string.
|
boolean |
query(java.lang.String string,
java.util.Map varMap)
Finds the first solution to a query specified as a string.
|
boolean |
queryCutFail(java.lang.String string,
java.util.Map varMap)
Finds the first solution to a query specified as a string, then cuts away
any choicepoints and fails, i.e. ignores everything but the side-effects
during the first solution.
|
se.sics.jasper.Server getServer()
Query openPrologQuery(java.lang.String string, java.util.Map varMap) throws java.lang.NoSuchMethodException, java.lang.InterruptedException, java.lang.Exception
nextSolution
to do that. When
no more solutions are needed, the query must be closed using methods
close
or
cut
on the query-object.
Multiple queries can be open at the same time. See
nextSolution
for details and
restrictions.
string
- The goal to use for the query, with terminating period.varMap
- The arguments to the predicate as a map from variable names to
Term objects. The map will get entries added for all variables
(with names not starting with underscore) in the goal that
were not already present as input. May be null.query
object.java.lang.NoSuchMethodException
- Undocumentedjava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedQuery.nextSolution()
,
Query.close()
,
Query.cut()
boolean query(java.lang.String string, java.util.Map varMap) throws java.lang.NoSuchMethodException, java.lang.InterruptedException, java.lang.Exception
openPrologQuery
.string
- The goal to use for the query, with terminating period.varMap
- The arguments to the predicate as a map from variable names to
Term objects. On success varMap will get entries added for all
variables (with names not starting with underscore) in the
goal that were not already present as input. May be null.java.lang.NoSuchMethodException
- Undocumentedjava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedopenPrologQuery(java.lang.String, java.util.Map)
,
queryCutFail(java.lang.String, java.util.Map)
,
Term
boolean queryCutFail(java.lang.String string, java.util.Map varMap) throws java.lang.NoSuchMethodException, java.lang.InterruptedException, java.lang.Exception
string
- The goal to use for the query, with terminating period.varMap
- The arguments to the predicate as a map from variable names to
Term objects. May be null. No bindings are added.java.lang.NoSuchMethodException
- Undocumentedjava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedquery(java.lang.String, java.util.Map)
Term newTerm() throws java.lang.InterruptedException, java.lang.Exception
java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(Term t) throws java.lang.InterruptedException, java.lang.Exception
t
- The Term object whose term to usejava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(int i) throws java.lang.InterruptedException, java.lang.Exception
int
.i
- Initial value of the integer.java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(long j) throws java.lang.InterruptedException, java.lang.Exception
long
.j
- Initial value of the integer (long).java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(double d) throws java.lang.InterruptedException, java.lang.Exception
d
- Initial value of the float.java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(float f) throws java.lang.InterruptedException, java.lang.Exception
f
- Initial value of the float.java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(java.lang.String a) throws java.lang.InterruptedException, java.lang.Exception
a
- String describing the initial value of the atom.java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newTerm(java.lang.String functor, Term[] args) throws java.lang.InterruptedException, java.lang.Exception
functor
- The functor of the compound term as a stringargs
- The arguments as an array of Termsjava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm prologReadFromString(java.lang.String string, java.util.Map varMap) throws java.lang.InterruptedException, java.lang.Exception
string
- The printed representation of the term, with terminating
period.varMap
- Bindings for any variables occurring in the term, as a map
from variable names to Term objects. The map will get entries
added for all variables (with names not starting with
underscore) in the term that were not already present as
input. May be null.java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newVariable() throws java.lang.InterruptedException, java.lang.Exception
java.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm consFunctor(java.lang.String functor, Term[] args) throws java.lang.InterruptedException, java.lang.Exception
functor
- The term's name as a Java String
args
- The arguments of the termjava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm consList(Term head, Term tail) throws java.lang.InterruptedException, java.lang.Exception
head
- The head of the listtail
- The tail of the listjava.lang.InterruptedException
- the thread was interruptedjava.lang.Exception
- some other problem happenedTerm newObjectTerm(java.lang.Object obj) throws IllegalTermException, ConversionFailedException, java.lang.Exception
obj
- A reference to a Java object.IllegalTermException
- an invalid term was detectedConversionFailedException
- the argument could not be converted to a termjava.lang.Exception
- some other problem happenedTerm numberFromString(java.lang.String str) throws ConversionFailedException, IllegalTermException, java.lang.Exception
str
- The string containing the printed representation of the
number.ConversionFailedException
- the argument could not be converted to a termIllegalTermException
- an invalid term was detectedjava.lang.Exception
- some other problem happenedTerm listFromString(java.lang.String str) throws ConversionFailedException, IllegalTermException, java.lang.Exception
String
.str
- The string of characters.ConversionFailedException
- the argument could not be converted to a termIllegalTermException
- an invalid term was detectedjava.lang.Exception
- some other problem happened