RbUtils 0.13

org.ktc.rbutils.rb
Class AbstractRbTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.ktc.rbutils.rb.AbstractRbTask
Direct Known Subclasses:
RbCheckerTask, RbGeneratorTask

public abstract class AbstractRbTask
extends Task

Abstract class for RbUtils ant tasks. Provides common options for check and generation. This includes logging system.

Since:
RbUtils 0.9.1
Version:
$Revision: 1.5 $
Author:
redfish

Nested Class Summary
static class AbstractRbTask.Log
          Logger for the rbUtils ant tasks.
static class AbstractRbTask.LoggerType
          Enumerated attribute for ant logger type.
 
Field Summary
protected  Locale displayLocale
          Locale for results display.
protected  String extension
          Extension of properties file.
protected  boolean failOnErrors
          Specifies whether the build will break if errors occur.
protected  String failureProperty
          The name of the property to set if errors occur.
protected  List fileSets
          Contains the filesets to process.
protected  int maxErrors
          The maximum number of errors that are tolerated before breaking the build or setting the failure property.
protected  MainProcessor processor
          Processor used by the task to do the job.
protected  File root
          Root directory used to find properties file.
protected  TaskType taskType
          The type of the Task.
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
AbstractRbTask()
          Instanciates a new AbstractRbTask.
 
Method Summary
 void addFileset(FileSet fileSet)
          Adds a set of files (nested fileset attribute).
 void addLogger(AbstractRbTask.Log logger)
          Adds an Ant Logger.
protected  void doJob()
          Launches the check.
protected  List getFiles()
          Scans all optional filesets to find files to check and returns the list of found files.
protected  List getLoggers()
          Returns the list of listeners set in this task.
protected  void handleErrors(int numErrors)
          Handles errors.
protected  void logTaskStarts()
          Display, via the ant loggers, that the task starts.
 void setDisplayLocale(String displayLocale)
          Sets the locale to be used to generate message used on logging.
 void setExtension(String extension)
          Sets the extension of the properties file used for the check.
 void setFailOnErrors(boolean failOnErrors)
          Tells this task whether to fail if errors occur during the check.
 void setFailureProperty(String failureProperty)
          Tells this task to set the named property to "true" when there is a violation.
 void setMaxErrors(int maxErrors)
          Sets the maximum number of errors allowed.
 void setRoot(File root)
          Sets the directory where the properties files will be searched for the check.
protected abstract  void specificTaskinitilization()
          Adds specific Initialization to the task.
 
Methods inherited from class org.apache.tools.ant.Task
execute, getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

displayLocale

protected Locale displayLocale
Locale for results display.


maxErrors

protected int maxErrors
The maximum number of errors that are tolerated before breaking the build or setting the failure property.


failOnErrors

protected boolean failOnErrors
Specifies whether the build will break if errors occur.


failureProperty

protected String failureProperty
The name of the property to set if errors occur.


fileSets

protected final List fileSets
Contains the filesets to process.


root

protected File root
Root directory used to find properties file.


extension

protected String extension
Extension of properties file.


processor

protected MainProcessor processor
Processor used by the task to do the job.


taskType

protected TaskType taskType
The type of the Task. This must be initialized by subclasses.

Constructor Detail

AbstractRbTask

public AbstractRbTask()
Instanciates a new AbstractRbTask.

Method Detail

doJob

protected void doJob()
Launches the check.


specificTaskinitilization

protected abstract void specificTaskinitilization()
                                           throws FileNotFoundException
Adds specific Initialization to the task. This let subclasses instanciate the processor and set processor properties .

Throws:
FileNotFoundException - if a file is not found on processor instanciation.

logTaskStarts

protected void logTaskStarts()
Display, via the ant loggers, that the task starts.


addLogger

public void addLogger(AbstractRbTask.Log logger)
Adds an Ant Logger.

Parameters:
logger - the ant logger to be added for logging.

getLoggers

protected List getLoggers()
                   throws IOException
Returns the list of listeners set in this task.

If no loggers are registered, creates a new DefaultLogger using the ant logging system and adds it to the returned list.

Returns:
the list of listeners.
Throws:
IOException - if an error occurs.

getFiles

protected List getFiles()
Scans all optional filesets to find files to check and returns the list of found files.

The list contains File objects.

Returns:
the list of files found with the filesets of the task.

handleErrors

protected void handleErrors(int numErrors)
Handles errors. This should be used after the underlying task execution.

If this number is greater than maxErrors, sets the failureProperty if asked and throws an BuildException if failOnErrors is sets to true.

Parameters:
numErrors - number of errors to be check against maxErrors.

setDisplayLocale

public void setDisplayLocale(String displayLocale)
Sets the locale to be used to generate message used on logging. TODO Javadoc - default?

The separator in the String argument must be LocaleUtils.LOCALE_SEPARATOR.

Parameters:
displayLocale - The locale to set.

setFailOnErrors

public void setFailOnErrors(boolean failOnErrors)
Tells this task whether to fail if errors occur during the check. Default to true.

Parameters:
failOnErrors - true to fail on errors; false otherwise.

setFailureProperty

public void setFailureProperty(String failureProperty)
Tells this task to set the named property to "true" when there is a violation.

Parameters:
failureProperty - the name of the property to set in the event of an failure.

setMaxErrors

public void setMaxErrors(int maxErrors)
Sets the maximum number of errors allowed. Default to 0.

Parameters:
maxErrors - the maximum number of errors allowed.

addFileset

public void addFileset(FileSet fileSet)
Adds a set of files (nested fileset attribute).

Parameters:
fileSet - the file set to add.

setRoot

public void setRoot(File root)
Sets the directory where the properties files will be searched for the check.

Parameters:
root - the root directory to set.

setExtension

public void setExtension(String extension)
Sets the extension of the properties file used for the check. Default is AbstractMainProcessor#DEFAULT_PROPERTIES_EXTENSION.

Parameters:
extension - the extension to set.

Back to the RbUtils Home Page

Copyright © 2005-2009 RbUtils Project. All Rights Reserved.