com.cra.bnet.engine
Class BeliefAlert

java.lang.Object
  |
  +--com.cra.bnet.engine.BeliefAlert

public class BeliefAlert
extends Object

Alerts belief listeners when a belief event meets a certain condition. Creating an alert is as simple as this:

 BeliefCondition condition = ...;
 BeliefListener listener = ...;
 BeliefAlert alert = new BeliefAlert(condition, listener);
 
Immediately after creating the BeliefAlert instance, the BeliefListener will begin receiving belief events that are accepted by the BeliefCondition object. Use the stop method to instruct the alert to stop firing belief events.


Constructor Summary
BeliefAlert(BeliefCondition condition)
          Creates a new BeliefAlert using the specified condition.
BeliefAlert(BeliefCondition condition, BeliefListener listener)
          Creates a new BeliefAlert using the specified condition and belief listener.
 
Method Summary
 void addBeliefListener(BeliefListener listener)
          Registers the specified belief listener so it will receive notification when belief events pass this alert's condition.
protected  void fireBeliefsChanged(BeliefEvent event)
          Fires the specified belief event to all registered belief listeners.
 BeliefCondition getBeliefCondition()
          Returns this alert's condition.
 void removeBeliefListener(BeliefListener listener)
          Unregisters the specified belief listener so it will no longer receive events from this alert.
 void stop()
          Stops this alert from firing any more belief events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeliefAlert

public BeliefAlert(BeliefCondition condition)
Creates a new BeliefAlert using the specified condition.

Parameters:
condition - belief condition.

BeliefAlert

public BeliefAlert(BeliefCondition condition,
                   BeliefListener listener)
Creates a new BeliefAlert using the specified condition and belief listener.

Parameters:
condition - belief condition.
listener - a belief listener to register with the alert.
Method Detail

addBeliefListener

public void addBeliefListener(BeliefListener listener)
Registers the specified belief listener so it will receive notification when belief events pass this alert's condition.

Parameters:
listener - belief listener.

removeBeliefListener

public void removeBeliefListener(BeliefListener listener)
Unregisters the specified belief listener so it will no longer receive events from this alert.

Parameters:
listener - belief listener.

fireBeliefsChanged

protected void fireBeliefsChanged(BeliefEvent event)
Fires the specified belief event to all registered belief listeners.

Parameters:
event - belief event.

getBeliefCondition

public BeliefCondition getBeliefCondition()
Returns this alert's condition. Belief events must be accepted by the condition to be forwarded to registered belief listeners.

Returns:
this alert's condition.

stop

public void stop()
Stops this alert from firing any more belief events. Registered belief listeners will no longer receive events from this alert. Once this alert is stopped it cannot be started again.