Class JFril

java.lang.Object
  |
  +--JFril

public class JFril
extends java.lang.Object

Java class which contains a native library implementation of Fril. This can be called via

This documentation is not yet complete


Field Summary
static int JFRILATOM
          Value returned by jFrilGetItemType indicating the argument is a Fril constant
static int JFRILFAILED
          Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query failed
static int JFRILFLOAT
          Value returned by jFrilGetItemType indicating that the argument is a Fril float
static int JFRILFSET
          Value returned by jFrilGetItemType indicating that the argument is a Fril fuzzy set
static int JFRILFSITEM
          Constant used to reference the bound answer variable when calling jFrilGetItemType or jFrilGetXXX after jFrilFindSolution
static int JFRILFSLIST
          Constant used to reference the bound answer variable when calling jFrilGetItemType or jFrilGetXXX after jFrilFindSolution
static int JFRILINT
          Value returned by jFrilGetItemType indicating that the argument is a Fril integer
static int JFRILINTERRUPT
          Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query was interrupted
static int JFRILLIST
          Value returned by jFrilGetItemType indicating that the argument is a Fril list
static int JFRILREQUESTINPUT
          Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query has requested input
static int JFRILSUCCEEDED
          Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query succeeded
static int JFRILTERMINATED
          Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query cannot be executed because Fril has terminated
static int JFRILVBLE
          Value returned by jFrilGetItemType indicating that the argument is a Fril variable
static boolean resultFrilCall
          resultFrilCall is used internally for communication with the embedded Fril library code
 
Constructor Summary
JFril()
          Creates a JFril object.
JFril(java.io.Writer stdOut)
          Creates a JFril object which directs all its output to the Writer stdOut.
JFril(java.io.Writer stdOut, java.lang.String initialCommand)
          Creates a JFril object which directs all its output to the Writer stdOut.
 
Method Summary
static java.lang.Integer jFrilCreateList(int len)
           
static void jFrilDisplayOutput(java.lang.String buf)
          method used internally for communication with the embedded Fril library code
static int jFrilExecuteFril(java.io.BufferedReader stdIn)
          Calls Fril to execute the input supplied by the BufferedReader stdIn.
static int jFrilExecuteFril(java.lang.String frilInput)
          Calls Fril to execute the input supplied in the String frilInput.
static int jFrilExecuteGoal(java.lang.String inbuf)
          Calls Fril to execute a goal created using the low level interface functions and passed to Fril by putgoal.
static int jFrilFindSolution(java.io.BufferedReader stdIn)
          Calls Fril to execute the input supplied by the BufferedReader stdIn and finds a binding for a target variable or pattern.
static int jFrilFindSolution(java.lang.String frilInput)
          Calls Fril to execute the input contained in the String frilInput and finds a binding for a target variable or pattern.
static java.lang.Integer jFrilGetArgs()
          Low level interface function which returns an Integer identifying the Fril argument list.
static java.lang.String jFrilGetAtom(int listID, int item)
          Low level interface function used to extract a Fril constant (string) from a Fril list.
static java.lang.Float jFrilGetFloat(int listID, int item)
          Low level interface function used to extract a Fril float from a Fril list.
static java.lang.Integer jFrilGetInt(int listID, int item)
          Low level interface function used to extract an integer from a Fril list.
static java.lang.Integer jFrilGetItemType(int listID, int item)
           
static java.lang.Integer jFrilGetList(int listID, int item)
          Low level interface function used to extract an identifier for a Fril list contained within a Fril list.
static java.lang.Integer jFrilGetListLen(int listID)
          Low level interface function used to determine the length of the list referenced by the identifier listid.
static boolean jFrilGetStatus()
           
static java.lang.String jFrilGetVersion()
           
static void jFrilInitialiseInterface()
          jFrilInitialiseInterface initialises the low level Fril-java interface, by clearing structures created during previous transfer of information across the interface.
static boolean jFrilPutArg(int listID1, int item1, int listID2, int item2)
          Low level interface function normally used to bind two variables.
