com.chaosserver.bilbo.task
Class BaseTask

java.lang.Object
  |
  +--com.chaosserver.bilbo.task.BaseTask
All Implemented Interfaces:
Task
Direct Known Subclasses:
BackAgainTask, CleanTask, ConvertTask, GenerateTask, ThereTask, ValidateTask

public abstract class BaseTask
extends Object
implements Task

Base task that provides the template design pattern for concrete implementations.

Since:
Bilbo 2.0

Field Summary
protected static String DEFAULT_HELP
          Holds the resource location of the default task help file.
protected  Settings settings
          Holds the settings object.
 
Constructor Summary
BaseTask()
           
 
Method Summary
 void execute()
          Executes this task against the rootDirectory provided in the settings object.
protected abstract  void execute(File currentDirectory)
          Executes this task against the given directory
protected  void executeRecursive(File currentDirectory)
          Executes this task against the given directory, then recursive against all subdirectories.
protected  String getHelpResource()
          Gets the help resource location.
protected  Settings getSettings()
          Getter for the settings object.
 void printHelp()
          Prints the usage notes out for the concrete task.
 void setSettings(Settings settings)
          Setter for the settings object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.chaosserver.bilbo.task.Task
parseTaskArguments
 

Field Detail

DEFAULT_HELP

protected static String DEFAULT_HELP
Holds the resource location of the default task help file.


settings

protected Settings settings
Holds the settings object.

Constructor Detail

BaseTask

public BaseTask()
Method Detail

setSettings

public void setSettings(Settings settings)
Setter for the settings object.

Specified by:
setSettings in interface Task
Parameters:
settings - the settings object

getSettings

protected Settings getSettings()
Getter for the settings object.

Returns:
the settings object

printHelp

public void printHelp()
               throws TaskException
Prints the usage notes out for the concrete task.

The concrete task should place it's usage notes in a file named help.txt inside its package. If no file is found, then the default usage notes will be displayed.

Throws:
TaskException - if there is an error printing the usage notes

execute

public void execute()
             throws TaskException
Executes this task against the rootDirectory provided in the settings object.

This task will at least be executed against the rootDirectory in the settings object. If the recursive flag is on, then it will also be executed against each subdirectory.

Specified by:
execute in interface Task
Throws:
TaskException - if something goes wrong

executeRecursive

protected void executeRecursive(File currentDirectory)
                         throws TaskException
Executes this task against the given directory, then recursive against all subdirectories.

Parameters:
currentDirectory - the directory to execute the task against
Throws:
TaskException - is something goes wrong

execute

protected abstract void execute(File currentDirectory)
                         throws TaskException
Executes this task against the given directory

Parameters:
currentDirectory - the directory to execute the task against
Throws:
TaskException - is something goes wrong

getHelpResource

protected String getHelpResource()
Gets the help resource location.

This appends "help.txt" to the package location.

Returns:
help resource location


Copyright © 20020228