jeops.conflict
Class AbstractConflictSet

java.lang.Object
  |
  +--jeops.conflict.AbstractConflictSet
Direct Known Subclasses:
DefaultConflictSet, LRUConflictSet, MEAConflictSet, 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.

Version:
0.01 08 Jun 2000
Author:
Carlos Figueira Filho (csff@cin.ufpe.br)

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.
private  void fireInternalElementAddedEvent(InternalConflictSetEvent e)
          Dispatch an internal element added event to all registered listeners.
private  void fireInternalElementRemovedEvent(InternalConflictSetEvent e)
          Dispatch an internal element removed event to all registered listeners.
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, registerNatives, toString, wait, wait, wait
 

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:
element - 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:
element - the element that has been removed from this conflict set.

fireInternalElementAddedEvent

private void fireInternalElementAddedEvent(InternalConflictSetEvent e)
Dispatch an internal element added event to all registered listeners.

fireInternalElementRemovedEvent

private void fireInternalElementRemovedEvent(InternalConflictSetEvent e)
Dispatch an internal element removed event to all registered listeners.

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