I am stumbling for some time now with the use of a JessListener. After
many tries, I figured out that the listener does not work properly when
I bload() certain files.
Since the Rete class implements JessListener, for ease of testing I
extended it and got to the class below.
>From my experiences, if the bsave file is empty, it works fine. If I use
another bsaved file that I have, I get problems. Only the retracted
facts are being notified.
Is this a bug? What should I look for in my bsaved file?
Thanks.
Henrique
//---------------------------------------------
public class JEL extends Rete {
public JEL() {
super();
// set event mask
setEventMask(JessEvent.FACT);
// load file
try {
FileInputStream fis = new FileInputStream("somefile.bsave");
bload(fis);
fis.close();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
public void eventHappened(JessEvent jev) {
System.out.println("EVENT:" +
JessEvent.getEventName(jev.getType()));
switch(jev.getType()) {
case JessEvent.FACT | JessEvent.REMOVED: // retraction
Fact whatWasRetracted = (Fact) jev.getObject();
System.out.println("- - -" + whatWasRetracted);
break;
case JessEvent.FACT: // assertion
Fact whatWasAsserted = (Fact) jev.getObject();
System.out.println("+ + +" + whatWasAsserted);
break;
}
}
public static void main(String args[]) {
JEL jel = new JEL();
try {
jel.assertString("(qwe)");
jel.retractString("(qwe)");
jel.assertString("(asd)");
} catch(JessException je) {
je.printStackTrace();
}
}
}
//----------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------