flora-commits Mailing List for Flora-2
Brought to you by:
kifer
You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(59) |
Jun
(43) |
Jul
(4) |
Aug
(4) |
Sep
(102) |
Oct
(20) |
Nov
(47) |
Dec
(32) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(24) |
Feb
(34) |
Mar
(72) |
Apr
(36) |
May
(10) |
Jun
(46) |
Jul
(36) |
Aug
(24) |
Sep
(37) |
Oct
(27) |
Nov
(43) |
Dec
(40) |
| 2004 |
Jan
(35) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(30) |
Aug
(83) |
Sep
(68) |
Oct
(38) |
Nov
(3) |
Dec
(7) |
| 2005 |
Jan
(9) |
Feb
(31) |
Mar
(46) |
Apr
(73) |
May
(21) |
Jun
(1) |
Jul
(32) |
Aug
(33) |
Sep
(3) |
Oct
(28) |
Nov
(4) |
Dec
(23) |
| 2006 |
Jan
(22) |
Feb
(2) |
Mar
(12) |
Apr
(23) |
May
(73) |
Jun
(14) |
Jul
|
Aug
(20) |
Sep
(14) |
Oct
(5) |
Nov
|
Dec
(14) |
| 2007 |
Jan
(54) |
Feb
(81) |
Mar
(286) |
Apr
(313) |
May
(154) |
Jun
(85) |
Jul
(8) |
Aug
(11) |
Sep
(12) |
Oct
(14) |
Nov
(6) |
Dec
(6) |
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(12) |
May
(4) |
Jun
|
Jul
(13) |
Aug
(22) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(46) |
Jun
(43) |
Jul
(46) |
Aug
(9) |
Sep
(13) |
Oct
(31) |
Nov
(42) |
Dec
(18) |
| 2014 |
Jan
(7) |
Feb
(7) |
Mar
(11) |
Apr
(13) |
May
(16) |
Jun
(6) |
Jul
(17) |
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
| 2015 |
Jan
|
Feb
(17) |
Mar
(4) |
Apr
(3) |
May
(2) |
Jun
(3) |
Jul
(2) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
|
2
|
|
3
|
4
|
5
|
6
|
7
|
8
|
9
(2) |
|
10
(6) |
11
|
12
(3) |
13
|
14
|
15
|
16
|
|
17
|
18
|
19
|
20
|
21
|
22
|
23
|
|
24
|
25
|
26
(1) |
27
(1) |
28
(1) |
29
|
30
|
|
From: Hui W. <hw...@us...> - 2006-09-28 22:09:13
|
Update of /cvsroot/flora/flora2/lib In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv10019/lib Modified Files: flrtypeconstraint.flr Log Message: Fix little typo in comments. Index: flrtypeconstraint.flr =================================================================== RCS file: /cvsroot/flora/flora2/lib/flrtypeconstraint.flr,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- flrtypeconstraint.flr 5 May 2006 19:52:13 -0000 1.2 +++ flrtypeconstraint.flr 28 Sep 2006 22:09:04 -0000 1.3 @@ -48,12 +48,12 @@ (?Count < ?Low ; ?Count @> ?High). /************************************************************************************************************************* -?Object[%CheckCardinality(?Method,-Low,-High,?MethodType)] -?Object[%CheckCardinality(?Module,?Method,-Low,-High,?MethodType)] +?Object[%CheckCardinality(?Method,-LowBound,-HighBound,?MethodType)] +?Object[%CheckCardinality(?Module,?Method,-LowBound,-HighBound,?MethodType)] ?LowBound and ?HighBound should be unbound variables in the input, they are used to signal which bound is violated. If the lower bound is violated, then ?LowBound will be bound to the (violated) lower bound, otherwise bound to 'not_violated' - If the higher bound is violated, then ?HighBound will be bound to the (violated) lower bound, otherwise bound to 'not_violated' + If the higher bound is violated, then ?HighBound will be bound to the (violated) higher bound, otherwise bound to 'not_violated' ***********************************************************************************************************************/ ?Object[%CheckCardinality(?Method,?LowBound,?HighBound,'=>')] :- |
|
From: Hui W. <hw...@us...> - 2006-09-27 23:14:05
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv13012 Modified Files: flrcompiler.P Log Message: Bug fix for write_code for URI prefix definition. Index: flrcompiler.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcompiler.P,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- flrcompiler.P 19 Jun 2006 21:38:20 -0000 1.91 +++ flrcompiler.P 27 Sep 2006 23:13:57 -0000 1.92 @@ -1584,7 +1584,12 @@ compile_direct(DirectTerm,Idx,CodeList,Status) :- is_flprefixdef(DirectTerm,PrefixName,PrefixBody), compile_pathexplist([PrefixName,PrefixBody],[NameCode,BodyCode1],_,_,S), - ( is_prstring(BodyCode1,String,_) -> atom_codes(BodyCode,String); BodyCode=BodyCode1), % the body of prefix definition is stored as atom + ( is_prstring(BodyCode1,String,Index) -> + atom_codes(Atom,String), + atomobj_struct(Atom,Index,BodyCode) + + ; BodyCode=BodyCode1 + ), % the body of prefix definition is stored as atom ( S==[] -> prefixdef_struct(NameCode,BodyCode,Direct), directive_struct(Direct,Code1), |
|
From: Michael K. <ki...@us...> - 2006-09-26 11:10:50
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20845 Modified Files: flrutils.P flrutils.H Log Message: added flora_read_then_parse/2/3 Index: flrutils.P =================================================================== RCS file: /cvsroot/flora/flora2/flrutils.P,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- flrutils.P 10 Sep 2006 18:52:18 -0000 1.75 +++ flrutils.P 26 Sep 2006 11:10:40 -0000 1.76 @@ -1960,7 +1960,9 @@ /************************************************************************* flora_read_parse_compile(+Option,-Tokens,-FlattenedRules,-OptionList,-Status) - Note: This procedure can be used to read both file and command line. + Read file or command line, then parse and compile. + + This procedure can be used to read both file and command line. For reading file, Option is FLORA_FILE. For reading command line, Option is FLORA_COMMANDLINE. @@ -2028,6 +2030,84 @@ /************************************************************************* + flora_read_then_parse(-InputTokens,-ParserTerm,-Status) + flora_read_then_parse(-ParserTerm,-Status) + + Read standard input (one line) then parse (don't compile) + This can be used to dump parsed FLORA-2 code to XML and other formats. + + For reading file, Option is FLORA_FILE. For reading command line, + Option is FLORA_COMMANDLINE. + + The parser output is ParserTerm. + InputTokens is the list of tokens after tokenization. + Provided because it is sometimes useful. + + flora_read_then_parse/2 is like flora_read_then_parse/3, + but discards InputTokens. + +*************************************************************************/ +flora_read_then_parse(ParserTerm,Status) :- + flora_read_then_parse(_InputTokens,ParserTerm,Status). +flora_read_then_parse(InputTokens,ParserTerm,Status) :- + flora_tokens(InputTokens,LexerStatus), + %% get InputTokens + flora_lexer_error(InputTokens,LexerStatus,LexErrNum), + ( LexErrNum > 0 -> + ErrNum=LexErrNum, + WarnNum=0 + + ; flora_blank_line(InputTokens) -> + ErrNum=0, + WarnNum=0 + ; + %% compose + flora_compose(InputTokens,ComposerTerm,ComposerStatus), + flora_composer_errorwarn(ComposerStatus,CompoErrNum,CompoWarnNum), + ( CompoErrNum > 0 -> + ErrNum=CompoErrNum, + WarnNum=CompoWarnNum + ; + flora_parse(ComposerTerm,ParserTerm,ParserStatus), + %% parse + flora_parser_error(ParserStatus,ParErrNum), + ( ParErrNum > 0 -> + ErrNum=ParErrNum, + WarnNum=CompoWarnNum + ; + ErrNum=0, + WarnNum=CompoWarnNum + ) + ) + ), + EWS=[error(ErrNum),warning(WarnNum)], + ( flora_end_of_input(LexerStatus) -> + Status=[FLORA_EOF|EWS] + ; + Status=[FLORA_NOT_EOF|EWS] + ). + + +/************************************************************************* + flora_read_then_parse_string(+String,-ParserTerm,-Status) + + Uses flora_read_then_parse/3 to read and parse from string. + This predicate is mostly for debugging. + +*************************************************************************/ +flora_read_then_parse_string(String,ParserTerm,Status) :- + seeing(OldStdin), + open(atom(String), read, IOport), + see(IOport), + !, + flora_read_then_parse(ParserTerm,Status), + seen, + see(OldStdin), + close(IOport). + + + +/************************************************************************* flora_construct_query_term(+InputTokens,-Tokens) Construct a query term from the shell command line input. Two extra Index: flrutils.H =================================================================== RCS file: /cvsroot/flora/flora2/flrutils.H,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- flrutils.H 10 Sep 2006 18:52:18 -0000 1.40 +++ flrutils.H 26 Sep 2006 11:10:40 -0000 1.41 @@ -261,6 +261,10 @@ flora_compile_add/2, flora_compile_add/1, + flora_read_then_parse/2, + flora_read_then_parse/3, + flora_read_then_parse_string/3, + flora_patch_full_filename/1, flora_coder_error/1. |
|
From: Michael K. <ki...@us...> - 2006-09-12 13:41:53
|
Update of /cvsroot/flora/flora2/docs In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv14957/docs Modified Files: flora-flrjava.tex Log Message: improved documentation for Java API Index: flora-flrjava.tex =================================================================== RCS file: /cvsroot/flora/flora2/docs/flora-flrjava.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- flora-flrjava.tex 2 Jun 2006 04:52:17 -0000 1.9 +++ flora-flrjava.tex 12 Sep 2006 13:41:34 -0000 1.10 @@ -1,16 +1,18 @@ - \chapter[JAVA Interface for \FLORA]{JAVA Interface for \FLORA\\by Aditi Pandit} + \chapter[JAVA Interface for \FLORA]{JAVA Interface for \FLORA\\by Aditi + Pandit and Michael Kifer} This chapter documents the API for accessing \FLORA from a Java program. - The API has two versions: a low-level API, which enables Java programs to - send arbitrary queries to \FLORA and get results, and a high-level API, - which is more limited, but is easier to use. The high-level API + The API has two versions: a \emph{low-level API}, + which enables Java programs to + send arbitrary queries to \FLORA and get results, and a \emph{high-level + API}, which is more limited, but is easier to use. The high-level API establishes a correspondence between Java classes and \FLORA classes, which enables manipulation of \FLORA classes by executing appropriate methods on the corresponding Java classes. Both interfaces rely on the - Java-XSB interface, called \emph{Interprolog,} provided by Declarativa.com. + Java-XSB interface, called \emph{Interprolog}, provided by Declarativa.com. \section{Description} @@ -18,18 +20,24 @@ The low-level API enables Java programs to send arbitrary queries to \FLORA and get results. -Interprolog calls are wrapped in the {\tt -net.sourceforge.flora.javaAPI.src.FloraSession} class and made -available to the caller of the interface. The following methods are -available in that class: +In order to be able to access \FLORA, the Java program must first establish +a session for a running instance of \FLORA. Multiple sessions can be active +at the same time. The knowledge bases in the different running instances +are completely independent. Sessions are instances of +the {\tt +net.sourceforge.flora.javaAPI.src.FloraSession}. This class provides methods +for opening/closing sessions and loading \FLORA knowledge bases +(which are also used in the high-level +interface). In addition, a session provides +methods for executing arbitrary \FLORA queries. The following is the complete +list of the methods that are available in that class. \begin{itemize} \item \begin{verbatim} public FloraSession() \end{verbatim} - This method initializes the connection between Java and \FLORA by -initializing the Interprolog Library. The initialization parameters -needed are: + This method creates a connection to an instance of \FLORA. +The initialization parameters needed are: {\tt JAVA\_BIN}. This variable points to the directory containing the javac and java executable programs. This variable is specified in @@ -39,28 +47,23 @@ {\tt XSB\_ROOT\_DIRECTORY}. This variable points to the directory containing the XSB executable. This variable is specified in the {\tt flora\_settings.bat} and {\tt flora\_settings.sh} files in the {\tt java} -directory. Both of these files are generated automatically by the {\tt - makeflora} script and are of no concern for the user under normal -circumstances. - -{\tt FLORA\_DIRECTORY}. This variable points to the directory containing -the \FLORA installation. This variable is specified in the {\tt +directory. {\tt FLORA\_DIRECTORY}. This variable points to the directory +containing the \FLORA installation. This variable is specified in the {\tt flora\_settings.bat} and {\tt flora\_settings.sh} files in the {\tt java} directory. Both of these files are generated automatically by the {\tt - makeflora} script and are of no concern for the user under normal + makeflora} script and should be of no concern to the user under normal circumstances. \item {\tt close()} \\ - This method is called to terminate a \FLORA session. Note that this does - not terminate the Java program that initiated the session. - - Also note that in order to exit the Java program that talks to \FLORA - through Interprolog, one needs to execute + This method must be called to terminate a \FLORA session. Note that this does + not terminate the Java program that initiated the session: + to exit the Java program that talks to \FLORA, one needs to execute + the statement %% \begin{verbatim} System.exit(); \end{verbatim} %% - Just returning from the {\tt main} method is not enough. + Note that just returning from the {\tt main} method is not enough. \item \begin{verbatim} @@ -68,10 +71,10 @@ \end{verbatim} This method executes the \FLORA command given by the parameter {\tt command}. This method is used to execute \FLORA queries that -do not require variable bindings to be returned back to Java or have +do not require variable bindings to be returned back to Java or queries that +have only a single variable to be returned. Each binding is represented as an instance of {\tt net.sourceforge.flora.javaAPI.src.FloraObject}. - The examples below illustrate how to process the results returned by this method. @@ -85,15 +88,16 @@ added to the vector using the method {\tt add} before calling {\tt ExecuteQuery}. For instance, {\tt vars.add("?X")}. - This method {\tt ExecuteQuery} returns an iterator over all bindings for - this query returned by \FLORA. Each binding is represented by a HashMap + This version of {\tt ExecuteQuery} returns an iterator over all bindings + returned by the \FLORA query. Each binding is represented by a {\tt + HashMap} object which can be used to obtain the value of each variable in the query (using the {\tt get()} method). The value of each variable returned is an instance of {\tt net.sourceforge.flora.javaAPI.src.FloraObject}. -See the examples below for the illustration of how to handle the results -returned by this method. + See the examples below for how to handle the results + returned by this method. \item \begin{verbatim} @@ -153,19 +157,21 @@ import net.sourceforge.flora.javaAPI.src.*; import java.util.*; -/* Sample java file */ public class flogicbasicsExample { public static void main(String[] args) { + // create a new session for a running instance of FLORA-2 FloraSession session = new FloraSession(); System.out.println("FLORA-2 session started"); + // Assume that Java was called with -DFLORA_FILE=the-file-name String fileName = System.getProperty("FLORA_FILE"); if(fileName == null || fileName.trim().length() == 0) { System.out.println("Invalid path to example file!"); System.exit(0); } + // load the FLORA-2 program into module basic_mod session.loadFile(fileName,"basic_mod"); /* Running queries from flogic_basics.flr */ @@ -180,23 +186,6 @@ FloraObject personObj = (FloraObject)personObjs.next(); System.out.println("Person name:"+personObj); - person currPerson =new person(personObj,"basic_mod"); - Iterator kidsItr = currPerson.getVDN_kids(); - - while(kidsItr.hasNext()) { - Object kidObj = kidsItr.next(); - System.out.println("Person Name: " + personObj + " has kid: " + kidObj); - - person kidPerson = null; - kidPerson = new person(kidObj,"basic_mod"); - - Iterator hobbiesItr = kidPerson.getVDN_hobbies(); - while(hobbiesItr.hasNext()) { - Object hobbyObj = hobbiesItr.next(); - System.out.println("Kid:"+kidObj + " has hobby: " + hobbyObj); - } - } - } command = "person[instances -> ?X]@basic_mod."; System.out.println("Query:"+command); @@ -208,31 +197,34 @@ System.out.println("Person Id: "+personObj); } - /* Example of query with two variables */ + /* Example of ExecuteQuery with two arguments */ Vector vars = new Vector(); vars.add("?X"); vars.add("?Y"); - Iterator allmatches = session.ExecuteQuery("?X[believes_in -> ?Y]@basic_mod.",vars); + Iterator allmatches = + session.ExecuteQuery("?X[believes_in -> ?Y]@basic_mod.",vars); System.out.println("Query:?X[believes_in -> ?Y]@basic_mod."); - while(allmatches.hasNext()) { HashMap firstmatch = (HashMap)allmatches.next(); Object Xobj = firstmatch.get("?X"); Object Yobj = firstmatch.get("?Y"); - System.out.println(Xobj+" believes in: "+Yobj); + System.out.println(Xobj+" believes in: "+?Yobj); } + // quit the system session.close(); System.exit(0); } } \end{verbatim} -\subsection{The High-level interface} -The high-level API establishes a correspondence between Java classes -and \FLORA classes, which enables manipulation of \FLORA classes by -executing appropriate methods on the corresponding Java classes. -Using the high-level API involves a number of stages, as described below. +\subsection{The High-Level Interface} + +The high-level API operates by creating proxy Java classes for +\FLORA classes selected by the user. +This enables the Java program to operate on \FLORA classes by +executing appropriate methods on the corresponding proxy Java classes. +The use of the high-level API involves a number of stages, as described below. \paragraph{Stage 1: Writing a \FLORA file.} We assume the same {\tt flogic\_basics.flr} file as in the previous @@ -240,58 +232,62 @@ \paragraph{Stage 2: Generating Java classes that serve as proxies for \FLORA classes.} The \FLORA side of the Java-to-\FLORA high level API provides a predicate -to generate Java proxy classes for each \fl class of interest. Each proxy -class gets methods to manipulate the declared attributes and methods of the -corresponding \fl class. If an \fl class has a declared value-returning -attribute {\tt foobar} then the proxy class will have the following -methods. Each method name has the form \emph{action}$S_1S_2S_3$\_{\tt - foobar}, where \emph{action} is either {\tt get}, {\tt set}, or {\tt - delete}. The specifier $S_1$ indicates the type of the method --- {\tt V} -for value-returning, {\tt B} for Boolean, and {\tt P} for procedural. The -specifier $S_2$ tells whether the operation applies to the signature if the -method ({\tt S}), e.g., {\tt person[foobar=>string]}, or to the actual data -({\tt D}), for example, {\tt john[foobar->3]}. Finally, the specifier -$S_3$ tells if the operation applies to the inheritable variant of the -method or its non-inheritable variant. +to generate Java proxy classes for each \fl class which have a signature +declaration in the \FLORA knowledge base. A proxy class gets defined so +that it would have methods to manipulate the attributes and methods of the +corresponding \fl class for which signature declarations are available. If +an \fl class has a declared value-returning attribute {\tt foobar} then the +proxy class will have the following methods. Each method name has the form +\emph{action}$S_1S_2S_3$\_{\tt foobar}, where \emph{action} is either {\tt + get}, {\tt set}, or {\tt delete}. The specifier $S_1$ indicates the type +of the method --- {\tt V} for value-returning, {\tt B} for Boolean, and +{\tt P} for procedural. The specifier $S_2$ tells whether the operation +applies to the signature of the method ({\tt S}), e.g., {\tt + person[foobar=>string]}, or to the actual data ({\tt D}), for example, +{\tt john[foobar->3]}. Finally, the specifier $S_3$ tells if the operation +applies to the inheritable variant of the method ({\tt I}) +or its non-inheritable variant ({\tt N}). %% \begin{enumerate} \item {\tt public Iterator getVDI\_foobar()}\\ - {\tt public Iterator getVDN\_foobar()} + {\tt public Iterator getVDN\_foobar()} \\ {\tt public Iterator getVSI\_foobar()}\\ - {\tt public Iterator getVSN\_foobar()} + {\tt public Iterator getVSN\_foobar()} \\ - Queries the knowledge base and gets all answers for the attribute {\tt - foobar}. Returns an iterator through which these answers can be - obtained. Each object returned by the iterator in of type {\tt FloraObject}. - The {\tt getVDN} form queries non-inheritable data methods and {\tt getVDI} - the inheritable ones. The {\tt getVSI} and {\tt getVSN} query - the signatures of those methods. + The above methods query the knowledge base and get all answers for the + attribute {\tt foobar}. They return iterators through which these answers + can be processed one-by-one. Each object returned by the iterator is of + type {\tt FloraObject}. The {\tt getVDN} form queries non-inheritable + data methods and {\tt getVDI} the inheritable ones. The {\tt getVSI} and + {\tt getVSN} forms query the signatures of the attribute {\tt foobar}. \item {\tt public boolean setVDI\_foobar(Vector value)}\\ {\tt public boolean setVDN\_foobar(Vector value)} \\ {\tt public boolean setVSI\_foobar(Vector value)}\\ {\tt public boolean setVSN\_foobar(Vector value)} \\ - Adds values to the set of values for the attribute {\tt foobar}. The - values must be placed in the vector parameter of the method. - Again, {\tt setVDN} sets data for non-inheritable methods and {\tt setVDI} - inheritable and {\tt setVSI}, {\tt setVSN} sets signatures. + These methods + add values to the set of values returned by the attribute {\tt foobar}. The + values must be placed in the vector parameter passed these methods. + Again, {\tt setVDN} adds data for non-inheritable methods and {\tt setVDI} + is used for inheritable methods. + {\tt setVSI} and {\tt setVSN} add types to signatures. \item {\tt public boolean setVDI\_foobar(Object value)}\\ {\tt public boolean setVDN\_foobar(Object value)} \\ {\tt public boolean setVSI\_foobar(Object value)}\\ {\tt public boolean setVSN\_foobar(Object value)}\\ - This method provides a simplified interface when only one value needs to - be added. It works like the above, except that only one given value is - added. + These methods provide a simplified interface when only one value needs to + be added. It works like the earlier set\_* methods, except that only one + value given as an argument is added. \item {\tt public boolean deleteVDI\_foobar(Vector value)}\\ {\tt public boolean deleteVDN\_foobar(Vector value)} \\ {\tt public boolean deleteVSI\_foobar(Vector value)}\\ {\tt public boolean deleteVSN\_foobar(Vector value)} \\ - Delete a set of values of the attribute {\tt foobar} as + Delete a set of values of the attribute {\tt foobar}. The set is specified in the vector argument. \item {\tt public boolean deleteVDI\_foobar(Object value)}\\ {\tt public boolean deleteVDN\_foobar(Object value)} @@ -299,20 +295,20 @@ {\tt public boolean deleteVSI\_foobar(Object value)}\\ {\tt public boolean deleteVSN\_foobar(Object value)} \\ - Like the above, but provides a simplified interface for the case when - only one value needs to be deleted. + A simplified interface for the case when only one value needs to be deleted. \item {\tt public boolean deleteVDI\_foobar()}\\ {\tt public boolean deleteVDN\_foobar()} \\ {\tt public boolean deleteVSI\_foobar()}\\ {\tt public boolean deleteVSN\_foobar()} \\ - Delete all values of the attribute {\tt foobar}. + Delete all values for the attribute {\tt foobar}. \end{enumerate} %% For \fl methods with arguments, the high-level API provides Java methods as -above, but they take more arguments to accommodate parameters. Let us -assume that the \fl method is called {\tt foobar2} and takes parameters +above, but they take more arguments to accommodate the parameters that \fl +methods take. Let us +assume that the \fl method is called {\tt foobar2} and it takes parameters {\tt arg1} and {\tt arg2}. As before the {\tt getVDI\_*}, {\tt setVDI\_*}, etc., forms of the Java methods are for dealing with inheritable \FLORA methods and the {\tt getVDN\_*}, {\tt setVDN\_*}, @@ -327,7 +323,7 @@ \item {\tt public boolean setVDI\_foobar2(Object arg1, Object arg2, Vector value)}\\ {\tt public boolean setVDN\_foobar2(Object arg1, Object arg2, Vector value)} \\ - Add a set of methods specified in {\tt value} for the method + Add a set of methods specified in the parameter {\tt value} for the method invocation {\tt foobar2(arg1,arg2)}. \item {\tt public boolean setVDI\_foobar2(Object arg1, Object arg2, Object value)}\\ {\tt public boolean setVDN\_foobar2(Object arg1, Object arg2, Object value)} @@ -349,11 +345,11 @@ \end{enumerate} %% For Boolean and procedural methods, the generated methods are similar -except that there is only one set and delete method. In addition, Boolean -inheritable methods use the {\tt getBDI\_*}, {\tt setBDI\_*}, etc., form, -while non-inheritable methods use the {\tt getBDN\_*}, etc., form. -Procedural methods use the {\tt getPDI\_*}, {\tt getPDN\_*}, etc., forms. -For instance, +except that there is only one version for the set and delete methods. In +addition, Boolean inheritable methods use the {\tt getBDI\_*}, {\tt + setBDI\_*}, etc., form, while non-inheritable methods use the {\tt + getBDN\_*}, etc., form. Procedural methods use the {\tt getPDI\_*}, {\tt + getPDN\_*}, etc., forms. For instance, %% \begin{enumerate} \item {\tt public boolean getBDI\_foobar3()} \\ @@ -370,21 +366,36 @@ {\tt public boolean deletePDN\_foobar3()} \end{enumerate} %% + +In addition, the methods to query the ISA hierarchy are available: +%% +\begin{itemize} +\item {\tt public Iterator getDirectInstances()} +\item {\tt public Iterator getInstances()} +\item {\tt public Iterator getDirectSubClasses()} +\item {\tt public Iterator getSubClasses()} +\item {\tt public Iterator getSuperClasses()} +\item {\tt public Iterator getDirectSuperClasses()} +\end{itemize} +%% +These methods apply to the java proxy object that corresponds to the \fl +class person. + All these methods are generated automatically by executing the following -\FLORA-2 query, where all arguments must be bound: +\FLORA query, where all arguments must be bound: %% \begin{verbatim} - // Arguments: %write(?Class,?Module,?ProxyFileName). + // %write(?Class,?Module,?ProxyClassFileName). ?- %write(foo,example,'myproject/foo.java'). \end{verbatim} %% -The class argument specifies the class for which to generate the methods, -the file name tells where the to put the Java file for the proxy object, -and the model argument tells which model to load this program to. The +The first argument specifies the class for which to generate the methods, +the file name tells where to put the Java file for the proxy object, +and the model argument tells which \FLORA model to load this program to. The result of this execution will be the file {\tt foo.java} which should be -included with your java program (the one that is going to interface with -\FLORA-2). (Note that because of Java conventions, the file name must have -the same name as the class name.) +included with your java program (the program that is going to interface with +\FLORA). Note that because of Java conventions, the file name must have +the same name as the class name. It is important to remember, however, that proxy methods will be generated only for those \fl methods that have been declared using signatures. @@ -405,18 +416,30 @@ The {\tt \%write} method will create the file {\tt person.java} shown -below. As explained earlier, -the methods defined in {\tt person.java} are the class constructor -for {\tt person} -plus the ``get'', ``set'' and ``delete'' methods for each method and -attribute declared in the \FLORA class {\tt person}. -The parameters for -the ``get'', ``set'' and ``delete'' Java methods are the same as for the -corresponding \FLORA method. The constructor for class {\tt person} takes -an object of class {\tt net.sourceforge.flora.javaAPI.src.FloraObject} as a -parameter. This object is responsible for translating the invocations of -the ``get'', ``set,'' and ``delete'' methods to the appropriate queries to -be sent through the low-level Java interface. +below. The methods defined in {\tt person.java} are the class constructors +for {\tt person}, the methods to query the ISA hierarchy, and the ``get'', +``set'' and ``delete'' methods for each method and attribute declared in +the \FLORA class {\tt person}. The parameters for the ``get'', ``set'' and +``delete'' Java methods are the same as for the corresponding \FLORA +methods. The first constructor for class {\tt person} takes a low-level +object of class {\tt net.sourceforge.flora.javaAPI.src.FloraObject} as a +parameter. The second parameter is the \FLORA module for which the proxy +object is to be created. +The second {\tt person}-constructor takes \fl object Id instead of a +low-level {\tt FloraObject}. It also takes the module name, as before, but, +in addition, it takes a session for a running \FLORA instance. +The session parameter was not needed for the first {\tt person}-constructor +because {\tt FloraObject} is already attached to a concrete session. + +It can be seen from the form of the proxy object constructors that +proxy objects are attached to specific \FLORA modules, which may seem to +go against the general philosophy that \fl objects do not belong to any +module --- only their methods do. On closer examination, however, attaching +high-level proxy Java objects to modules makes perfect sense. Indeed, a +proxy object encapsulates operations for manipulating \fl attributes +and methods, which belong to concrete \FLORA modules, so the proxy object +needs to know which module it operates upon. + \underline{{\bf person.java file}} @@ -428,7 +451,19 @@ public FloraObject sourceFloraObject; - public person(FloraObject sourceFloraObject,String moduleName) { ... } + // proxy objects' constructors + public person(FloraObject sourceFloraObject, String moduleName) { ... } + public person(String floraOID,String moduleName, FloraSession session) { ... } + + // ISA hierarchy queries + public Iterator getDirectInstances() { ... } + public Iterator getInstances() { ... } + public Iterator getDirectSubClasses() { ... } + public Iterator getSubClasses() { ... } + public Iterator getDirectSuperClasses() { ... } + public Iterator getSuperClasses() { ... } + + // Java methods for manipulating FLORA-2 methods public boolean setVDI_age(Object value) { ... } public boolean setVDN_age(Object value) { ... } public Iterator getVDI_age(){ ... } @@ -484,7 +519,7 @@ \paragraph{Stage 3: Writing Java application programs.} The following program ({\tt flogicbasicsExample.java}) shows several -queries that combine the low-level and the high-level interface. The +queries that use the high-level interface. The class {\tt person.java} is generated at the previous stage. The methods of the high-level interface operate on Java objects that are proxies for \FLORA objects. These Java objects are members of the class @@ -493,7 +528,8 @@ retrieve the appropriate proxy objects on which to operate. This is done by sending an appropriate query through the method {\tt ExecuteQuery}---the same method that was used in the low-level interface. -The following example illustrates the process. +Alternatively, {\tt person}-objects could be constructed using the +3-argument proxy constructor, which takes \fl oids. \begin{quote} @@ -512,7 +548,7 @@ /* Loading the flora file */ session.loadFile(fileName,"basic_mod"); - /* Querying the class person */ + // Retrieving instances of the class person through low-level API String command = "?X:person@basic_mod."; System.out.println("Query:"+command); Iterator personObjs = session.ExecuteQuery(command); @@ -521,8 +557,7 @@ person currPerson = null; while (personObjs.hasNext()) { FloraObject personObj = personObjs.next(); - System.out.println("Person name:"+personObj); - /* Elevate personObj to the higher-level person-object */ + // Elevate personObj to the higher-level person-object currPerson =new person(personObj,"basic_mod"); /* Set that person's age to 50 */ @@ -546,6 +581,23 @@ } } } + + FloraObject age; + // create a person-object directly by supplying its F-logic OID + // father(mary) + currPerson = new person("father(mary)", "example", session); + Iterator maryfatherItr = currPerson.getVDN_age(); + age = (FloraObject)maryfatherItr.next(); + System.out.println("Mary's father is " + age + " years old"); + + // create a proxy object for the F-logic class person itself + person personClass = new person("person", "example", session); + // query its instances through the high-level interface + instanceIter = personClass.getInstances(); + System.out.println("Person instances using high-level API:"); + while (instanceIter.hasNext()) + System.out.println(" " + (FloraObject)instanceIter.next()); + session.close(); System.exit(); } @@ -555,12 +607,12 @@ \paragraph{Stage 4: Running the Java application program.} To run Java programs that interface with \FLORA, one must follow the -following rules. +following guidelines. \begin{itemize} \item Place the files {\tt flogicsbasicsExample.java} (the program you have written) and {\tt person.java} (the automatically generated file) -in a directory and compile them using the {\tt javac} command. Add +in the same directory and compile them using the {\tt javac} command. Add the directories containing the API code (i.e., the correct path name of the directory {\tt .../flora2/java/API}) and the {\tt interprolog.jar} file to the Java classpath. @@ -590,12 +642,12 @@ {\tt ENGINE}: This variable should be set to {\tt Native} or {\tt Subprocess}. The variable indicates whether InterProlog -should use the Java Native Interface or sockets to communicate with \FLORA. +should use the Java Native Interface (JNI) or sockets to communicate with \FLORA. {\tt CLASSPATH}: This variable should point to the directory containing the API code (i.e., the correct path name of the -directory {\tt .../flora2/java/API}) and {\tt interprolog.jar} -for the respective classes. +directory {\tt .../flora2/java/API}) and the file {\tt interprolog.jar} +(see below). \end{itemize} @@ -612,7 +664,7 @@ XSB needs to be configured in a special way in order to interoperate with InterProlog. To build XSB with InterProlog support, run the following commands in the {\tt build} -directory of XSB. +subdirectory of XSB. The {\tt configure} script needs to be run only on Linux and other Unix-based systems. %% @@ -650,7 +702,7 @@ makexsb_wind \end{verbatim} %% - Note: this requires that {\tt nmake} and the C++ compiler are available on + Note: this assumes that {\tt nmake} and the C++ compiler are available on your system. See the \FLORA manual, Section 1, for the instructions on obtaining these programs. \item Rebuild \FLORA with the new XSB binary obtained in the @@ -658,55 +710,33 @@ \item Get InterProlog from {\tt http://www.declarativa.com/interprolog/} and put it in the {\tt java} folder of the \FLORA distribution. (Do this only if you need a newer version of InterProlog. \FLORA -distribution already includes a version of {\tt interprolog.jar}). -\item The {\tt API} directory consists of the system code for the interface - in the {\tt net} folder and some sample applications in the - {\tt examples} folder. -\item To build the code for the interface, use the {\tt build.bat} or - {\tt build.sh} scripts in the API folder (depending on whether you are +distribution already includes a version of {\tt interprolog.jar} in the +{\tt java} subdirectory). +\item The {\tt java/API/net} subdirectory in the \FLORA distribution + consists of the system code for the interface. + Sample applications are found in the {\tt java/API/examples} folder. +\item To build the code for the interface, use the scripts {\tt build.bat} or + {\tt build.sh} in the {\tt java/API} folder (depending on whether you are using Windows or Unix). \item To build the the examples, use the scripts - {\tt buildExample.bat} or {\tt buildExample.sh} in the {\tt examples} + {\tt buildExample.bat} or {\tt buildExample.sh} in the {\tt java/API/examples} folder. For instance, to build the {\tt flogicbasicsExample} example, use the commands \begin{verbatim} cd examples buildExample.sh flogicbasicsExample -buildExample.bat flogicbasicsExample +(or buildExample.bat flogicbasicsExample, for Windows) \end{verbatim} \item To run the demos, use the scripts -{\tt runExample.bat} and {\tt runExample.sh} in the {\tt example} +{\tt runExample.bat} and {\tt runExample.sh} in the {\tt java/API/examples} folder. For instance, to run the {\tt flogicbasicsExample}, use the commands \begin{verbatim} runExample.sh flogicbasicsExample -runExample.bat flogicbasicsExample +(or runExample.bat flogicbasicsExample , for Windows) \end{verbatim} \end{itemize} -\section{Summary of the \FLORA Predicates and JAVA Library Calls} - -F-logic predicate in package {\tt javaAPI}: -\begin{itemize} - \item {\bf \%write(?Class,?Module,?ProxyFile)} \\ - Creates Java proxy classes for \FLORA classes. -\end{itemize} - -The methods of {\tt net.sourceforge.flora.javaAPI.src.FloraSession} in the -low-level API: -\begin{itemize} - \item {\tt FloraSession()} \\ - Constructor for a Session object to the \FLORA - system. - \item {\tt Iterator ExecuteQuery(String command)} \\ - Executes \FLORA commands that do not bind variables. - \item {\tt Iterator ExecuteQuery(String query,Vector vars)}\\ - Executes \FLORA queries that bind variables. - \item {\tt void loadFile(String fileName,String moduleName)}\\ - Loads a \FLORA file into a particular module. -\end{itemize} - - %%% Local Variables: %%% mode: latex |
|
From: Michael K. <ki...@us...> - 2006-09-12 13:41:24
|
Update of /cvsroot/flora/flora2/java/API/examples/flogicbasicsExample In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv14870/java/API/examples/flogicbasicsExample Modified Files: flogicbasicsExample.java Log Message: reorganized examples Index: flogicbasicsExample.java =================================================================== RCS file: /cvsroot/flora/flora2/java/API/examples/flogicbasicsExample/flogicbasicsExample.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- flogicbasicsExample.java 10 Sep 2006 18:53:46 -0000 1.5 +++ flogicbasicsExample.java 12 Sep 2006 13:41:08 -0000 1.6 @@ -1,6 +1,6 @@ /* File: flogicbasicsExample.java ** -** Author(s): Aditi Pandit +** Author(s): Aditi Pandit, Michael Kifer ** ** Contact: flo...@li... ** @@ -25,10 +25,14 @@ ** */ +/*********************************************************************** + This file contains examples of the uses of low-level API followed + by the examples of the uses of high-level API. +***********************************************************************/ + import net.sourceforge.flora.javaAPI.src.*; import java.util.*; -/* Sample java file */ public class flogicbasicsExample{ public static void main(String[] args) { @@ -43,52 +47,13 @@ } session.loadFile(fileName,"example"); - /* Running queries from flogic_basics */ + /* Examples of uses of the low-level Java-FLORA-2 API */ - /* Query for persons */ + // Querying persons String command = "?X:person@example."; System.out.println("Query:"+command); Iterator personObjs = session.ExecuteQuery(command); - /* Printing out the person names and information about their kids */ - person currPerson = null; - while (personObjs.hasNext()) { - FloraObject personObj = (FloraObject)(personObjs.next()); - System.out.println("Person name:"+personObj); - - currPerson =new person(personObj,"example"); - Iterator kidsItr = currPerson.getVDN_kids(); - - while(kidsItr.hasNext()) { - FloraObject kidObj = (FloraObject)(kidsItr.next()); - System.out.println("Person Name: " + personObj - + " has kid: " + kidObj); - - person kidPerson = null; - kidPerson = new person(kidObj,"example"); - - Iterator hobbiesItr = kidPerson.getVDN_hobbies(); - - while(hobbiesItr.hasNext()) { - FloraObject hobbyObj = null; - hobbyObj = (FloraObject)(hobbiesItr.next()); - System.out.println("Kid:"+kidObj - + " has hobby: " + hobbyObj); - } - } - } - - FloraObject age; - currPerson = new person("father(mary)", "example", session); - Iterator maryfatherItr = currPerson.getVDN_age(); - age = (FloraObject)maryfatherItr.next(); - System.out.println("Mary's father is " + age + " years old"); - - currPerson = new person("mary", "example", session); - Iterator maryItr = currPerson.getVDN_age(); - age = (FloraObject)maryItr.next(); - System.out.println("Mary is " + age + " years old"); - command = "person[instances -> ?X]@example."; System.out.println("Query:"+command); personObjs = session.ExecuteQuery(command); @@ -122,18 +87,12 @@ System.out.println(((FloraMethod)methIter.next()).methodDetails()); } + // instances of the person class Iterator instanceIter = personObj.getInstances("example"); System.out.println("Person instances:"); while (instanceIter.hasNext()) System.out.println(" " + (FloraObject)instanceIter.next()); - // same as above, but using high-level interface - person personClass = new person("person", "example", session); - instanceIter = personClass.getInstances(); - System.out.println("Person instances using high-level API:"); - while (instanceIter.hasNext()) - System.out.println(" " + (FloraObject)instanceIter.next()); - instanceIter = personObj.getDirectInstances("example"); System.out.println("Person direct instances:"); @@ -160,7 +119,68 @@ while (supIter.hasNext()) System.out.println(" " + (FloraObject)supIter.next()); + /***************************************************************** + ******** Examples of uses of the high-level Java-FLORA-2 API + *****************************************************************/ + + /* Printing out people's names and information about their kids + using the high-level API. Note that the high-level person-object + is obtained here out of the low-level FloraObject personObj + */ + person currPerson = null; + while (personObjs.hasNext()) { + personObj = (FloraObject)(personObjs.next()); + System.out.println("Person name:"+personObj); + + currPerson =new person(personObj,"example"); + Iterator kidsItr = currPerson.getVDN_kids(); + + while(kidsItr.hasNext()) { + FloraObject kidObj = (FloraObject)(kidsItr.next()); + System.out.println("Person Name: " + personObj + + " has kid: " + kidObj); + + person kidPerson = null; + kidPerson = new person(kidObj,"example"); + + Iterator hobbiesItr = kidPerson.getVDN_hobbies(); + + while(hobbiesItr.hasNext()) { + FloraObject hobbyObj = null; + hobbyObj = (FloraObject)(hobbiesItr.next()); + System.out.println("Kid:"+kidObj + + " has hobby: " + hobbyObj); + } + } + } + + + FloraObject age; + currPerson = new person("father(mary)", "example", session); + Iterator maryfatherItr = currPerson.getVDN_age(); + age = (FloraObject)maryfatherItr.next(); + System.out.println("Mary's father is " + age + " years old"); + + currPerson = new person("mary", "example", session); + Iterator maryItr = currPerson.getVDN_age(); + age = (FloraObject)maryItr.next(); + System.out.println("Mary is " + age + " years old"); + + // person instances using high-level interface + person personClass = new person("person", "example", session); + instanceIter = personClass.getInstances(); + System.out.println("Person instances using high-level API:"); + while (instanceIter.hasNext()) + System.out.println(" " + (FloraObject)instanceIter.next()); + + Iterator subclassIter = personClass.getSubClasses(); + System.out.println("Person subclasses using high-level API:"); + while (subclassIter.hasNext()) + System.out.println(" " + (FloraObject)subclassIter.next()); + + + // Close session and good bye session.close(); System.exit(0); } |
|
From: Michael K. <ki...@us...> - 2006-09-12 13:41:19
|
Update of /cvsroot/flora/flora2/java/API/examples/fooExample In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv14870/java/API/examples/fooExample Modified Files: fooExample.java Log Message: reorganized examples Index: fooExample.java =================================================================== RCS file: /cvsroot/flora/flora2/java/API/examples/fooExample/fooExample.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- fooExample.java 2 Jun 2006 04:52:16 -0000 1.4 +++ fooExample.java 12 Sep 2006 13:41:08 -0000 1.5 @@ -25,10 +25,14 @@ ** */ +/*********************************************************************** + Examples of the low-level API followed by examples of the uses of + the high-level API. +***********************************************************************/ + import net.sourceforge.flora.javaAPI.src.*; import java.util.*; -/* Sample java file */ public class fooExample{ public static void main(String[] args) { @@ -43,9 +47,14 @@ } session.loadFile(fileName,"example"); + /*********************************************************** + Low-level API examples + ***********************************************************/ + String command = "?Y : foo @ example."; Iterator fooObjs = session.ExecuteQuery(command); + System.out.println("Query: ?Y : foo @ example."); FloraObject johnSuper = null; while (fooObjs.hasNext()) { johnSuper = (FloraObject)fooObjs.next(); @@ -55,8 +64,27 @@ System.out.println("FOO obj Id: wrong answer!"); } + + Vector vars = new Vector(); + vars.add("?X"); + vars.add("?Y"); + + // Use of ExecuteQuery/2 + Iterator allmatches = session.ExecuteQuery("?X : ?Y @ example.",vars); + HashMap firstmatch; + System.out.println("Query: ?X : ?Y @ example."); + while (allmatches.hasNext()) { + firstmatch = (HashMap)allmatches.next(); + Object Xobj = firstmatch.get("?X"); + Object Yobj = firstmatch.get("?Y"); + System.out.println(" " + Xobj + " : " + Yobj); + } + + /******************************************************************* + Examples of the high-level API + *******************************************************************/ - foo objJohn = new foo(johnSuper,"example"); + foo objJohn = new foo("john","example",session); boolean check = objJohn.getBDN_boolean(); if (check) System.out.println("boolean is true"); @@ -88,7 +116,7 @@ System.out.println("Set John's age"); Iterator ageValues = objJohn.getVDN_age("2004"); while (ageValues.hasNext()) { - System.out.println("John's age:"+ageValues.next()); + System.out.println("John's age: "+ageValues.next()); } Vector ancestors = new Vector(); @@ -96,27 +124,14 @@ ancestors.add("sally"); objJohn.setVDN_ancestors(ancestors); - System.out.println("John obj:"+objJohn); - - - /* To show the use of ExecuteQuery/2 */ - objJohn.setVDN_ancestors(ancestors); - System.out.println("John obj:"+objJohn); - - Vector vars = new Vector(); - vars.add("?X"); - vars.add("?Y"); - - Iterator allmatches = session.ExecuteQuery("?X : ?Y @ example.",vars); - HashMap firstmatch; - System.out.println("Query: ?X : ?Y @ example."); - while (allmatches.hasNext()) { - firstmatch = (HashMap)allmatches.next(); - Object Xobj = firstmatch.get("?X"); - Object Yobj = firstmatch.get("?Y"); - System.out.println(" " + Xobj + " : " + Yobj); + System.out.println("John obj: "+objJohn); + + Iterator ancestorVals = objJohn.getVDN_ancestors(); + while (ancestorVals.hasNext()) { + System.out.println("John's ancestors: " + ancestorVals.next()); } - + + // good bye session.close(); System.exit(0); } |
|
From: Michael K. <ki...@us...> - 2006-09-10 18:53:48
|
Update of /cvsroot/flora/flora2/pkgs In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11513/pkgs Modified Files: javaAPI.flr Log Message: enhancements to java API Index: javaAPI.flr =================================================================== RCS file: /cvsroot/flora/flora2/pkgs/javaAPI.flr,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- javaAPI.flr 2 Jun 2006 04:52:16 -0000 1.6 +++ javaAPI.flr 10 Sep 2006 18:53:45 -0000 1.7 @@ -25,17 +25,15 @@ ** */ -/* Flora2 code to dump a flora class as a java class +/* FLORA-2 code to dump a FLORA class as a Java class ** The exported predicate is %write(Obj,Module,FileName) ** Obj : Flora Class ** Module : Module in which the flora class has been loaded ** FileName : Name of the java file */ -// NEED TO DEAL WITH CASES WHERE THE SAME NAME OS USED FOR INHERITABLE AND NON ?- debug[%check_undefined(on)]@flora(sys). - ?- debug[%ignore_undefcheck((?[=>?], ?[*=>?], ?[=>%?], @@ -47,8 +45,14 @@ %write(?Obj,?Module,?FileName) :- %openFile(?FileName), - %writeImports, - %writeStartClass(?Obj), + ( flora_install_dir(?FloraDir), + flora_slash(?S), + flora_concat_atoms([?FloraDir,?S,pkgs,?S,include,?S,'javaAPI.flh'], + ?IncludeFile) + )@prolog(flrporting), + // copy include file to stdout and replace PROXY_CLASS with class name + flora_copy_and_preprocess(?IncludeFile,?, + [' -D PROXY_CLASS=',?Obj])@prolog(flrutils), %writeBooleanMethods(?Obj,?Module,booleanMethodInh,DATA), %writeBooleanMethods(?Obj,?Module,booleanMethodNoninh,DATA), %writeBooleanMethods(?Obj,?Module,booleanMethodInh,SIGNATURE), @@ -64,63 +68,8 @@ %writeValueMethods(?Obj,?Module,valueMethodNoninh,SIGNATURE), %closeFile. -%openFile(?FileName) :- - ?FileName[%tell]@flora(io). - -/* Writing the first import statement */ -%writeImports :- - writeln(' -import java.util.*; -import com.declarativa.interprolog.TermModel; -import net.sourceforge.flora.javaAPI.util.*; -import net.sourceforge.flora.javaAPI.src.*;')@prolog(). - -/* Writing the class statement */ -%writeStartClass(?Obj) :- - write('public class ')@prolog(), - write(?Obj)@prolog(), - writeln(' extends FloraConstants {')@prolog(), - %writeConstructor(?Obj), - %writeToStringMethod(). - -%writeConstructor(?Obj) :- - writeln(' -FloraObject sourceFloraObject; -String moduleName;')@prolog(), - write('TermModel floraClassName = new TermModel("')@prolog(), - %write(?Obj)@flora(io), - writeln('");')@prolog(), - - write('public ')@prolog(), - write(?Obj)@prolog(), - writeln('(FloraObject sourceFloraObject,String moduleName) {')@prolog(), - writeln(' -this.sourceFloraObject = sourceFloraObject; -if (sourceFloraObject == null) - throw new FlrException("Cannot create Java class " + floraClassName - + ". Null sourceFloraObject object passed to " - + floraClassName + "(sourceFloraObject,moduleName)"); -this.moduleName = moduleName; -}')@prolog(), - - write('public ')@prolog(), - write(?Obj)@prolog(), - writeln('(String floraOID,String moduleName,FloraSession session) {')@prolog(), - writeln(' -this.sourceFloraObject = new FloraObject(floraOID,session); -this.moduleName = moduleName; -}')@prolog(). - - -%writeToStringMethod() :- - writeln(' -public String toString() { -return sourceFloraObject.toString(); -}')@prolog(). - -%closeFile :- - writeln('}')@prolog(), - told@prolog(). +%openFile(?FileName) :- ?FileName[%tell]@flora(io). +%closeFile :- %indent(0), writeln('}')@prolog(), told@prolog(). /* Find all the methods of the object and write them to the java file */ @@ -150,7 +99,8 @@ %callXOnList(?Op,?Rest,?DataOrSign). /* Calling the same functions for inheritable/non-inheritable versions - of the method */ + of the method +*/ %booleanMethodInh(?Method,?DataOrSign) :- %booleanMethodAny(?Method,INHERITABLE,?DataOrSign). %booleanMethodNoninh(?Method,?DataOrSign) :- @@ -185,7 +135,6 @@ %valueMethodDelete(?Method,?Inherit,?DataOrSign), %valueMethodDeleteAll(?Method,?Inherit,?DataOrSign). - // Boolean %boolMethodGet(?Method,?Inherit,?DataOrSign) :- %boolMethodGetProto(?Method,?Inherit,?DataOrSign), @@ -208,6 +157,7 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean getB~w~w_',[?Modifier1,?Modifier2])@prolog(), %write(?FnName)@flora(io), write('(')@prolog(), @@ -219,6 +169,7 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public Iterator getB~w~wall_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -226,20 +177,25 @@ writeln(')')@prolog(). %boolMethodGetBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallGetBody(?Method,?Inherit,getboolean,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %boolMethodGetAllBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallGetBody(?Method,?Inherit,getbooleanAll,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %boolMethodSetProto(?Method,?Inherit,?DataOrSign) :- ?Method =.. [?H|?FnArgs], (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean setB~w~w_',[?Modifier1,?Modifier2])@prolog(), %write(?FnName)@flora(io), write('(')@prolog(), @@ -247,15 +203,18 @@ writeln(')')@prolog(). %boolMethodSetBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallSetBody(?Method,?Inherit,setboolean,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %boolMethodDeleteProto(?Method,?Inherit,?DataOrSign) :- ?Method =.. [?H|?FnArgs], (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean deleteB~w~w_',[?Modifier1,?Modifier2])@prolog(), %write(?FnName)@flora(io), write('(')@prolog(), @@ -263,9 +222,11 @@ writeln(')')@prolog(). %boolMethodDeleteBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallDeleteBody(?Method,?Inherit,deleteboolean,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). // Procedural %procMethodGet(?Method,?Inherit,?DataOrSign) :- @@ -289,7 +250,9 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), - format('public boolean getP~w~w_',[?Modifier1,?Modifier2])@prolog(format), + %indent(1), + format('public boolean getP~w~w_', + [?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), %writeParlist(?FnArgs), @@ -300,27 +263,34 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), - format('public Iterator getallP~w~w_',[?Modifier1,?Modifier2])@prolog(format), + %indent(1), + format('public Iterator getallP~w~w_', + [?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), %writeParlist(?FnArgs), writeln(')')@prolog(). %procMethodGetBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallGetBody(?Method,?Inherit,getprocedural,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %procMethodGetAllBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallGetBody(?Method,?Inherit,getproceduralAll,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %procMethodSetProto(?Method,?Inherit,?DataOrSign) :- ?Method =.. [?H|?FnArgs], (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean setP~w~w_',[?Modifier1,?Modifier2])@prolog(), %write(?FnName)@flora(io), write('(')@prolog(), @@ -328,15 +298,18 @@ writeln(')')@prolog(). %procMethodSetBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallSetBody(?Method,?Inherit,setprocedural,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %procMethodDeleteProto(?Method,?Inherit,?DataOrSign) :- ?Method =.. [?H|?FnArgs], (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean deleteP~w~w_',[?Modifier1,?Modifier2])@prolog(), %write(?FnName)@flora(io), write('(')@prolog(), @@ -344,14 +317,16 @@ writeln(')')@prolog(). %procMethodDeleteBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallDeleteBody(?Method,?Inherit,deleteprocedural,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). /* The set and the get functions involve writing the prototype and the - body of the function */ - + body of the function +*/ %valueMethodSet(?Method,?Inherit,?DataOrSign) :- %valueMethodSetProto(?Method,?Inherit,?DataOrSign), %valueMethodSetBody(?Method,?Inherit,?DataOrSign), @@ -383,6 +358,7 @@ else (?H = ?FnName, ?Msg = 'Object value)'), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean setV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -395,6 +371,7 @@ else (?H = ?FnName, ?Msg = 'Vector value)'), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean setV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -406,6 +383,7 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public Iterator getV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -417,6 +395,7 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public Iterator getallV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -429,6 +408,7 @@ else (?H = ?FnName, ?Msg = 'Object value)'), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean deleteV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -441,6 +421,7 @@ else (?H = ?FnName, ?Msg = 'Vector value)'), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean deleteV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -452,6 +433,7 @@ (?H = hilog(?FnName), ! ; ?H = ?FnName), (?DataOrSign==DATA, !, ?Modifier1=D ; ?Modifier1=S), (?Inherit==INHERITABLE, !, ?Modifier2=I ; ?Modifier2=N), + %indent(1), format('public boolean deleteV~w~w_',[?Modifier1,?Modifier2])@prolog(format), %write(?FnName)@flora(io), write('(')@prolog(), @@ -461,29 +443,39 @@ /* Writing the body */ %valueMethodSetBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallSetBody(?Method,?Inherit,setvalue,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %valueMethodGetBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallGetBody(?Method,?Inherit,getvalue,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %valueMethodGetAllBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallGetBody(?Method,?Inherit,getvalueAll,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %valueMethodDeleteBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallDeleteBody(?Method,?Inherit,deletevalue,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %valueMethodDeleteAllBody(?Method,?Inherit,?DataOrSign) :- + %indent(1), writeln('{')@prolog(), %parentCallDeleteAllBody(?Method,?Inherit,?DataOrSign), - writeln('}')@prolog(). + %indent(1), + writeln('}\n')@prolog(). %parentCallSetBody(?Method,?Inherit,?Type,?DataOrSign) :- ?Method =.. [?H|?FnArgs], @@ -493,10 +485,12 @@ %writeProxySetCall(?FnName,?Inherit,?Type,?DataOrSign). %writeVectorParsInit:- + %indent(2), writeln('Vector pars = new Vector();')@prolog(). %writeProxySetCall(?FnName,?Inherit,?Type,?DataOrSign) :- (?Inherit==INHERITABLE, !, ?Modifier=I ; ?Modifier=N), + %indent(2), format('return sourceFloraObject.~w(moduleName,"',[?Type])@prolog(format), %write(?FnName)@flora(io), write('",')@prolog(), @@ -515,6 +509,7 @@ %writeProxyGetCall(?FnName,?Inherit,?Type,?DataOrSign). %writeProxyGetCall(?FnName,?Inherit,?Type,?DataOrSign) :- + %indent(2), format('return sourceFloraObject.~w(moduleName,"',[?Type])@prolog(format), %write(?FnName)@flora(io), write('",')@prolog(), @@ -540,6 +535,7 @@ %writeProxyDeleteBody(?FnName,?Inherit,?Type,?DataOrSign). %writeProxyDeleteBody(?FnName,?Inherit,?Type,?DataOrSign) :- + %indent(2), format('return sourceFloraObject.~w(moduleName,"',[?Type])@prolog(format), %write(?FnName)@flora(io), write('",')@prolog(), @@ -558,6 +554,7 @@ %writeProxyDeleteAllBody(?FnName,?Inherit,?DataOrSign). %writeProxyDeleteAllBody(?FnName,?Inherit,?DataOrSign) :- + %indent(2), write('return sourceFloraObject.deletevalue(moduleName,"')@prolog(), %write(?FnName)@flora(io), write('",')@prolog(), @@ -567,41 +564,32 @@ writeln(',pars);')@prolog(). /* Predicates to write parameter lists */ -%writeParlist([]). -%writeParlist([?A|[]]) :- - write('Object ')@prolog(), - %write(?A)@flora(io). - +%writeParlist([]) :- true. %writeParlist([?A|?X]) :- - ?X\=[], write('Object ')@prolog(), %write(?A)@flora(io), - write(', ')@prolog(), - %writeParlist(?X). - + unless ?X == [] do ( + write(', ')@prolog(), + %writeParlist(?X) + ). -%writeBodyList([]). -%writeBodyList([?A|[]]) :- - write('pars.add(')@prolog(), - %write(?A)@flora(io), - writeln(');')@prolog(). +%writeBodyList([]) :- true. %writeBodyList([?A|?X]) :- - ?X\=[], + %indent(2), write('pars.add(')@prolog(), %write(?A)@flora(io), writeln(');')@prolog(), %writeBodyList(?X). -%writeGetAllBodyList([]). -%writeGetAllBodyList([?A|[]]) :- - write('pars.add("Par_')@prolog(), - %write(?A)@flora(io), - writeln('");')@prolog(). - +%writeGetAllBodyList([]) :- true. %writeGetAllBodyList([?A|?X]) :- - ?X\=[], + %indent(2), write('pars.add("Par_')@prolog(), %write(?A)@flora(io), writeln('");')@prolog(), %writeGetAllBodyList(?X). + +%indent(0) :- !. +%indent(1) :- !, write(' ')@prolog(). +%indent(?N) :- ?N>1, write(' ')@prolog(), ?N1 is ?N-1, %indent(?N1). |
|
From: Michael K. <ki...@us...> - 2006-09-10 18:53:48
|
Update of /cvsroot/flora/flora2/java/API/examples/flogicbasicsExample In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11513/java/API/examples/flogicbasicsExample Modified Files: person.java flogicbasicsExample.java Log Message: enhancements to java API Index: person.java =================================================================== RCS file: /cvsroot/flora/flora2/java/API/examples/flogicbasicsExample/person.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- person.java 2 Jun 2006 04:52:17 -0000 1.4 +++ person.java 10 Sep 2006 18:53:46 -0000 1.5 @@ -1,3 +1,11 @@ +/* File: javaAPI.flh +** +** Author(s): Michael Kifer +** +** Template included with every high-level Java object in the FLORA-2 Java API. +** +*/ + import java.util.*; import com.declarativa.interprolog.TermModel; [...1968 lines suppressed...] -return sourceFloraObject.setvalue(moduleName,"salary",NONINHERITABLE,SIGNATURE,pars,value); -} -public boolean deleteVSN_salary(Object year,Vector value) -{ -Vector pars = new Vector(); -pars.add(year); -return sourceFloraObject.deletevalue(moduleName,"salary",NONINHERITABLE,SIGNATURE,pars,value); -} -public boolean deleteVSN_salary(Object year,Object value) -{ -Vector pars = new Vector(); -pars.add(year); -return sourceFloraObject.deletevalue(moduleName,"salary",NONINHERITABLE,SIGNATURE,pars,value); -} -public boolean deleteVSN_salary(Object year){ -Vector pars = new Vector(); -pars.add(year); -return sourceFloraObject.deletevalue(moduleName,"salary",NONINHERITABLE,SIGNATURE,pars); -} } Index: flogicbasicsExample.java =================================================================== RCS file: /cvsroot/flora/flora2/java/API/examples/flogicbasicsExample/flogicbasicsExample.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- flogicbasicsExample.java 2 Jun 2006 04:52:17 -0000 1.4 +++ flogicbasicsExample.java 10 Sep 2006 18:53:46 -0000 1.5 @@ -127,6 +127,14 @@ while (instanceIter.hasNext()) System.out.println(" " + (FloraObject)instanceIter.next()); + // same as above, but using high-level interface + person personClass = new person("person", "example", session); + instanceIter = personClass.getInstances(); + System.out.println("Person instances using high-level API:"); + while (instanceIter.hasNext()) + System.out.println(" " + (FloraObject)instanceIter.next()); + + instanceIter = personObj.getDirectInstances("example"); System.out.println("Person direct instances:"); while (instanceIter.hasNext()) |
|
From: Michael K. <ki...@us...> - 2006-09-10 18:53:48
|
Update of /cvsroot/flora/flora2/java/API/examples/fooExample In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11513/java/API/examples/fooExample Modified Files: foo.java Log Message: enhancements to java API Index: foo.java =================================================================== RCS file: /cvsroot/flora/flora2/java/API/examples/fooExample/foo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- foo.java 2 Jun 2006 04:52:17 -0000 1.4 +++ foo.java 10 Sep 2006 18:53:46 -0000 1.5 @@ -1,3 +1,11 @@ +/* File: javaAPI.flh +** +** Author(s): Michael Kifer +** +** Template included with every high-level Java object in the FLORA-2 Java API. +** +*/ + import java.util.*; import com.declarativa.interprolog.TermModel; [...1984 lines suppressed...] -{ -Vector pars = new Vector(); -pars.add(year); -pars.add(month); -return sourceFloraObject.deletevalue(moduleName,"bonus",NONINHERITABLE,SIGNATURE,pars,value); -} -public boolean deleteVSN_bonus(Object year, Object month,Object value) -{ -Vector pars = new Vector(); -pars.add(year); -pars.add(month); -return sourceFloraObject.deletevalue(moduleName,"bonus",NONINHERITABLE,SIGNATURE,pars,value); -} -public boolean deleteVSN_bonus(Object year, Object month){ -Vector pars = new Vector(); -pars.add(year); -pars.add(month); -return sourceFloraObject.deletevalue(moduleName,"bonus",NONINHERITABLE,SIGNATURE,pars); -} } |
|
From: Michael K. <ki...@us...> - 2006-09-10 18:53:47
|
Update of /cvsroot/flora/flora2/pkgs/include In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11513/pkgs/include Added Files: javaAPI.flh Log Message: enhancements to java API --- NEW FILE: javaAPI.flh --- /* File: javaAPI.flh ** ** Author(s): Michael Kifer ** ** Template included with every high-level Java object in the FLORA-2 Java API. ** */ import java.util.*; import com.declarativa.interprolog.TermModel; import net.sourceforge.flora.javaAPI.util.*; import net.sourceforge.flora.javaAPI.src.*; public class PROXY_CLASS extends FloraConstants { static TermModel floraClassName = new TermModel("PROXY_CLASS"); FloraObject sourceFloraObject; String moduleName; public PROXY_CLASS(FloraObject sourceFloraObject,String moduleName) { this.sourceFloraObject = sourceFloraObject; if (sourceFloraObject == null) throw new FlrException("Cannot create Java class " + floraClassName + ". Null FloraObject passed to " + floraClassName + "(sourceFloraObject,moduleName)"); this.moduleName = moduleName; } public PROXY_CLASS(String floraOID,String moduleName,FloraSession session) { this.sourceFloraObject = new FloraObject(floraOID,session); this.moduleName = moduleName; } public String toString() { return sourceFloraObject.toString(); } // Sub/Superclass methods public Iterator getDirectInstances() { return sourceFloraObject.getDirectInstances(moduleName); } public Iterator getInstances() { return sourceFloraObject.getInstances(moduleName); } public Iterator getDirectSubClasses() { return sourceFloraObject.getDirectSubClasses(moduleName); } public Iterator getSubClasses() { return sourceFloraObject.getSubClasses(moduleName); } public Iterator getDirectSuperClasses() { return sourceFloraObject.getDirectSuperClasses(moduleName); } public Iterator getSuperClasses() { return sourceFloraObject.getSuperClasses(moduleName); } // Java proxy methods for FLORA-2 methods |
|
From: Michael K. <ki...@us...> - 2006-09-10 18:52:56
|
Update of /cvsroot/flora/flora2/pkgs/include In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11081/pkgs/include Log Message: Directory /cvsroot/flora/flora2/pkgs/include added to the repository |
|
From: Michael K. <ki...@us...> - 2006-09-10 18:52:26
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11017 Modified Files: flrutils.P flrutils.H flrundefhook.P flrporting.P Log Message: better support for java API Index: flrutils.P =================================================================== RCS file: /cvsroot/flora/flora2/flrutils.P,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- flrutils.P 23 May 2006 17:19:23 -0000 1.74 +++ flrutils.P 10 Sep 2006 18:52:18 -0000 1.75 @@ -870,7 +870,7 @@ flora_set_xpp_options(Purpose) :- - retractall(xpp_options(_)), + flora_clear_xpp_options, (Purpose==read -> flora_xpp_standard_options_for_read(StandardOpt) ; Purpose==dump @@ -884,7 +884,7 @@ flora_increment_counter(flora_compile_id,1,_,Id) ), flora_concat_items([StandardOpt,' -D FLORA_COMPILATION_ID=',Id,' '],Opt), - assert(xpp_options(Opt)). + flora_assert_xpp_options(Opt). %% This is always called before invoking GPP. @@ -894,7 +894,7 @@ %% flora_set_xpp_options finishes. %% Purpose is either read or compile. flora_set_xpp_options(Purpose,ModuleName) :- - retractall(xpp_options(_)), + flora_clear_xpp_options, flora_module_name(ModuleName,Type,WS), ( Type == usermodule -> ExtraOpt='' @@ -918,7 +918,7 @@ flora_concat_items([StandardOpt,' -D FLORA_VAR_WORKSPACE=',WS, ' ',ExtraOpt,' -D FLORA_COMPILATION_ID=',Id,' '], Opt), - assert(xpp_options(Opt)), + flora_assert_xpp_options(Opt), !. @@ -930,13 +930,19 @@ %% Adds NewOpt to the existing XPP options flora_add_xpp_options(NewOpt) :- xpp_options(XOpt), - retractall(xpp_options(_)), + flora_clear_xpp_options, flora_concat_atoms([XOpt,' ',NewOpt],Opt), - assert(xpp_options(Opt)). + flora_assert_xpp_options(Opt). flora_clear_xpp_options :- retractall(xpp_options(_)). +flora_assert_xpp_options(Options) :- assert(xpp_options(Options)). + +flora_replace_xpp_options(Options) :- + flora_clear_xpp_options, + flora_assert_xpp_options(Options). + /************************************************************************* flora_insert_code_for_loaddyn_data(+FileName) @@ -2697,6 +2703,32 @@ fail. +/***************************************************************************** + flora_copy_and_preprocess(?Input, ?Output, +GPP_OptionsList) + + Input and Output are either bound to file names or are unbound variables. + GPP_OptionsList is a list of options to pass to the preprocessor. + Each option is an atom. The atoms in the list are concatenated + and passed to gpp. +*****************************************************************************/ +flora_copy_and_preprocess(Input,Output,GPP_OptionsList) :- + flora_concat_atoms(GPP_OptionsList, XPP_Options), + flora_replace_xpp_options(XPP_Options), + xpp_process_file(Input,XPP_process,IOportFromGPP), + %% Save standard input and output ports + seeing(StdIn), + telling(StdOut), + flora_copy_input(IOportFromGPP,Output), + process_control(XPP_process,wait(ExitStatus)), + (ExitStatus==0, ! + ; flora_error_line('Error while preprocessing ~w', [Input]) + ), + flora_clear_xpp_options, + seen, + %% Restore the old stdin and stdout + see(StdIn), + tell(StdOut). + /***************************************************************************** flora_measure_time(+Call,+Message) @@ -2711,15 +2743,6 @@ flora_message_line('~w ~w seconds',[Message,Delta]). -%% From, To are file names. Variable means stdin or stdout, respectively -flora_copy_input(From,To) :- - (var(From), ! ; seeing(OldIn), see(From)), - (var(To), ! ; telling(OldOut), tell(To)), - flora_copy_input, - (var(From), ! ; seen, see(OldIn)), - (var(To), ! ; told, tell(OldOut)). - - flora_abort :- xsb_backtrace(Bt), close_open_tables, Index: flrutils.H =================================================================== RCS file: /cvsroot/flora/flora2/flrutils.H,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- flrutils.H 23 May 2006 17:19:23 -0000 1.39 +++ flrutils.H 10 Sep 2006 18:52:18 -0000 1.40 @@ -47,7 +47,7 @@ flora_increment_counter/4, flora_concat_atoms/2, flora_concat_items/2, - flora_copy_input/0, + flora_copy_input/2, flora_write_atom/1, flora_running_under/1 from flrporting. @@ -240,6 +240,8 @@ flora_set_xpp_options_for_read/2, flora_clear_xpp_options/0, flora_add_xpp_options/1, + flora_replace_xpp_options/1, + flora_copy_and_preprocess/3, flora_list2conjunct/2, flora_check_workspace/1, Index: flrporting.P =================================================================== RCS file: /cvsroot/flora/flora2/flrporting.P,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- flrporting.P 6 May 2006 06:59:03 -0000 1.26 +++ flrporting.P 10 Sep 2006 18:52:18 -0000 1.27 @@ -57,6 +57,7 @@ :- import flora_abort/1 from flrutils. +:- import flora_configuration/2 from flrregistry. :- export flora_write_quoted_atom/1, @@ -69,7 +70,9 @@ flora_read_line_as_atom/1, flora_read_line_as_list/1, flora_copy_input/0, + flora_copy_input/2, flora_user_home/1, + flora_install_dir/1, flora_atom_length/2, flora_match_substring/3, flora_match_substring/5, @@ -159,6 +162,9 @@ %% User Home flora_user_home(Path) :- xsb_configuration(user_home,Path). +%% where Flora is installed +flora_install_dir(Path) :- flora_configuration(installdir,Path). + %% File system-related flora_file_op(exists,File) :- path_sysop(exists,File). flora_file_op(readable,File) :- path_sysop(readable,File). @@ -189,6 +195,14 @@ telling(StdOut), copyIOport(StdIn,StdOut). +%% From, To are file names. Variable means stdin or stdout, respectively +flora_copy_input(From,To) :- + (var(From), ! ; seeing(OldIn), see(From)), + (var(To), ! ; telling(OldOut), tell(To)), + flora_copy_input, + (var(From), ! ; seen, see(OldIn)), + (var(To), ! ; told, tell(OldOut)). + flora_write_atom_quoted_as_needed(Atom) :- \+atom(Atom), Index: flrundefhook.P =================================================================== RCS file: /cvsroot/flora/flora2/flrundefhook.P,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- flrundefhook.P 9 Sep 2006 19:04:47 -0000 1.10 +++ flrundefhook.P 10 Sep 2006 18:52:18 -0000 1.11 @@ -49,7 +49,7 @@ flora_undefined_predicate_hook(PredName,Arity,PrologModule) :- %% Decode the predicate symbol. functor(PCall,PredName,Arity), - flora_decode_predicate(PCall,PredicateType,ModuleName,_,PredicateSymbol,_), + flora_decode_predicate(PCall,PredicateType,ModuleName,_,_PredSymbol,_), ( PredicateType == (flogic) -> %% an F-logic predicate flora_decode_goal_as_atom(PCall,PCallAtom), |
|
From: Michael K. <ki...@us...> - 2006-09-09 19:05:27
|
Update of /cvsroot/flora/flora2/pkgs/prolog In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12218/pkgs/prolog Modified Files: flrpm.P Log Message: memory leak killed Index: flrpm.P =================================================================== RCS file: /cvsroot/flora/flora2/pkgs/prolog/flrpm.P,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- flrpm.P 17 May 2006 06:52:28 -0000 1.1 +++ flrpm.P 9 Sep 2006 19:05:25 -0000 1.2 @@ -174,14 +174,18 @@ [dbdrivers], load_driver(ODBC), %% does a db handle exist for this DSN/UserName/Password? - ( flora_dbmodule_handle(DSN,UserName,Password,DBHandle) + ( flora_dbmodule_handle(DSN,UserName,Password,DBHandle) -> true ; - gensym(DBHANDLE,DBHandle), - db_connect_internal(DBHandle,ODBC,DSN,UserName,Password), - assert(flora_dbmodule_handle(DSN,UserName,Password,DBHandle)) + gensym(DBHANDLE,DBHandle), + db_connect_internal(DBHandle,ODBC,DSN,UserName,Password), + assert(flora_dbmodule_handle(DSN,UserName,Password,DBHandle)), + aux_prepare_db(Database,DSN,ModuleName,DBHandle) + ), + (flora_dbmodule_registry(ModuleName,Database,DSN,UserName,Password) + -> true + ; + assert(flora_dbmodule_registry(ModuleName,Database,DSN,UserName,Password)) ), - aux_prepare_db(Database,DSN,ModuleName,DBHandle), - assert(flora_dbmodule_registry(ModuleName,Database,DSN,UserName,Password)), aux_memory_to_db(ModuleName). @@ -199,7 +203,7 @@ load_driver(ODBC), %% does a db handle exist for this triplet? ( - flora_dbmodule_handle(DSN,UserName,Password,DBHandle) + flora_dbmodule_handle(DSN,UserName,Password,DBHandle) -> true ; gensym(DBHANDLE,DBHandle), db_connect_internal(DBHandle,ODBC,DSN,UserName,Password), @@ -346,7 +350,9 @@ !, aux_add_tables_to_memory(WRAP_LIST,ModuleName), %% indicate that all the db info for this module has been retrieved. - assert(flora_dbmodule_inmemory(ModuleName)). + (flora_dbmodule_inmemory(ModuleName) -> true + ; assert(flora_dbmodule_inmemory(ModuleName)) + ). /**************************************************************************** |
|
From: Michael K. <ki...@us...> - 2006-09-09 19:04:56
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11834 Modified Files: flrundefhook.P flrundefhook.H Log Message: bug fix Index: flrundefhook.P =================================================================== RCS file: /cvsroot/flora/flora2/flrundefhook.P,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- flrundefhook.P 24 Aug 2004 17:57:28 -0000 1.9 +++ flrundefhook.P 9 Sep 2006 19:04:47 -0000 1.10 @@ -52,13 +52,14 @@ flora_decode_predicate(PCall,PredicateType,ModuleName,_,PredicateSymbol,_), ( PredicateType == (flogic) -> %% an F-logic predicate + flora_decode_goal_as_atom(PCall,PCallAtom), ( flLoadedModule(ModuleName) -> %% This is very unlikely to happen unless something goes wrong. - flora_error_line('Attempt to call undefined F-logic molecule `~w'' in FLORA module `~w''', - [PredicateSymbol/Arity,ModuleName]) + flora_error_line('Attempt to call undefined F-logic molecule of the form ~w in FLORA module `~w''', + [PCallAtom, ModuleName]) ; - flora_error_line('Attempt to call an F-logic molecule in an unloaded FLORA module `~w''', - [PredicateSymbol/Arity,ModuleName]) + flora_error_line('Attempt to call an F-logic molecule of the form ~w in an unloaded FLORA module `~w''', + [PCallAtom, ModuleName]) ) ; PredicateType == (hilog) -> Index: flrundefhook.H =================================================================== RCS file: /cvsroot/flora/flora2/flrundefhook.H,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- flrundefhook.H 3 Mar 2003 20:52:53 -0000 1.4 +++ flrundefhook.H 9 Sep 2006 19:04:47 -0000 1.5 @@ -31,4 +31,6 @@ :- import flora_error_line/2 from flrprint. +:- import flora_decode_goal_as_atom/2 from flrdecode. + :- export flora_undefined_predicate_hook/3. |