Class IfTask

  • All Implemented Interfaces:
    Breakable, java.lang.Cloneable, org.apache.tools.ant.TaskContainer

    public class IfTask
    extends org.apache.tools.ant.Task
    implements org.apache.tools.ant.TaskContainer, Breakable
    Similar to Java's 'if' keyword, verifies that a given property has a given value and executes embedded tasks if it does. Does nothing if the property value is not as expected or the property does not exist.

    Can hold other tasks including IfTask, in particular, an ElseTask and a Break.

    Since:
    Ant 1.5
    • Field Summary

      • Fields inherited from class org.apache.tools.ant.Task

        target, taskName, taskType, wrapper
      • Fields inherited from class org.apache.tools.ant.ProjectComponent

        description, location, project
    • Constructor Summary

      Constructors 
      Constructor Description
      IfTask()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBool​(BooleanConditionTask boolTask)  
      void addBreak​(Break b)
      Required by Breakable.
      void addElse​(ElseTask elseTask)  
      void addTask​(org.apache.tools.ant.Task task)
      Add a nested task to execute.
      boolean doBreak()
      Required by Breakable.
      void execute()
      Execute this task and all nested Tasks, checking for Breaks and Breakables.
      void init()
      Automatically define dependent tasks.
      void maybeConfigure()
      Override maybeConfigure in a way that leaves the nested tasks unconfigured until they get executed.
      void setBreak​(boolean b)
      Required by Breakable.
      void setExists​(java.lang.String exists)
      Set the 'exists' attribute.
      void setName​(java.lang.String name)
      Set the name of the property to test.
      void setValue​(java.lang.String value)
      Set the expected value of the property.
      • Methods inherited from class org.apache.tools.ant.Task

        bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
      • Methods inherited from class org.apache.tools.ant.ProjectComponent

        clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IfTask

        public IfTask()
    • Method Detail

      • init

        public void init()
        Automatically define dependent tasks.
        Overrides:
        init in class org.apache.tools.ant.Task
      • setName

        public void setName​(java.lang.String name)
        Set the name of the property to test. Required unless nested condition is used.
        Parameters:
        name - the name of the property to test.
      • setValue

        public void setValue​(java.lang.String value)
        Set the expected value of the property. Implies 'exists'. execute method throws BuildException if the actual value is not the same as this value. Optional.
        Parameters:
        value - the expected value of the property.
      • setExists

        public void setExists​(java.lang.String exists)
        Set the 'exists' attribute. If true, throws BuildException if the property does not exist. Optional, default is true.
        Parameters:
        exists - Ant boolean, whether the value must exist.
      • setBreak

        public void setBreak​(boolean b)
        Required by Breakable.
        Specified by:
        setBreak in interface Breakable
        Parameters:
        b - The new break value
      • addBreak

        public void addBreak​(Break b)
        Required by Breakable.
        Specified by:
        addBreak in interface Breakable
        Parameters:
        b - The feature to be added to the Break attribute
      • addElse

        public void addElse​(ElseTask elseTask)
      • doBreak

        public boolean doBreak()
        Required by Breakable.
        Specified by:
        doBreak in interface Breakable
        Returns:
        Description of the Return Value
      • maybeConfigure

        public void maybeConfigure()
                            throws org.apache.tools.ant.BuildException
        Override maybeConfigure in a way that leaves the nested tasks unconfigured until they get executed.
        Overrides:
        maybeConfigure in class org.apache.tools.ant.Task
        Throws:
        org.apache.tools.ant.BuildException - Description of the Exception
        Since:
        Ant 1.5
      • addTask

        public void addTask​(org.apache.tools.ant.Task task)
        Add a nested task to execute.

        Specified by:
        addTask in interface org.apache.tools.ant.TaskContainer
        Parameters:
        task - Nested task to execute.

      • execute

        public void execute()
                     throws org.apache.tools.ant.BuildException
        Execute this task and all nested Tasks, checking for Breaks and Breakables.
        Overrides:
        execute in class org.apache.tools.ant.Task
        Throws:
        org.apache.tools.ant.BuildException - Description of the Exception