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.List
history
The history of executed activations (if enabled).protected Activation
last
The last activation.protected java.util.List
listeners
Agenda listeners (if any).protected int
state
The 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 void
addActivation(Activation act)
Add a new activation.void
addAgendaListener(IAgendaListener listener)
Add an agenda listener.void
fireRule()
Fire one activated rule.abstract java.util.Collection
getActivations()
Get the current activations.java.util.List
getHistory()
Get the history.Activation
getLastActivation()
The last activation.abstract Activation
getNextActivation()
Get the next activation.int
getState()
Get the state of the agenda.abstract boolean
isEmpty()
Test if the agenda is empty.boolean
isHistoryEnabled()
Get the history mode.protected void
notifyListeners()
Notify all listeners (if any).abstract void
removeActivation(Activation act)
Remove an activationvoid
removeAgendaListener(IAgendaListener listener)
Remove an agenda listener.void
setHistoryEnabled(boolean enabled)
Set the history mode.abstract void
setNextActivation(Activation next)
Set the next activation.java.lang.String
toString()
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:
getActivations
in 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:
getNextActivation
in interfaceIAgenda
- Returns:
- The next activation.
-
setNextActivation
public abstract void setNextActivation(Activation next)
Set the next activation.- Specified by:
setNextActivation
in 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:
getLastActivation
in 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:
isHistoryEnabled
in interfaceIAgenda
-
setHistoryEnabled
public void setHistoryEnabled(boolean enabled)
Set the history mode.- Specified by:
setHistoryEnabled
in interfaceIAgenda
-
getHistory
public java.util.List getHistory()
Get the history.- Specified by:
getHistory
in interfaceIAgenda
- Returns:
- null, if history not enabled.
-
addAgendaListener
public void addAgendaListener(IAgendaListener listener)
Add an agenda listener.- Specified by:
addAgendaListener
in interfaceIAgenda
- Parameters:
listener
- The listener.
-
removeAgendaListener
public void removeAgendaListener(IAgendaListener listener)
Remove an agenda listener.- Specified by:
removeAgendaListener
in 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:
toString
in classjava.lang.Object
- Returns:
- The string representation.
-
-