org.jscience.computing.ai.expertsystem.conflict
Class AbstractConflictSet

java.lang.Object
  extended by org.jscience.computing.ai.expertsystem.conflict.AbstractConflictSet
All Implemented Interfaces:
ConflictSet
Direct Known Subclasses:
DefaultConflictSet, LRUConflictSet, MRUConflictSet, OneShotConflictSet, PriorityConflictSet

public abstract class AbstractConflictSet
extends java.lang.Object
implements ConflictSet

This class provides a skeletal implementation of the ConflictSet interface to minimize the effort required to implement this interface. It helps mainly in dealing with the registered listeners for conflict set events. Its subclasses must invoke the methods elementAdded and elementRemoved wheneved applicable to make full use of the notification mechanism this skeleton provides.


Field Summary
protected  boolean debug
          Flag indicating whether there is some registered listener.
protected  java.util.Vector listeners
          The event listeners.
 
Constructor Summary
AbstractConflictSet()
          Class constructor.
 
Method Summary
 void addInternalConflictSetListener(InternalConflictSetListener l)
          Adds the specified listener to receive events from this conflict set.
protected  void elementAdded(ConflictSetElement e)
          Callback method, used to indicate that an element has been added to this conflict set.
protected  void elementRemoved(ConflictSetElement e)
          Callback method, used to indicate that an element has been removed from this conflict set.
protected  void removeElementsWith_1D(java.util.Vector fireableRules, java.lang.Object obj)
          Auxiliar method, used to remove the elements that use a given object in its instantiations.
protected  int removeElementsWith_2D(java.util.Vector fireableRules, java.lang.Object obj)
          Auxiliar method, used to remove the elements that use a given object in its instantiations.
 void removeInternalConflictSetListener(InternalConflictSetListener l)
          Removes the specified listener so that it no longer receives events from this conflict set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jscience.computing.ai.expertsystem.conflict.ConflictSet
flush, insertElement, isEmpty, nextElement, removeElementsWith
 

Field Detail

listeners

protected java.util.Vector listeners
The event listeners.


debug

protected boolean debug
Flag indicating whether there is some registered listener.

Constructor Detail

AbstractConflictSet

public AbstractConflictSet()
Class constructor.

Method Detail

addInternalConflictSetListener

public void addInternalConflictSetListener(InternalConflictSetListener l)
Adds the specified listener to receive events from this conflict set.

Specified by:
addInternalConflictSetListener in interface ConflictSet
Parameters:
l - the conflict set listener

elementAdded

protected void elementAdded(ConflictSetElement e)
Callback method, used to indicate that an element has been added to this conflict set.

Parameters:
e - the element that has been added to this conflict set.

elementRemoved

protected void elementRemoved(ConflictSetElement e)
Callback method, used to indicate that an element has been removed from this conflict set. Elements that are returned by the nextElement are not considered as been removed.

Parameters:
e - the element that has been removed from this conflict set.

removeElementsWith_1D

protected void removeElementsWith_1D(java.util.Vector fireableRules,
                                     java.lang.Object obj)
Auxiliar method, used to remove the elements that use a given object in its instantiations. This method should be used when the fireable rules are stored in a linear (unidimensional) Vector.

Parameters:
fireableRules - the Vector that stores the fireable rules.
obj - the given object.

removeElementsWith_2D

protected int removeElementsWith_2D(java.util.Vector fireableRules,
                                    java.lang.Object obj)
Auxiliar method, used to remove the elements that use a given object in its instantiations. This method should be used when the fireable rules are stored in a matricial (bidimensional) Vector.

Parameters:
fireableRules - the Vector that stores the fireable rules.
obj - the given object.
Returns:
the number of elements that have been removed.

removeInternalConflictSetListener

public void removeInternalConflictSetListener(InternalConflictSetListener l)
Removes the specified listener so that it no longer receives events from this conflict set.

Specified by:
removeInternalConflictSetListener in interface ConflictSet
Parameters:
l - the conflict set listener