net.sf.antcontrib.logic

Class Switch


public class Switch
extends Task

Task definition for the ANT task to switch on a particular value.

 Usage:

   Task declaration in the project:
   
     <taskdef name="switch" classname="net.sf.antcontrib.logic.Switch" />
   

   Task calling syntax:
    
     <switch value="value" [caseinsensitive="true|false"] >
       <case value="val">
         <property name="propname" value="propvalue" /> |
         <antcall target="targetname" /> |
         any other tasks
       </case>
      [
       <default>
         <property name="propname" value="propvalue" /> |
         <antcall target="targetname" /> |
         any other tasks
       </default> 
      ]
     </switch>
    


   Attributes:
       value           -> The value to switch on
       caseinsensitive -> Should we do case insensitive comparisons?
                          (default is false)

   Subitems:
       case     --> An individual case to consider, if the value that
                    is being switched on matches to value attribute of
                    the case, then the nested tasks will be executed.
       default  --> The default case for when no match is found.

 
 Crude Example:

     
     <switch value="${foo}">
       <case value="bar">
         <echo message="The value of property foo is bar" />
       </case>
       <case value="baz">
         <echo message="The value of property foo is baz" />
       </case>
       <default>
         <echo message="The value of property foo is not sensible" />
       </default>
     </switch>
     

 
Authors:
Matthew Inger
Stefan Bodewig

Nested Class Summary

class
Switch.Case

Constructor Summary

Switch()
Default Constructor

Method Summary

void
addDefault(Sequential res)
Creates the <default> tag
Switch.Case
createCase()
Creates the <case> tag
void
execute()
void
setCaseInsensitive(boolean c)
void
setValue(String value)
Sets the value being switched on

Constructor Details

Switch

public Switch()
Default Constructor

Method Details

addDefault

public void addDefault(Sequential res)
            throws BuildException
Creates the <default> tag

createCase

public Switch.Case createCase()
            throws BuildException
Creates the <case> tag

execute

public void execute()
            throws BuildException

setCaseInsensitive

public void setCaseInsensitive(boolean c)

setValue

public void setValue(String value)
Sets the value being switched on