Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient
In directory sc8-pr-cvs1:/tmp/cvs-serv18511/src/org/asturlinux/frade/prolix/consoleclient
Modified Files:
ConsoleClient.java
Log Message:
Added option in console client to execute an step or advance to next solution
Index: ConsoleClient.java
===================================================================
RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient/ConsoleClient.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ConsoleClient.java 14 Jul 2003 21:49:39 -0000 1.8
--- ConsoleClient.java 20 Jul 2003 19:02:31 -0000 1.9
***************
*** 1,2 ****
--- 1,3 ----
+
/**
*
***************
*** 41,47 ****
private ProlixMain interpreter;
- private String hardCodedProgram = "hermano(X,Y):=padre(X,Z),padre(Y,Z).padre(Felipe,JC).padre(Helena,JC)";
- private String hardCodedConsult = "hermano(X,Y)";
-
public static void main(String args[]) {
ConsoleClient console = new ConsoleClient();
--- 42,45 ----
***************
*** 57,63 ****
// Obtain reference to home
InitialContext ctx = new InitialContext();
- //Object o = ctx.lookup( "org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMain" );
- //ProlixMainHome home = null;
- // home = (ProlixMainHome)PortableRemoteObject.narrow(o, ProlixMainHome.class);
ProlixMainHome home = (ProlixMainHome)ctx.lookup(ProlixMainHome.JNDI_NAME);
// Create the interpreter bean
--- 55,58 ----
***************
*** 85,88 ****
--- 80,84 ----
"Get loaded consult",
"Step",
+ "NextSolution",
"Exit"};
***************
*** 103,109 ****
case 4: getLoadedConsult();
break;
! case 5: gostep();
break;
! case 6: otherIteration = false;
break;
}
--- 99,107 ----
case 4: getLoadedConsult();
break;
! case 5: goStep();
break;
! case 6: goNextSolution();
! break;
! case 7: otherIteration = false;
break;
}
***************
*** 131,135 ****
{
String input = new String(in.readLine());
! interpreter.loadProgram(hardCodedProgram);
}
catch (LexicalException le)
--- 129,133 ----
{
String input = new String(in.readLine());
! interpreter.loadProgram(input);
}
catch (LexicalException le)
***************
*** 170,174 ****
{
String input = new String(in.readLine());
! interpreter.loadConsult(hardCodedConsult);
}
catch (LexicalException le)
--- 168,172 ----
{
String input = new String(in.readLine());
! interpreter.loadConsult(input);
}
catch (LexicalException le)
***************
*** 206,210 ****
}
! private void gostep()
{
try
--- 204,208 ----
}
! private void goStep()
{
try
***************
*** 226,229 ****
--- 224,247 ----
}
+ private void goNextSolution()
+ {
+ try
+ {
+ System.out.println(interpreter.nextSolution());
+ }
+ catch (ProgramNotLoadedException programNotLoaded)
+ {
+ System.out.println("Unable to execute a step if you don't load a program");
+ }
+ catch (QueryNotLoadedException queryNotLoaded)
+ {
+ System.out.println("Unable to execute a step if you don't load a query");
+ }
+ catch (RemoteException remote)
+ {
+ System.out.println("Remote exception doing an step");
+ }
+
+ }
}
|