Package jadex.rules.rulesystem
Class AbstractAgenda
- java.lang.Object
-
- jadex.rules.rulesystem.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 Summary
Fields Modifier and Type Field Description protected java.util.ListhistoryThe history of executed activations (if enabled).protected ActivationlastThe last activation.protected java.util.ListlistenersAgenda listeners (if any).protected intstateThe state.
-
Constructor Summary
Constructors Constructor Description AbstractAgenda()Create a new fifo agenda.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddActivation(Activation act)Add a new activation.voidaddAgendaListener(IAgendaListener listener)Add an agenda listener.voidfireRule()Fire one activated rule.abstract java.util.CollectiongetActivations()Get the current activations.java.util.ListgetHistory()Get the history.ActivationgetLastActivation()The last activation.abstract ActivationgetNextActivation()Get the next activation.intgetState()Get the state of the agenda.abstract booleanisEmpty()Test if the agenda is empty.booleanisHistoryEnabled()Get the history mode.protected voidnotifyListeners()Notify all listeners (if any).abstract voidremoveActivation(Activation act)Remove an activationvoidremoveAgendaListener(IAgendaListener listener)Remove an agenda listener.voidsetHistoryEnabled(boolean enabled)Set the history mode.abstract voidsetNextActivation(Activation next)Set the next activation.java.lang.StringtoString()Get the string representation.
-
-
-
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.
-
-
Method Detail
-
fireRule
public void fireRule()
Fire one activated rule.
-
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:
getActivationsin interfaceIAgenda- Returns:
- The activations.
-
isEmpty
public abstract boolean isEmpty()
Test if the agenda is empty.
-
getNextActivation
public abstract Activation getNextActivation()
Get the next activation.- Specified by:
getNextActivationin interfaceIAgenda- Returns:
- The next activation.
-
setNextActivation
public abstract void setNextActivation(Activation next)
Set the next activation.- Specified by:
setNextActivationin interfaceIAgenda
-
getState
public int getState()
Get the state of the agenda. Changes whenever the activation list changes.
-
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:
getLastActivationin interfaceIAgenda- 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:
isHistoryEnabledin interfaceIAgenda
-
setHistoryEnabled
public void setHistoryEnabled(boolean enabled)
Set the history mode.- Specified by:
setHistoryEnabledin interfaceIAgenda
-
getHistory
public java.util.List getHistory()
Get the history.- Specified by:
getHistoryin interfaceIAgenda- Returns:
- null, if history not enabled.
-
addAgendaListener
public void addAgendaListener(IAgendaListener listener)
Add an agenda listener.- Specified by:
addAgendaListenerin interfaceIAgenda- Parameters:
listener- The listener.
-
removeAgendaListener
public void removeAgendaListener(IAgendaListener listener)
Remove an agenda listener.- Specified by:
removeAgendaListenerin interfaceIAgenda- Parameters:
listener- The listener.
-
notifyListeners
protected void notifyListeners()
Notify all listeners (if any).
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string representation.
-
-