static boolean jFrilPutAtom(int listID, int item, java.lang.String val)
          Low level interface function used to set the itemth element in the list identified by listID to the constant (String) value val.
static boolean jFrilPutFloat(int listID, int item, float val)
          Low level interface function used to set the itemth element in the list identified by listID to the float value val.
static boolean jFrilPutGoal(int listID)
           
static boolean jFrilPutInt(int listID, int item, int val)
          Low level interface function used to set the itemth element in the list identified by listID to the integer value val.
static boolean jFrilPutList(int listID, int item, int putListID)
          Low level interface function used to set the itemth element in the list identified by listID to the list identified by putListID.
static boolean jFrilPutListLen(int listID, int len)
          Low level interface function normally used to bind two variables.
static int jFrilResume(java.lang.String buffer)
          Calls Fril to continue execution of a goal which has suspended because it requires input.
static void jFrilSetOutWriter(java.io.Writer stdOut)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JFRILATOM

public static final int JFRILATOM
Value returned by jFrilGetItemType indicating the argument is a Fril constant

JFRILINT

public static final int JFRILINT
Value returned by jFrilGetItemType indicating that the argument is a Fril integer

JFRILFLOAT

public static final int JFRILFLOAT
Value returned by jFrilGetItemType indicating that the argument is a Fril float
See Also:
jFrilGetItemType

JFRILLIST

public static final int JFRILLIST
Value returned by jFrilGetItemType indicating that the argument is a Fril list

JFRILVBLE

public static final int JFRILVBLE
Value returned by jFrilGetItemType indicating that the argument is a Fril variable

JFRILFSET

public static final int JFRILFSET
Value returned by jFrilGetItemType indicating that the argument is a Fril fuzzy set

JFRILFSLIST

public static final int JFRILFSLIST
Constant used to reference the bound answer variable when calling jFrilGetItemType or jFrilGetXXX after jFrilFindSolution

JFRILFSITEM

public static final int JFRILFSITEM
Constant used to reference the bound answer variable when calling jFrilGetItemType or jFrilGetXXX after jFrilFindSolution

JFRILSUCCEEDED

public static final int JFRILSUCCEEDED
Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query succeeded

JFRILFAILED

public static final int JFRILFAILED
Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query failed

JFRILINTERRUPT

public static final int JFRILINTERRUPT
Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query was interrupted

JFRILTERMINATED

public static final int JFRILTERMINATED
Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query cannot be executed because Fril has terminated

JFRILREQUESTINPUT

public static final int JFRILREQUESTINPUT
Value returned by jFrilExecuteFril, jFrilExecuteGoal, jFrilFindSolution indicating that the query has requested input

resultFrilCall

public static boolean resultFrilCall
resultFrilCall is used internally for communication with the embedded Fril library code
Constructor Detail

JFril

public JFril()
Creates a JFril object. The output from any Fril queries will be discarded unless a Writer is specified using the function jFrilSetOutWriter()
Parameters:
NONE -  
Throws:
NONE -  

JFril

public JFril(java.io.Writer stdOut)
Creates a JFril object which directs all its output to the Writer stdOut.
Parameters:
stdOut - a Writer.
Throws:
NONE -  
See Also:
java.io#Writer()

JFril

public JFril(java.io.Writer stdOut,
             java.lang.String initialCommand)
Creates a JFril object which directs all its output to the Writer stdOut. As soon as the JFril object is created, it will execute the command specified in
Parameters:
stdOut - a Writer
String - initialCommand.
Throws:
NONE -  
See Also:
java.io#Writer()
Method Detail

jFrilExecuteFril

public static int jFrilExecuteFril(java.io.BufferedReader stdIn)
                            throws java.io.IOException
Calls Fril to execute the input supplied by the BufferedReader stdIn. If executing the goal causes Fril to read input, this is taken from the BufferedReader stdIn using its ReadLine() method.
Returns:
one of JFRILSUCCEEDED, JFRILFAILED, JFRILTERMINATED

