| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tools.ant.TaskConfigurationChecker
public class TaskConfigurationChecker
Helper class for the check of the configuration of a given task. This class provides methods for making assumptions about the task configuration. After collecting all violations with assert* and fail methods the checkErrors will throw a BuildException with all collected messages or does nothing if there wasn't any error.
Example:
     public class MyTask extends Task {
         ...
         public void execute() {
             TaskConfigurationChecker checker = TaskConfigurationChecker(this);
             checker.assertConfig(
                 srcdir != null,
                 "Attribute 'srcdir' must be set.
             );
             checker.assertConfig(
                 srcdir.exists(),
                 "Srcdir (" + srcdir + ") must exist."
             );
             if (someComplexCondition()) {
                 fail("Complex condition failed.");
             }
             checker.checkErrors();
         }
     }
 
| Constructor Summary | |
|---|---|
| TaskConfigurationChecker(Task task)Constructor. | |
| Method Summary | |
|---|---|
|  void | assertConfig(boolean condition,
             java.lang.String errormessage)Asserts that a condition is true. | 
|  void | checkErrors()Checks if there are any collected errors and throws a BuildException with all messages if there was one or more. | 
|  void | fail(java.lang.String errormessage)Registers an error. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public TaskConfigurationChecker(Task task)
task - which task should be checked| Method Detail | 
|---|
public void assertConfig(boolean condition,
                         java.lang.String errormessage)
condition - which condition to checkerrormessage - errormessage to throw if a condition failedpublic void fail(java.lang.String errormessage)
errormessage - the message for the registered error
public void checkErrors()
                 throws BuildException
BuildException - if one or more errors were registered| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||