Class AbstractAgenda

  • All Implemented Interfaces:
    IAgenda
    Direct Known Subclasses:
    FIFOAgenda, LIFOAgenda, PriorityAgenda

    public abstract class AbstractAgenda
    extends java.lang.Object
    implements IAgenda
    The agenda contains the activations and can use a conflict resolution strategy for deciding which activation to fire.
    • Field Detail

      • last

        protected Activation last
        The last activation. Represents the last rule that has been executed (or that is currently executing, if still running).
      • listeners

        protected java.util.List listeners
        Agenda listeners (if any).
      • history

        protected java.util.List history
        The history of executed activations (if enabled).
      • state

        protected int state
        The state.
    • Constructor Detail

      • AbstractAgenda

        public AbstractAgenda()
        Create a new fifo agenda.
        Parameters:
        state - The state.
    • Method Detail

      • fireRule

        public void fireRule()
        Fire one activated rule.
        Specified by:
        fireRule in interface IAgenda
      • addActivation

        public abstract void addActivation​(Activation act)
        Add a new activation.
        Parameters:
        act - The activation.
      • removeActivation

        public abstract void removeActivation​(Activation act)
        Remove an activation
        Parameters:
        act - The activation.
      • getActivations

        public abstract java.util.Collection getActivations()
        Get the current activations.
        Specified by:
        getActivations in interface IAgenda
        Returns:
        The activations.
      • isEmpty

        public abstract boolean isEmpty()
        Test if the agenda is empty.
        Specified by:
        isEmpty in interface IAgenda
        Returns:
        True if is empty.
      • getNextActivation

        public abstract Activation getNextActivation()
        Get the next activation.
        Specified by:
        getNextActivation in interface IAgenda
        Returns:
        The next activation.
      • getState

        public int getState()
        Get the state of the agenda. Changes whenever the activation list changes.
        Specified by:
        getState in interface IAgenda
      • getLastActivation

        public Activation getLastActivation()
        The last activation. Represents the last rule that has been executed (or that is currently executing, if still running).
        Specified by:
        getLastActivation in interface IAgenda
        Returns:
        null, when no rule has been executed or when fireRule has been called on an empty agenda.
      • isHistoryEnabled

        public boolean isHistoryEnabled()
        Get the history mode.
        Specified by:
        isHistoryEnabled in interface IAgenda
      • setHistoryEnabled

        public void setHistoryEnabled​(boolean enabled)
        Set the history mode.
        Specified by:
        setHistoryEnabled in interface IAgenda
      • getHistory

        public java.util.List getHistory()
        Get the history.
        Specified by:
        getHistory in interface IAgenda
        Returns:
        null, if history not enabled.
      • addAgendaListener

        public void addAgendaListener​(IAgendaListener listener)
        Add an agenda listener.
        Specified by:
        addAgendaListener in interface IAgenda
        Parameters:
        listener - The listener.
      • notifyListeners

        protected void notifyListeners()
        Notify all listeners (if any).
      • toString

        public java.lang.String toString()
        Get the string representation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation.