Perform some tasks based on whether a given condition holds true or not.

This task is heavily based on the Condition framework that can be found in Ant 1.4 and later, therefore it cannot be used in conjunction with versions of Ant prior to 1.4.

This task doesn't have any attributes, the condition to test is specified by a nested element - see the documentation of your

    <condition>

task (see the online documentation for example) for a complete list of nested elements.

Just like the

    <condition>

task, only a single condition can be specified - you combine them using

    <and>

or

    <or>

conditions.

In addition to the condition, you can specify three different child elements,

    <elseif>

,

    <then>

and

    <else>

. All three subelements are optional. Both

    <then>

and

    <else>

must not be used more than once inside the if task. Both are containers for Ant tasks, just like Ant's

    <parallel>

and

    <sequential>

tasks - in fact they are implemented using the same class as Ant's

    <sequential>

task.

The

    <elseif>

behaves exactly like an

    <if>

except that it cannot contain the

    <else>

element inside of it. You may specify as may of these as you like, and the order they are specified is the order they are evaluated in. If the condition on the

    <if>

is false, then the first

    <elseif>

who's conditional evaluates to true will be executed. The

    <else>

will be executed only if the

    <if>

and all

    <elseif>

conditions are false.

Use the following task to define the

    <if>

task before you use it the first time:

      <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />

### Crude Example

    <if>

     <then>

     </then>
     <else>

     </else>
    </if>

    <if>

     </then>

     <elseif>

      <then>

      </then>
     </elseif>

     <else>

     </else>
    </if>

author | <a href="mailto:stefan.bodewig@freenet.de">Stefan Bodewig</a>
package | phing.tasks.system
version | $Id$

### Methods

## addAvailable()

    addAvailable(\AvailableTask $a) : void

Inherited

inherited_from | \ConditionBase::addAvailable()

### Parameters

#### $a

## A nested <else> element - a container of tasks that will be run if the condition doesn't hold true.

    addElse(\SequentialTask $e)

Not required.

### Parameters

#### $e

## addElseIf()

    addElseIf(\ElseIfTask $ei)

### Parameters

#### $ei

## A nested <then> element - a container of tasks that will be run if the condition holds true.

    addThen(\SequentialTask $t)

Not required.

### Parameters

#### $t

## countConditions()

    countConditions()

Inherited

inherited_from | \ConditionBase::countConditions()

## createAnd()

    createAnd() : \AndCondition

Inherited

inherited_from | \ConditionBase::createAnd()

### Returns

`\AndCondition`

## createContains()

    createContains() : \ContainsCondition

Inherited

inherited_from | \ConditionBase::createContains()

### Returns

`\ContainsCondition`

## createEquals()

    createEquals() : \EqualsCondition

Inherited

inherited_from | \ConditionBase::createEquals()

### Returns

`\EqualsCondition`

## createIsFalse()

    createIsFalse() : \IsFalseCondition

Inherited

inherited_from | \ConditionBase::createIsFalse()

### Returns

`\IsFalseCondition`

## createIsSet()

    createIsSet() : \IsSetCondition

Inherited

inherited_from | \ConditionBase::createIsSet()

### Returns

`\IsSetCondition`

## createIsTrue()

    createIsTrue() : \IsTrueCondition

Inherited

inherited_from | \ConditionBase::createIsTrue()

### Returns

`\IsTrueCondition`

## createNot()

    createNot() : \NotCondition

Inherited

inherited_from | \ConditionBase::createNot()

### Returns

`\NotCondition`

## createOr()

    createOr() : \OrCondition

Inherited

inherited_from | \ConditionBase::createOr()

### Returns

`\OrCondition`

## createOs()

    createOs() : \OsCondition

Inherited

inherited_from | \ConditionBase::createOs()

### Returns

`\OsCondition`

## createReferenceExists()

    createReferenceExists() : \ReferenceExistsCondition

Inherited

inherited_from | \ConditionBase::createReferenceExists()

### Returns

`\ReferenceExistsCondition`

## Creates the object for the child element

    customChildCreator(string $elementName, \Project $project) : \Condition

Inherited

inherited_from | \ConditionBase::customChildCreator()

### Parameters

#### $elementName

`string`

#### $project

`\Project`

### Exceptions

`\BuildException` |

### Returns

`\Condition`

## getConditions()

    getConditions()

Inherited

inherited_from | \ConditionBase::getConditions()

## Required for IteratorAggregate

    getIterator()

Inherited

inherited_from | \ConditionBase::getIterator()

## Returns a reference to current project

    getProject() : \Project

Inherited

inherited_from | \ProjectComponent::getProject()
inherited_from | \ConditionBase::getProject()

### Returns

`\Project`Reference to current porject object

## Logs a message with the given priority.

    log(string $msg, integer $level)

Inherited

inherited_from | \ProjectComponent::log()
inherited_from | \ConditionBase::log()

### Parameters

#### $msg

`string`

The message to be logged.

#### $level

`integer`

The message's priority at this message should have

## main()

    main()

## References the project to the current component.

    setProject(\Project $project)

Inherited

inherited_from | \ProjectComponent::setProject()
inherited_from | \ConditionBase::setProject()

### Parameters

#### $project

`\Project`

The reference to the current project

### Properties

##

    $conditions

Inherited

inherited_from | \ConditionBase::$$conditions

##

    $project : \Project

Inherited

inherited_from | \ProjectComponent::$$project
inherited_from | \ConditionBase::$$project

##

    $elseIfTasks

##

    $elseTasks

##

    $thenTasks