jadex.application.space.envsupport.environment
Class AbstractTask

java.lang.Object
  extended by jadex.commons.SimplePropertyObject
      extended by jadex.application.space.envsupport.environment.AbstractTask
All Implemented Interfaces:
IObjectTask, IPropertyObject

public abstract class AbstractTask
extends SimplePropertyObject
implements IObjectTask

Empty default implementation for object tasks.


Field Summary
protected  IBooleanCondition condition
          The task condition (optional).
protected  boolean finished
          The finished flag.
static String PROPERTY_CONDITION
          The task condition property.
 
Fields inherited from class jadex.commons.SimplePropertyObject
pcs, properties
 
Fields inherited from interface jadex.application.space.envsupport.environment.IObjectTask
PROPERTY_ID
 
Constructor Summary
AbstractTask()
           
 
Method Summary
 void execute(IEnvironmentSpace space, ISpaceObject obj, IVector1 progress)
          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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jadex.application.space.envsupport.environment.IObjectTask
execute
 
Methods inherited from interface jadex.commons.IPropertyObject
getProperty, getPropertyNames, hasProperty, setProperty
 

Field Detail

PROPERTY_CONDITION

public static final 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.

Constructor Detail

AbstractTask

public AbstractTask()
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 interface IObjectTask
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 interface IObjectTask
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,
                    IVector1 progress)
Executes the task. Handles exceptions. Subclasses should implement doExecute() instead.

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.

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 interface IObjectTask
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.


Copyright © 2010. All Rights Reserved.