jFrilExecuteFril

public static int jFrilExecuteFril(java.lang.String frilInput)
Calls Fril to execute the input supplied in the String frilInput. If executing the goal causes Fril to read input, this is taken from the String frilInput until all its characters have been read; the return value JFril.JFRILREQUESTINPUT indicates that further input is required.
Returns:
one of JFRILSUCCEEDED, JFRILFAILED, JFRILTERMINATED, JFRILREQUESTINPUT

jFrilFindSolution

public static int jFrilFindSolution(java.io.BufferedReader stdIn)
                             throws java.io.IOException
Calls Fril to execute the input supplied by the BufferedReader stdIn and finds a binding for a target variable or pattern. The query string given to Fril has a similar syntax to a Fril "wh" query, e.g. (X (bla X Y) (foo X)). The first term in this list is a Fril variable (or pattern), the remaining terms are Fril goals to be executed. The execution should provide a binding for the target variable or pattern. The return value indicates the binding, and an apporpriate low-level jFrilGet** function can be used to retrieve the instantiated value. If executing the goal causes Fril to read input, this is taken from the BufferedReader stdIn using its ReadLine() method.
Returns:
one of JFRILATOM, JFRILINT, JFRILFLOAT, JFRILLIST, JFRILVBLE, JFRILFSET, JFRILFAILED, JFRILTERMINATED, JFRILREQUESTINPUT

jFrilFindSolution

public static int jFrilFindSolution(java.lang.String frilInput)
Calls Fril to execute the input contained in the String frilInput and finds a binding for a target variable or pattern. The query string given to Fril has a similar syntax to a Fril "wh" query, e.g. (X (bla X Y) (foo X)). The first term in this list is a Fril variable (or pattern), the remaining terms are Fril goals to be executed. The execution should provide a binding for the target variable or pattern. The return value indicates the binding, and an apporpriate low-level jFrilGet** function can be used to retrieve the instantiated value. If executing the goal causes Fril to read input, this is taken from the BufferedReader stdIn using its ReadLine() method.
Returns:
one of JFRILATOM, JFRILINT, JFRILFLOAT, JFRILLIST, JFRILVBLE, JFRILFSET, JFRILFAILED, JFRILTERMINATED, JFRILREQUESTINPUT

jFrilExecuteGoal

public static int jFrilExecuteGoal(java.lang.String inbuf)
Calls Fril to execute a goal created using the low level interface functions and passed to Fril by putgoal. If executing the goal causes Fril to read input, this is taken from the String inbuf.
Parameters:
String - inbuf : used to pass input to any Fril built-in predicates that read from stdin.
Returns:
one of JFRILSUCCEEDED, JFRILFAILED, JFRILREQUESTINPUT, JFRILTERMINATED

jFrilInitialiseInterface

public static void jFrilInitialiseInterface()
jFrilInitialiseInterface initialises the low level Fril-java interface, by clearing structures created during previous transfer of information across the interface. This function should be called before a new goal is created. Any list identifiers created prior to a call to jFrilInitialiseInterface are invalid after the call.

jFrilResume

public static int jFrilResume(java.lang.String buffer)
Calls Fril to continue execution of a goal which has suspended because it requires input. This can happen during jFrilExecuteGoal, jFrilFindSolution or jFrilExecuteFril.
Parameters:
String - inbuf : used to pass input to any Fril built-in predicates that read from stdin.
Returns:
one of JFRILSUCCEEDED, JFRILFAILED, JFRILREQUESTINPUT, JFRILTERMINATED

jFrilGetArgs

public static java.lang.Integer jFrilGetArgs()
Low level interface function which returns an Integer identifying the Fril argument list. NB this identifier will normally be known as it will have been used to pass the goal to Fril using jFrilPutArgs
Returns:
an Integer whose value is the identifier for the list of arguments passed to Fril OR null in the case of an error.

