infosapient.util
Class FzySystemListener

java.lang.Object
  |
  +--infosapient.util.FzySystemListener

public class FzySystemListener
extends java.lang.Object
implements Observer

A listener that handles events and notifications from fzy.system objects.

An error event sets the errorEncountered property to true. Error messages received by the listener are written to the PrintWriter stream. It is up to the controlling object to determine whether to terminate processing if an error is encountered.

In this version, other notifications have the message written to the PrintWriter - no error is set.

Example:

FzyEngineController fzyControl = new FzyEngineController(false);

// create a listener with the output stream
FzySystemListener ears = new FzySystemListener(out);

// add the listener as an observer to the ctrl
fzyControl.addObserver( ears );

fzyControl.readKB("kb_error.kb");
FzyKnowledgebase kb = fzyControl.getKB();

// note we check for errors and we check that the
// business condition is satisfied (kb exists)
if (ears.isErrorEncountered() || (kb == null) ) {
log("error creating kb");
out.println("Error creating knowledgebase");
return;
}
Creation date: (1/21/00 1:02:53 PM)

Version:
$Revision: 1.1.1.1 $
See Also:
Serialized Form

Field Summary
private  boolean debug
           
private  boolean errorEncountered
           
private  java.io.PrintWriter out
           
 
Constructor Summary
FzySystemListener()
          FzySystemListener constructor comment.
FzySystemListener(java.io.PrintWriter out)
          Constructor using a PrintWriter stream to print events.
 
Method Summary
 boolean errorEncountered()
          Returns true if the listener has received an error event.
protected  void log(java.lang.String str)
          Write the message and time to system.out Creation date: (12/16/1999 1:45:42 PM)
 void setErrorEncountered(boolean newErrorEncountered)
          Sets the error-encountered flag.
 void update(Observable obser, java.lang.Object obj)
          Receives the notification of an event and acts on it.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

out

private java.io.PrintWriter out

errorEncountered

private boolean errorEncountered

debug

private boolean debug
Constructor Detail

FzySystemListener

public FzySystemListener()
FzySystemListener constructor comment.

FzySystemListener

public FzySystemListener(java.io.PrintWriter out)
Constructor using a PrintWriter stream to print events. Creation date: (12/16/1999 2:01:33 PM)
Parameters:
out - java.io.PrintWriter
Method Detail

errorEncountered

public boolean errorEncountered()
Returns true if the listener has received an error event. Creation date: (1/20/00 4:14:29 PM)
Returns:
boolean

log

protected void log(java.lang.String str)
Write the message and time to system.out Creation date: (12/16/1999 1:45:42 PM)
Parameters:
str - java.lang.String

setErrorEncountered

public void setErrorEncountered(boolean newErrorEncountered)
Sets the error-encountered flag. Creation date: (1/20/00 4:14:29 PM)
Parameters:
newErrorEncountered - boolean

update

public void update(Observable obser,
                   java.lang.Object obj)
Receives the notification of an event and acts on it. Creation date: (1/21/00 12:30:27 PM)
Specified by:
update in interface Observer
Parameters:
obser - The object sending the event.
obj - The notification being sent.

License to use this program is provided under the TERMS OF THE COMMON PUBLIC LICENSE 0.5. ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

Copyright (c) 2001, Workplace Performance Tools, All Rights Reserved