se.sics.prologbeans
Class PrologSession

PrologSession handles the connection with the Prolog Server. Currently only synchronous connections with the server are supported.

Constructor Summary
PrologSession()
         Creates a new PrologSession instance with default Prolog server settings.

Property Summary
bool AlwaysClose
        
bool AlwaysClosing
        
bool AutoConnecting
         Returns the state of the auto connect mode.
bool Connected
         Returns true if a connection with the Prolog server is open and false otherwise.
string Host
         Returns the host of the Prolog server (exactly as registered in setHost). Sets the host of the Prolog server (default is localhost). The host can be specified as either IP-address or host name.
int Port
         Returns the port of the Prolog server. Sets the port of the Prolog server (default 8066).
int Timeout
         Returns the timeout in milliseconds before the connection to the Prolog server is reset (when a query is not answered). Sets the timeout in milliseconds before the connection to the Prolog server is reset (when a query is not answered). Setting the timeout to 0 will disable timeouts for this prolog session. Default is 2000 milliseconds.

Method Summary
void connect()
         Connects to the Prolog server. By default executeQuery will automatically connect to the server when called.
void disconnect()
         Closes the connection with the Prolog server. The connection can be opened again with connect.
se.sics.prologbeans.QueryAnswer executeQuery(string query, se.sics.prologbeans.Bindings bindings, string sessionID)
         Sends a query to the Prolog server and waits for the answer before returning the QueryAnswer. Bindings are variable bindings for the given query and will ensure that the values are stuffed correctly.
se.sics.prologbeans.QueryAnswer executeQuery(string query, se.sics.prologbeans.Bindings bindings)
         Sends a query to the Prolog server and waits for the answer before returning the QueryAnswer. Bindings are variable bindings for the given query and will ensure that the values are stuffed correctly.

An example:

QueryAnswer answer = executeQuery("evaluate(In,Out)",
            new Bindings().bind("In","4*9."));
            

se.sics.prologbeans.QueryAnswer executeQuery(string query)
         Sends a query to the Prolog server and waits for the answer before returning the QueryAnswer. Anonymous variables (underscore, _), will be ignored, and thus not accessible in the QueryAnswer. executeQuery throws IOException if communication problems with the server occurs. Please note: executeQuery will only return one answer.

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Constructor Detail

PrologSession

public PrologSession()

Creates a new PrologSession instance with default Prolog server settings.

Property Detail

AlwaysClose

public bool AlwaysClose


AlwaysClosing

public bool AlwaysClosing


AutoConnecting

public bool AutoConnecting

Returns the state of the auto connect mode.


Connected

public bool Connected

Returns true if a connection with the Prolog server is open and false otherwise.


Host

public string Host

Returns the host of the Prolog server (exactly as registered in setHost). Sets the host of the Prolog server (default is localhost). The host can be specified as either IP-address or host name.


Port

public int Port

Returns the port of the Prolog server. Sets the port of the Prolog server (default 8066).


Timeout

public int Timeout

Returns the timeout in milliseconds before the connection to the Prolog server is reset (when a query is not answered). Sets the timeout in milliseconds before the connection to the Prolog server is reset (when a query is not answered). Setting the timeout to 0 will disable timeouts for this prolog session. Default is 2000 milliseconds.

Method Detail

connect

public void connect()

Connects to the Prolog server. By default executeQuery will automatically connect to the server when called.


disconnect

public void disconnect()

Closes the connection with the Prolog server. The connection can be opened again with connect.


executeQuery

public se.sics.prologbeans.QueryAnswer executeQuery(string query,
                                                    se.sics.prologbeans.Bindings bindings,
                                                    string sessionID)

Sends a query to the Prolog server and waits for the answer before returning the QueryAnswer. Bindings are variable bindings for the given query and will ensure that the values are stuffed correctly.

Parameters:
query - the query to send to the prolog server The characters in the query are restricted to ISO-8859-1.
bindings - the variable bindings to use in the query
sessionID - the session id to give to the prolog server
Returns:
the answer from the prolog server
Throws:
System.IO.IOException - if an error occurs. A possible cause is a timeout.

executeQuery

public se.sics.prologbeans.QueryAnswer executeQuery(string query,
                                                    se.sics.prologbeans.Bindings bindings)

Sends a query to the Prolog server and waits for the answer before returning the QueryAnswer. Bindings are variable bindings for the given query and will ensure that the values are stuffed correctly.

An example:

QueryAnswer answer = executeQuery("evaluate(In,Out)",
            new Bindings().bind("In","4*9."));
            

Parameters:
query - the query to send to the prolog server The characters in the query are restricted to ISO-8859-1.
bindings - the variable bindings to use in the query
Returns:
the answer from the prolog server
Throws:
System.IO.IOException - if an error occurs. A possible cause is a timeout.

executeQuery

public se.sics.prologbeans.QueryAnswer executeQuery(string query)

Sends a query to the Prolog server and waits for the answer before returning the QueryAnswer. Anonymous variables (underscore, _), will be ignored, and thus not accessible in the QueryAnswer. executeQuery throws IOException if communication problems with the server occurs. Please note: executeQuery will only return one answer.

Parameters:
query - the query to send to the prolog server The characters in the query are restricted to ISO-8859-1.
Returns:
the answer from the prolog server
Throws:
System.IO.IOException - Thrown if an error occurs. A possible cause is a timeout.