jFrilGetInt

public static java.lang.Integer jFrilGetInt(int listID,
                                            int item)
Low level interface function used to extract an integer from a Fril list.
Returns:
an Integer whose value is the itemth element in the list identified by listID OR null in the case of an error.

jFrilGetAtom

public static java.lang.String jFrilGetAtom(int listID,
                                            int item)
Low level interface function used to extract a Fril constant (string) from a Fril list.
Returns:
a String whose value is the itemth element in the list identified by listID OR null in the case of an error.

jFrilGetFloat

public static java.lang.Float jFrilGetFloat(int listID,
                                            int item)
Low level interface function used to extract a Fril float from a Fril list.
Returns:
a Float whose value is the itemth element in the list identified by listID OR null in the case of an error.

jFrilGetList

public static java.lang.Integer jFrilGetList(int listID,
                                             int item)
Low level interface function used to extract an identifier for a Fril list contained within a Fril list.
Returns:
an Integer whose value is the identifier for the itemth element in the list identified by listID OR null in the case of an error.

jFrilGetListLen

public static java.lang.Integer jFrilGetListLen(int listID)
Low level interface function used to determine the length of the list referenced by the identifier listid. If successful, it returns an Integer whose value is set to the length of the list. If the list is unterminated, the value is minus the number of elements currently known to be in the list, e.g. if listid referenced the list (a b c|X), then the value would be set to -3. Note that in the case of an unterminated list, the length can change if additional elements are put into the list (see example below under putlistlen). If the identifier listid does not refer to a list, Fril will generate an error 604 and null is returned.
Returns:
an Integer whose value is the identifier for the itemth element in the list identified by listID OR null in the case of an error.

jFrilPutInt

public static boolean jFrilPutInt(int listID,
                                  int item,
                                  int val)
Low level interface function used to set the itemth element in the list identified by listID to the integer value val.
Returns:
true or false depending on whether it was possible to set the requested value.

jFrilPutFloat

public static boolean jFrilPutFloat(int listID,
                                    int item,
                                    float val)
Low level interface function used to set the itemth element in the list identified by listID to the float value val.
Returns:
true or false depending on whether it was possible to set the requested value.

jFrilPutAtom

public static boolean jFrilPutAtom(int listID,
                                   int item,
                                   java.lang.String val)
Low level interface function used to set the itemth element in the list identified by listID to the constant (String) value val.
Returns:
true or false depending on whether it was possible to set the requested value.

jFrilPutList

public static boolean jFrilPutList(int listID,
                                   int item,
                                   int putListID)
Low level interface function used to set the itemth element in the list identified by listID to the list identified by putListID.
Returns:
true or false depending on whether it was possible to set the requested value.

jFrilPutListLen

public static boolean jFrilPutListLen(int listID,
                                      int len)
Low level interface function normally used to bind two variables. set the itemth element in the list identified by listID to the list identified by putListID.
Returns:
true or false depending on whether it was possible to set the requested value.

jFrilPutArg

public static boolean jFrilPutArg(int listID1,
                                  int item1,
                                  int listID2,
                                  int item2)
Low level interface function normally used to bind two variables. jFrilPutArg unifies the item1th element in the list identified by listID1 with the item2th element in the list identified by listID2.
Returns:
true or false depending on whether it was possible to unify the specified terms.

jFrilPutGoal

public static boolean jFrilPutGoal(int listID)

jFrilGetItemType

public static java.lang.Integer jFrilGetItemType(int listID,
                                                 int item)

jFrilCreateList

public static java.lang.Integer jFrilCreateList(int len)

jFrilGetStatus

public static boolean jFrilGetStatus()

jFrilGetVersion

public static java.lang.String jFrilGetVersion()

jFrilSetOutWriter

public static void jFrilSetOutWriter(java.io.Writer stdOut)

jFrilDisplayOutput

public static void jFrilDisplayOutput(java.lang.String buf)
method used internally for communication with the embedded Fril library code