phing-tasks-system
[ class tree: phing-tasks-system ] [ index: phing-tasks-system ] [ all elements ]

Class: IfTask

Source Location: /tasks/system/IfTask.php

Class Overview

ProjectComponent
   |
   --ConditionBase
      |
      --IfTask

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


Author(s):

Version:

  • $Revision: 557 $

Copyright:

  • © 2001,2002 THYRELL. All rights reserved

Methods


Inherited Variables

Inherited Methods


Class Details

[line 110]
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

  1. <condition&gt;
task (see <a href="http://jakarta.apache.org/ant/manual/CoreTasks/condition.html">the online documentation</a> for example) for a complete list of nested elements.

Just like the

  1. <condition&gt;
task, only a single condition can be specified - you combine them using
  1. <and&gt;
or
  1. <or&gt;
conditions.

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

  1. <elseif&gt;
,
  1. <then&gt;
and
  1. <else&gt;
. All three subelements are optional. Both
  1. <then&gt;
and
  1. <else&gt;
must not be used more than once inside the if task. Both are containers for Ant tasks, just like Ant's
  1. <parallel&gt;
and
  1. <sequential&gt;
tasks - in fact they are implemented using the same class as Ant's
  1. <sequential&gt;
task.

The

  1. <elseif&gt;
behaves exactly like an
  1. <if&gt;
except that it cannot contain the
  1. <else&gt;
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
  1. <if&gt;
is false, then the first
  1. <elseif&gt;
who's conditional evaluates to true will be executed. The
  1. <else&gt;
will be executed only if the
  1. <if&gt;
and all
  1. <elseif&gt;
conditions are false. Use the following task to define the
  1. <if&gt;
task before you use it the first time:


   <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
 
<h3>Crude Example</h3>
  1.  <if>
  2.   <equals arg1="${foo}arg2="bar" />
  3.   <then>
  4.     <echo message="The value of property foo is bar" />
  5.   </then>
  6.   <else>
  7.     <echo message="The value of property foo is not bar" />
  8.   </else>
  9.  </if>
  1.  <if>
  2.   <equals arg1="${foo}arg2="bar" /&gt;
  3.   <then>
  4.    <echo message="The value of property foo is 'bar'" />
  5.   </then>
  6.  
  7.   <elseif>
  8.    <equals arg1="${foo}arg2="foo" />
  9.    <then>
  10.     <echo message="The value of property foo is 'foo'" />
  11.    </then>
  12.   </elseif>
  13.  
  14.   <else>
  15.    <echo message="The value of property foo is not 'foo' or 'bar'" />
  16.   </else>
  17.  </if>




Tags:

author:  <href="mailto:stefan.bodewig@freenet.de" a href="mailto:stefan.bodewig@freenet.de">Stefan Bodewig</a>
version:  $Revision: 557 $
copyright:  © 2001,2002 THYRELL. All rights reserved


[ Top ]


Class Methods


method addElse [line 144]

void addElse( SequentialTask $e)

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

Not required.




Tags:

access:  public


Parameters:

SequentialTask   $e  

[ Top ]

method addElseIf [line 120]

void addElseIf( $ei)

*

A nested Else if task




Tags:

access:  public


Parameters:

ElseIfTask   $ei  

[ Top ]

method addThen [line 131]

void addThen( SequentialTask $t)

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

Not required.




Tags:

access:  public


Parameters:

SequentialTask   $t  

[ Top ]

method main [line 151]

void main( )



Tags:

access:  public


[ Top ]


Documentation generated on Mon, 19 Oct 2009 10:51:03 +0200 by phpDocumentor 1.4.3