Class AbstractTask
- java.lang.Object
-
- jadex.commons.SimplePropertyObject
-
- jadex.extension.envsupport.environment.AbstractTask
-
- All Implemented Interfaces:
IPropertyObject
,IObjectTask
- Direct Known Subclasses:
AnalyzeTargetTask
,AnalyzeTargetTask
,AnalyzeTargetTask
,ClearChemicalsTask
,ClearChemicalsTask
,DeliverPatientTask
,DeliverPatientTask
,ExtinguishFireTask
,ExtinguishFireTask
,LoadBatteryTask
,LoadOreTask
,LoadOreTask
,LoadOreTask
,Move3DTask
,MoveTask
,MoveTask
,MoveTask
,MoveTask
,MoveTask
,MoveTask
,ProduceOreTask
,ProduceOreTask
,ProduceOreTask
,Rotation3DTask
,RotationTask
,RotationTask
,RotationTask
,TreatVictimTask
,TreatVictimTask
public abstract class AbstractTask extends SimplePropertyObject implements IObjectTask
Empty default implementation for object tasks.
-
-
Field Summary
Fields Modifier and Type Field Description protected IBooleanCondition
condition
The task condition (optional).protected boolean
finished
The finished flag.static java.lang.String
PROPERTY_CONDITION
The task condition property.-
Fields inherited from class jadex.commons.SimplePropertyObject
pcs, properties
-
Fields inherited from interface jadex.extension.envsupport.environment.IObjectTask
PROPERTY_ID
-
-
Constructor Summary
Constructors Constructor Description AbstractTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(IEnvironmentSpace space, ISpaceObject obj, long progress, IClockService clock)
Executes the task.boolean
isFinished(IEnvironmentSpace space, ISpaceObject obj)
Check if a task is finished and should be removed.void
setFinished(IEnvironmentSpace space, ISpaceObject obj, boolean finished)
Indicate that the task is finished and should be removed.void
shutdown(ISpaceObject obj)
This method will be executed by the object before the task is removed from the execution queue.void
start(ISpaceObject obj)
This method will be executed by the object before the task gets added to the execution queue.-
Methods inherited from class jadex.commons.SimplePropertyObject
addPropertyChangeListener, getProperties, getProperty, getPropertyNames, hasProperty, removePropertyChangeListener, setProperties, setProperty, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jadex.commons.IPropertyObject
getProperty, getPropertyNames, hasProperty, setProperty
-
-
-
-
Field Detail
-
PROPERTY_CONDITION
public static final java.lang.String PROPERTY_CONDITION
The task condition property.- See Also:
- Constant Field Values
-
finished
protected boolean finished
The finished flag.
-
condition
protected IBooleanCondition condition
The task condition (optional). Task is executed as long as the condition is true.
-
-
Method Detail
-
start
public void start(ISpaceObject obj)
This method will be executed by the object before the task gets added to the execution queue. Empty default implementation that can be replaced by subclasses.- Specified by:
start
in interfaceIObjectTask
- Parameters:
space
- The environment in which the task is executing.obj
- The object that is executing the task.
-
shutdown
public void shutdown(ISpaceObject obj)
This method will be executed by the object before the task is removed from the execution queue. Notifies the listener and hence should be called when overridden in subclasses.- Specified by:
shutdown
in interfaceIObjectTask
- Parameters:
space
- The environment in which the task is executing.obj
- The object that is executing the task.
-
execute
public void execute(IEnvironmentSpace space, ISpaceObject obj, long progress, IClockService clock)
Executes the task.- Specified by:
execute
in interfaceIObjectTask
- Parameters:
space
- The environment in which the task is executing.obj
- The object that is executing the task.progress
- The time that has passed according to the environment executor.clock
- The clock service.
-
isFinished
public boolean isFinished(IEnvironmentSpace space, ISpaceObject obj)
Check if a task is finished and should be removed. Finished tasks will no longer be executed.- Specified by:
isFinished
in interfaceIObjectTask
- Returns:
- True, if the task is finished.
-
setFinished
public void setFinished(IEnvironmentSpace space, ISpaceObject obj, boolean finished)
Indicate that the task is finished and should be removed.- Parameters:
space
- The environment in which the task is executing.obj
- The object that is executing the task.finished
- The finished flag.
-
-