org.semanticweb.xsb
Class XSBCore

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended byorg.semanticweb.xsb.XSBCore
All Implemented Interfaces:
java.rmi.Remote, java.io.Serializable, XSBCoreIntf
Direct Known Subclasses:
XSBCoreWrapper

public class XSBCore
extends java.rmi.server.UnicastRemoteObject
implements XSBCoreIntf

Description of the Class

Author:
Administrator, Andreas Harth
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
XSBCore()
          Constructor.
 
Method Summary
 java.lang.String xsb_answer_string(java.lang.String sep)
          xsb_answer_string returns an answer substitution as a string, the single answers separated by sep.
 int xsb_assert_fact(Literal fact)
          Asserts a Java representation of a fact
 int xsb_assert_rule(ProgramClause clause)
          Asserts a Java representation of a program clause
 int xsb_close_query()
          xsb_close_query() closes the current query, so that no more answers will be returned, and another query can be opened.
 int xsb_close()
          xsb_close() is currently just a noop, since it doesn't clean anything up, to allow a re-init.
 int xsb_command_string(java.lang.String command)
          xsb_command_string(char *goal) passes the command (e.g.
 int xsb_command_term(Term t)
          xsb_command_term(Term t) passes the command represented as a Java Term to xsb and executes it.
 int xsb_command()
          xsb_command() passes the command (i.e.
 Term[] xsb_get_answer_substitution()
          xsb_get_answer_substitution() returns an array of answer substitution, each variable corresponds to one position in the array.
 int xsb_init(java.lang.String[] args)
          xsb_init(String[] args) initializes the XSB engines.
 int xsb_next()
          xsb_next() causes xsb to return the next answer.
 int xsb_query_java(ProgramClause clause)
          Poses a query in a Java representation
 int xsb_query_string(java.lang.String command)
          xsb_query_string(String command) submits a query to xsb.
 int xsb_query_term(Term t)
          xsb_query_term(Term t) passes the query represented as a Java term to xsb.
 int xsb_query()
          xsb_query() passes the query to xsb.
 int xsb_retract_fact(Literal fact)
          Retracts a Java representation of a fact
 int xsb_retract_rule(ProgramClause clause)
          Retract the Java Representation of a Rule
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XSBCore

public XSBCore()
        throws java.rmi.RemoteException
Constructor.

Method Detail

xsb_init

public int xsb_init(java.lang.String[] args)
             throws java.rmi.RemoteException
xsb_init(String[] args) initializes the XSB engines. The first element of args must point to the XSB installation directory. The other parameter are usuall XSB startup parameter. A typical parameters are:
String[] args= {"/local/xsb/XSB", "-n", "--quietload"}; "-n" turns the interactive mode of
"--quitemode" prevents startup output from XSB

Specified by:
xsb_init in interface XSBCoreIntf
Parameters:
args - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_close

public int xsb_close()
              throws java.rmi.RemoteException
xsb_close() is currently just a noop, since it doesn't clean anything up, to allow a re-init.

Specified by:
xsb_close in interface XSBCoreIntf
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_command_string

public int xsb_command_string(java.lang.String command)
                       throws java.rmi.RemoteException
xsb_command_string(char *goal) passes the command (e.g. a query which only succeeds or fails) to xsb. The command must a string passed in the argument. It returns 0 if it succeeds, 1 if it fails, in either case resetting register 1 back to a free variabe. It returns 2 if there is an error.

Specified by:
xsb_command_string in interface XSBCoreIntf
Parameters:
command - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_command

public int xsb_command()
                throws java.rmi.RemoteException
xsb_command() passes the command (i.e. query with no variables) to xsb. The command must be put into xsb's register 1 as a term, by the caller who uses the c2p_* (and perhaps p2p_*) functions. It returns 0 if it succeeds, 1 if it fails, in either case resetting register 1 back to a free variable. It returns 2 if there is an error. Usually not called from Java.

Specified by:
xsb_command in interface XSBCoreIntf
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_command_term

public int xsb_command_term(Term t)
                     throws java.rmi.RemoteException
xsb_command_term(Term t) passes the command represented as a Java Term to xsb and executes it. It returns 0 if it succeeds, 1 if it fails, in either case resetting register 1 back to a free variable. It returns 2 if there is an error. Usage examples are eg. turning on tabling for a predicate.

Specified by:
xsb_command_term in interface XSBCoreIntf
Parameters:
t - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_query_string

public int xsb_query_string(java.lang.String command)
                     throws java.rmi.RemoteException
xsb_query_string(String command) submits a query to xsb. The string must be a goal that will be correctly read by xsb's reader, and it must be terminated with a period (.). The query will be parsed, and an answer term will be constructed where Y1, .... Yn are the variables in the parsed goal (in left-to-right order). The answer can be obtained with xsb_answer_string or xsb_getAnswerSubstitution. If the goal succeeds, xsb_query_string returns 0 and the first answer is in register 2. If it fails, xsb_query_string returns 1.

Specified by:
xsb_query_string in interface XSBCoreIntf
Parameters:
command - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_query

public int xsb_query()
              throws java.rmi.RemoteException
xsb_query() passes the query to xsb. The query must be put into xsb's register 1 as a term, by the caller who uses the c2p_* (and perhaps p2p_*) functions. It returns 0 if it succeeds, 1 if it fails, in either case resetting register 1 back to a free variable. It returns 2 if there is an error. Usually not called from Java.

Specified by:
xsb_query in interface XSBCoreIntf
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_query_term

public int xsb_query_term(Term t)
                   throws java.rmi.RemoteException
xsb_query_term(Term t) passes the query represented as a Java term to xsb. The query must be put into xsb's register 1 as a term, by the caller who uses the c2p_* (and perhaps p2p_*) functions. It returns 0 if it succeeds, 1 if it fails, in either case resetting register 1 back to a free variable. It returns 2 if there is an error. Usually not called from Java.

Specified by:
xsb_query_term in interface XSBCoreIntf
Parameters:
t - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_close_query

public int xsb_close_query()
                    throws java.rmi.RemoteException
xsb_close_query() closes the current query, so that no more answers will be returned, and another query can be opened. If the query was correctly closed, it resets xsb registers 1 and 2 to be variables, and returns 0. If there is some error, it returns 2.

Specified by:
xsb_close_query in interface XSBCoreIntf
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_answer_string

public java.lang.String xsb_answer_string(java.lang.String sep)
                                   throws java.rmi.RemoteException
xsb_answer_string returns an answer substitution as a string, the single answers separated by sep.

Specified by:
xsb_answer_string in interface XSBCoreIntf
Parameters:
sep - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_next

public int xsb_next()
             throws java.rmi.RemoteException
xsb_next() causes xsb to return the next answer. It (or xsb_close_query) must be called after xsb_query. If there is another answer, xsb_next returns 0 and the substitution can get obtained via xsb_getAnswerSubstitution or xsb_answer_string. Variables in goal term xsb_next returns 0 if the next answer is found, 1 if there are no more answers, and 3 if an error is encountered. If 1 is returned, then the query is automatically closed.

Specified by:
xsb_next in interface XSBCoreIntf
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_get_answer_substitution

public Term[] xsb_get_answer_substitution()
                                   throws java.rmi.RemoteException
xsb_get_answer_substitution() returns an array of answer substitution, each variable corresponds to one position in the array.

Specified by:
xsb_get_answer_substitution in interface XSBCoreIntf
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_assert_rule

public int xsb_assert_rule(ProgramClause clause)
                    throws java.rmi.RemoteException
Asserts a Java representation of a program clause

Specified by:
xsb_assert_rule in interface XSBCoreIntf
Parameters:
clause - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_retract_rule

public int xsb_retract_rule(ProgramClause clause)
                     throws java.rmi.RemoteException
Retract the Java Representation of a Rule

Specified by:
xsb_retract_rule in interface XSBCoreIntf
Parameters:
clause - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_assert_fact

public int xsb_assert_fact(Literal fact)
                    throws java.rmi.RemoteException
Asserts a Java representation of a fact

Specified by:
xsb_assert_fact in interface XSBCoreIntf
Parameters:
fact - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_retract_fact

public int xsb_retract_fact(Literal fact)
                     throws java.rmi.RemoteException
Retracts a Java representation of a fact

Specified by:
xsb_retract_fact in interface XSBCoreIntf
Parameters:
fact - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_query_java

public int xsb_query_java(ProgramClause clause)
                   throws java.rmi.RemoteException
Poses a query in a Java representation

Specified by:
xsb_query_java in interface XSBCoreIntf
Parameters:
clause - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException