com.cra.bnet.engine
Class StructuralModificationSupport

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

public class StructuralModificationSupport
extends Object

A utility class used for detecting structural modifications to a Bayesian network. Structural modifications are:

Instances of this class listen for these events from a Bayesian network and fire change events when any of them occur. The source in the change events is always the Bayesian network.


Constructor Summary
StructuralModificationSupport(BayesianNetwork network)
          Creates a new StructuralModificationSupport that listens for structural modifcations to the specified Bayesian network.
StructuralModificationSupport(BayesianNetwork network, ChangeListener listener)
          Creates a new StructuralModificationSupport that listens for structural modifcations to the specified Bayesian network and registers the specified change listener.
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Registers the specified change listener to receive events whenever structural modifications are made to the Bayesian network.
protected  void fireChangeEvent()
          Fires a change event to all registered change listeners.
 BayesianNetwork getNetwork()
          Returns the Bayesian network this listener is observing for structural modifications.
 void removeChangeListener(ChangeListener listener)
          Unregisters the specified change listener so it will no longer receive change events when structural modifications are made to the Bayesian network.
 void setNetwork(BayesianNetwork network)
          Sets the Bayesian network to observe for structural modifications to the specified network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructuralModificationSupport

public StructuralModificationSupport(BayesianNetwork network)
Creates a new StructuralModificationSupport that listens for structural modifcations to the specified Bayesian network.

Parameters:
network - Bayesian network to detect structral modifications to.

StructuralModificationSupport

public StructuralModificationSupport(BayesianNetwork network,
                                     ChangeListener listener)
Creates a new StructuralModificationSupport that listens for structural modifcations to the specified Bayesian network and registers the specified change listener. Note that clients can still register other change listeners after calling this constructor.

Parameters:
network - Bayesian network to detect structral modifications to.
listener - change listener to register.
Method Detail

addChangeListener

public void addChangeListener(ChangeListener listener)
Registers the specified change listener to receive events whenever structural modifications are made to the Bayesian network.

Parameters:
listener - change listener to register.

getNetwork

public BayesianNetwork getNetwork()
Returns the Bayesian network this listener is observing for structural modifications.

Returns:
the Bayesian network this listener is observing for structural modifications.

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Unregisters the specified change listener so it will no longer receive change events when structural modifications are made to the Bayesian network.

Parameters:
listener - change listener to unregister.

setNetwork

public void setNetwork(BayesianNetwork network)
Sets the Bayesian network to observe for structural modifications to the specified network. Calling this method stops listening to the old Bayesian network.

Parameters:
network - Bayesian network to observe for structural modifications to the specified network.

fireChangeEvent

protected void fireChangeEvent()
Fires a change event to all registered change listeners. The source of the event is the Bayesian network.