org.semanticweb.xsb
Class XSBCoreWrapper

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

public class XSBCoreWrapper
extends XSBCore
implements java.rmi.Remote

Wrapper for XSBCore to intercept calls and store the prolog source that go through XSBCore.

Author:
Andreas Harth
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
XSBCoreWrapper()
          Constructor.
 
Method Summary
static void main(java.lang.String[] args)
          Main method.
 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_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_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 org.semanticweb.xsb.XSBCore
xsb_command, xsb_get_answer_substitution, xsb_init, xsb_next, xsb_query
 
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

XSBCoreWrapper

public XSBCoreWrapper()
               throws java.rmi.RemoteException
Constructor. Open a file where the commands that are sent to xsb are stored.

Method Detail

xsb_close

public int xsb_close()
              throws java.rmi.RemoteException
Description copied from class: XSBCore
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
Overrides:
xsb_close in class XSBCore
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
Description copied from class: XSBCore
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
Overrides:
xsb_command_string in class XSBCore
Parameters:
command - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_command_term

public int xsb_command_term(Term t)
                     throws java.rmi.RemoteException
Description copied from class: XSBCore
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
Overrides:
xsb_command_term in class XSBCore
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
Description copied from class: XSBCore
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
Overrides:
xsb_query_string in class XSBCore
Parameters:
command - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.rmi.RemoteException

xsb_query_term

public int xsb_query_term(Term t)
                   throws java.rmi.RemoteException
Description copied from class: XSBCore
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
Overrides:
xsb_query_term in class XSBCore
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
Description copied from class: XSBCore
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
Overrides:
xsb_close_query in class XSBCore
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
Description copied from class: XSBCore
xsb_answer_string returns an answer substitution as a string, the single answers separated by sep.

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

xsb_assert_rule

public int xsb_assert_rule(ProgramClause clause)
                    throws java.rmi.RemoteException
Description copied from class: XSBCore
Asserts a Java representation of a program clause

Specified by:
xsb_assert_rule in interface XSBCoreIntf
Overrides:
xsb_assert_rule in class XSBCore
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
Description copied from class: XSBCore
Retract the Java Representation of a Rule

Specified by:
xsb_retract_rule in interface XSBCoreIntf
Overrides:
xsb_retract_rule in class XSBCore
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
Description copied from class: XSBCore
Asserts a Java representation of a fact

Specified by:
xsb_assert_fact in interface XSBCoreIntf
Overrides:
xsb_assert_fact in class XSBCore
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
Description copied from class: XSBCore
Retracts a Java representation of a fact

Specified by:
xsb_retract_fact in interface XSBCoreIntf
Overrides:
xsb_retract_fact in class XSBCore
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
Description copied from class: XSBCore
Poses a query in a Java representation

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

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Main method.

Throws:
java.lang.Exception