BlockFor (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs.optional.testing, class: BlockFor

# Class BlockFor

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.taskdefs.condition.ConditionBase
org.apache.tools.ant.taskdefs.WaitFor
org.apache.tools.ant.taskdefs.optional.testing.BlockFor

All Implemented Interfaces:
  `Cloneable`

public class BlockFor extends WaitFor

Since:
  Ant 1.8

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class WaitFor

  `WaitFor.Unit`
  Modifier and Type
  Class
  Description
  `static class`
  `WaitFor.Unit`
  The enumeration of units: millisecond, second, minute, hour, day, week

- ## Field Summary

  ### Fields inherited from class WaitFor

  `DEFAULT_CHECK_MILLIS, DEFAULT_MAX_WAIT_MILLIS, ONE_DAY, ONE_HOUR, ONE_MILLISECOND, ONE_MINUTE, ONE_SECOND, ONE_WEEK`
  Modifier and Type
  Field
  Description
  `static final long`
  `DEFAULT_CHECK_MILLIS`
  default check time
  `static final long`
  `DEFAULT_MAX_WAIT_MILLIS`
  default wait time
  `static final long`
  `ONE_DAY`
  a day in milliseconds
  `static final long`
  `ONE_HOUR`
  an hour in milliseconds
  `static final long`
  `ONE_MILLISECOND`
  a millisecond
  `static final long`
  `ONE_MINUTE`
  a minute in milliseconds
  `static final long`
  `ONE_SECOND`
  a second in milliseconds
  `static final long`
  `ONE_WEEK`
  a week in milliseconds

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BlockFor()`
  Constructor that takes the name of the task in the task name.
  `BlockFor(String taskName)`
  Constructor that takes the name of the task in the task name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addText(String message)`
  Set the error text; all properties are expanded in the message.
  `protected void`
  `processTimeout()`
  If the wait fails, a BuildException is thrown.

  ### Methods inherited from class WaitFor

  `calculateCheckEveryMillis, calculateMaxWaitMillis, execute, processSuccess, setCheckEvery, setCheckEveryUnit, setMaxWait, setMaxWaitUnit, setTimeoutProperty`
  Modifier and Type
  Method
  Description
  `long`
  `calculateCheckEveryMillis()`
  Get the check wait time, in milliseconds.
  `long`
  `calculateMaxWaitMillis()`
  Get the maximum wait time, in milliseconds.
  `void`
  `execute()`
  Check repeatedly for the specified conditions until they become true or the timeout expires.
  `protected void`
  `processSuccess()`
  Actions to be taken on a successful waitfor.
  `void`
  `setCheckEvery(long time)`
  Set the time between each check
  `void`
  `setCheckEveryUnit(WaitFor.Unit unit)`
  Set the check every time unit
  `void`
  `setMaxWait(long time)`
  Set the maximum length of time to wait.
  `void`
  `setMaxWaitUnit(WaitFor.Unit unit)`
  Set the max wait time unit
  `void`
  `setTimeoutProperty(String p)`
  Name the property to set after a timeout.

  ### Methods inherited from class ConditionBase

  `add, addAnd, addAvailable, addChecksum, addContains, addEquals, addFilesMatch, addHttp, addIsFalse, addIsFileSelected, addIsReference, addIsSet, addIsTrue, addNot, addOr, addOs, addSocket, addUptodate, countConditions, getConditions, getTaskName, setTaskName`
  Modifier and Type
  Method
  Description
  `void`
  `add(Condition c)`
  Add an arbitrary condition
  `void`
  `addAnd(And a)`
  Add an <and> condition "container".
  `void`
  `addAvailable(Available a)`
  Add an <available> condition.
  `void`
  `addChecksum(Checksum c)`
  Add an <checksum> condition.
  `void`
  `addContains(Contains test)`
  Add a <contains> condition.
  `void`
  `addEquals(Equals e)`
  Add an <equals> condition.
  `void`
  `addFilesMatch(FilesMatch test)`
  Add a <filesmatch> condition.
  `void`
  `addHttp(Http h)`
  Add an <http> condition.
  `void`
  `addIsFalse(IsFalse test)`
  Add a <isfalse> condition.
  `void`
  `addIsFileSelected(IsFileSelected test)`
  Add an <isfileselected> condition.
  `void`
  `addIsReference(IsReference i)`
  Add an <isreference> condition.
  `void`
  `addIsSet(IsSet i)`
  Add an <isset> condition.
  `void`
  `addIsTrue(IsTrue test)`
  Add a <istrue> condition.
  `void`
  `addNot(Not n)`
  Add an <not> condition "container".
  `void`
  `addOr(Or o)`
  Add an <or> condition "container".
  `void`
  `addOs(Os o)`
  Add an <os> condition.
  `void`
  `addSocket(Socket s)`
  Add a <socket> condition.
  `void`
  `addUptodate(UpToDate u)`
  Add an <uptodate> condition.
  `protected int`
  `countConditions()`
  Count the conditions.
  `protected final Enumeration<Condition>`
  `getConditions()`
  Iterate through all conditions.
  `String`
  `getTaskName()`
  Returns the name to use in logging messages.
  `void`
  `setTaskName(String name)`
  Sets the name to use in logging messages.

  ### Methods inherited from class ProjectComponent

  `clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject`
  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.
  `void`
  `setProject(Project project)`
  Sets the project object of this component.

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BlockFor

    public BlockFor()
    Constructor that takes the name of the task in the task name.

  - ### BlockFor

    public BlockFor(String taskName)
    Constructor that takes the name of the task in the task name.
    Parameters:
      `taskName` - the name of the task.

- ## Method Details

  - ### processTimeout

    protected void processTimeout() throws BuildTimeoutException
    If the wait fails, a BuildException is thrown. All the superclasses actions are called first.
    Overrides:
      `processTimeout` in class `WaitFor`
    Throws:
      `BuildTimeoutException` - on timeout, using the text in `text`

  - ### addText

    public void addText(String message)
    Set the error text; all properties are expanded in the message.
    Parameters:
      `message` - the text to use in a failure message