net.chaosserver.bilbo.task.generate
Class GenerateTask

java.lang.Object
  |
  +--net.chaosserver.bilbo.task.BaseTask
        |
        +--net.chaosserver.bilbo.task.RecursiveTask
              |
              +--net.chaosserver.bilbo.task.RootFirstRecursiveTask
                    |
                    +--net.chaosserver.bilbo.task.generate.GenerateTask
All Implemented Interfaces:
Task

public class GenerateTask
extends RootFirstRecursiveTask

Generates mappings files.

Since:
Bilbo 2.0

Field Summary
protected  int errorLevel
          Holds the error response if an error is encountered.
protected  boolean full
          Holds the full flag.
protected  Collection mappings
          Holds the mapping names to generate for each file.
 
Fields inherited from class net.chaosserver.bilbo.task.BaseTask
settings
 
Constructor Summary
GenerateTask()
          Default constructor.
 
Method Summary
 void execute(File currentDirectoryFile)
          Iterators through each file in the directory and generates a mapping for each mapping passed in through the arguments.
protected  Directory generateDirectory(File currentDirectory)
          Generates a directory object for the directory given.
protected  FilenameMapping generateFilenameMapping(Directory directory, File currentFile)
          Generates a filemapping for the given file.
protected  int getErrorLevel()
          Getter for the error level
protected  boolean isFull()
          Getter for the full property.
protected  void parseFlags(String flags)
          Parses the flag portion of the task arguments.
protected  void parseMappingString(String mappingsString)
          Parses the mapping portion of the task arguments.
 void parseTaskArguments(String argumentString)
          Parses the argument string.
protected  void setErrorLevel(int errorLevel)
          Setter for the error level
protected  void setFull(boolean full)
          Setter for the full property.
protected  void writeMapping(File outputDirectory, Directory directory)
          Writes the mapping file out to the given directory.
 
Methods inherited from class net.chaosserver.bilbo.task.RootFirstRecursiveTask
executeRecursive
 
Methods inherited from class net.chaosserver.bilbo.task.RecursiveTask
executeSpecific, isRootDirectory
 
Methods inherited from class net.chaosserver.bilbo.task.BaseTask
execute, getHelpResource, getSettings, printHelp, setSettings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorLevel

protected int errorLevel
Holds the error response if an error is encountered.


full

protected boolean full
Holds the full flag.


mappings

protected Collection mappings
Holds the mapping names to generate for each file.

Constructor Detail

GenerateTask

public GenerateTask()
Default constructor.

Method Detail

setErrorLevel

protected void setErrorLevel(int errorLevel)
Setter for the error level

Parameters:
errorLevel - the error level

getErrorLevel

protected int getErrorLevel()
Getter for the error level

Returns:
the error level

setFull

protected void setFull(boolean full)
Setter for the full property.

Parameters:
full - the full property
See Also:
isFull()

isFull

protected boolean isFull()
Getter for the full property.

Returns:
the full property
See Also:
setFull(boolean)

parseTaskArguments

public void parseTaskArguments(String argumentString)
                        throws BadTaskCommandArgumentsException
Parses the argument string. This should look similar to [-e#][-f] mapping1 [mapping2 [mapping3 [...]]]

Specified by:
parseTaskArguments in interface Task
Overrides:
parseTaskArguments in class BaseTask
Parameters:
argumentString - the argument string to parse.
Throws:
BadTaskCommandArgumentsException - indicates a generic error

parseFlags

protected void parseFlags(String flags)
Parses the flag portion of the task arguments.

Parameters:
flags - the flag portion of the task arguments

parseMappingString

protected void parseMappingString(String mappingsString)
                           throws BadTaskCommandArgumentsException
Parses the mapping portion of the task arguments.

Parameters:
mappingsString - the mapping portion of the task arguments
Throws:
BadTaskCommandArgumentsException - if there is an error with the arguments provided

execute

public void execute(File currentDirectoryFile)
             throws GenerateException
Iterators through each file in the directory and generates a mapping for each mapping passed in through the arguments.

Specified by:
execute in class RecursiveTask
Parameters:
currentDirectoryFile - the directory to process
Throws:
GenerateException - if there is an error generating

generateDirectory

protected Directory generateDirectory(File currentDirectory)
                               throws GenerateException
Generates a directory object for the directory given.

Parameters:
currentDirectory - the directory to generate a Directory object for
Returns:
Directory object representation of the directory
Throws:
GenerateException - indicates a generic error

generateFilenameMapping

protected FilenameMapping generateFilenameMapping(Directory directory,
                                                  File currentFile)
                                           throws GenerateException
Generates a filemapping for the given file.

Parameters:
directory - the directory the file resides in. Needed in case of name conflicts
currentFile - the file to create mappings for
Returns:
the mapping for the given file
Throws:
GenerateException - indicates a generic error

writeMapping

protected void writeMapping(File outputDirectory,
                            Directory directory)
                     throws GenerateException
Writes the mapping file out to the given directory.

Parameters:
outputDirectory - the directory to write the mapping file to.
directory - directory to output
Throws:
GenerateException - indicates a generic error


Copyright © 20030415