de.enough.polish.ant
Class ConditionalElement

java.lang.Object
  extended by de.enough.polish.ant.ConditionalElement
Direct Known Subclasses:
AttributesFilter, LogSetting, MidletSetting, Setting

public class ConditionalElement
extends Object

The base class for any nested element which can be conditional.

This class supports the attributes [if] and [unless]. When the if-attribute is specified, the corresponding property needs to be defined in ant's build.xml. When the unless-attribute is defined, the corresponding property must not be defined in the build.xml. Classes can check if the conditions of this element are met by calling isActive(). Nested elements which want to make use of other conditional nested element needs to have a reference to the ant-project. This can be done with the help of the create<nested-element-name> method.

The if- and unless-conditions can now also refer to complex terms and use J2ME Polish variables and symbols. This has to be supported specifically by the implementation, though - the implementation needs to call isActive( BooleanEvaluator ).

Copyright Enough Software 2004 - 2011

 history
        25-Feb-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Constructor Summary
ConditionalElement()
          Creates a new conditional element.
ConditionalElement(ConditionalElement parent)
           
 
Method Summary
 String getCondition()
           
 String getIf()
           
 String getUnless()
           
 boolean isActive(BooleanEvaluator evaluator)
          Checks if the conditions for this element are met.
 boolean isActive(BooleanEvaluator evaluator, org.apache.tools.ant.Project project)
          Checks if the conditions for this element are met.
 boolean isActive(Environment environment)
          Checks if the conditions for this element are met.
 boolean isActive(org.apache.tools.ant.Project project)
          Checks if this element should be used.
 void setIf(String ifExpr)
          Sets the ant-property which needs to be defined to allow the execution of this task.
 void setUnless(String unlessExpr)
          Sets the ant-property which must not be defined to allow the execution of this task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionalElement

public ConditionalElement()
Creates a new conditional element.


ConditionalElement

public ConditionalElement(ConditionalElement parent)
Method Detail

setIf

public void setIf(String ifExpr)
Sets the ant-property which needs to be defined to allow the execution of this task.

Parameters:
ifExpr - the ant-property which needs to be defined

setUnless

public void setUnless(String unlessExpr)
Sets the ant-property which must not be defined to allow the execution of this task.

Parameters:
unlessExpr - the ant-property which must not be defined

isActive

public boolean isActive(org.apache.tools.ant.Project project)
Checks if this element should be used.

Parameters:
project - The project to which this nested element belongs to.
Returns:
true when this element is valid

isActive

public boolean isActive(BooleanEvaluator evaluator,
                        org.apache.tools.ant.Project project)
Checks if the conditions for this element are met.

Parameters:
evaluator - the boolean evaluator with the settings for the current device
project - the Ant project into which this variable is embedded
Returns:
true when no condition has been specified or the specified conditions have been met.

isActive

public boolean isActive(Environment environment)
Checks if the conditions for this element are met.

Parameters:
environment - the environment settings
Returns:
true when no condition has been specified or the specified conditions have been met.

isActive

public boolean isActive(BooleanEvaluator evaluator)
Checks if the conditions for this element are met.

Parameters:
evaluator - the boolean evaluator with the settings for the current device
Returns:
true when no condition has been specified or the specified conditions have been met.

getIf

public String getIf()

getUnless

public String getUnless()

getCondition

public String getCondition()