terp - the ANT Tasks
v1.3.304

com.codemesh.terp.ant.devpartner
Interface ToolOption<T extends Tool>

All Known Subinterfaces:
FileCreating<T>
All Known Implementing Classes:
AbstractToolOption, BatchFileOption, BooleanToolOption, ConfigFileOption, DirectoryToolOption, ExecutableOption, OutOption, SimpleToolOption, WorkingDirOption, XmlFileOption

public interface ToolOption<T extends Tool>

The interface implemented by all tool options. We do not implement TerpAware because the option itself cannot decide whether it is enabled, it requires the cooperation of the tool to retrieve the project and context.

This interface is very similar to the TerpAware interface, but just different enough that we could not reuse it. TerpAware tasks are evaluated in a single, implicit context, the project context. Compiler options on the other hand are evaluated in a tool context that could change, for example due to a <foreach> iteration over several tools. This requires an additional argument for the satisfies(com.codemesh.terp.api.TerpContext) method.


Method Summary
 void addCommands(java.util.List<java.lang.String> commandList, T tool, ToolPhase phase)
          Adds the tool switches repreesnted by this option to the list of switches.
 boolean appliesTo(T tool, ToolPhase phase)
          Returns true if this tool option applies to the given tool and tool phase.
 java.lang.String getIf()
          Returns the condition that must be satidifed to execute the implementing task.
 java.lang.String getUnless()
          Returns the condition that must not be satidifed to execute the implementing task.
 boolean satisfies(TerpContext ctx)
          Returns true if both conditions are met within the given terp context.
 void setIf(java.lang.String condition)
          Sets a condition that must be satisfied to execute the implementing task.
 void setUnless(java.lang.String condition)
          Sets a condition that must not be satisfied to execute the implementing task.
 

Method Detail

appliesTo

boolean appliesTo(T tool,
                  ToolPhase phase)
Returns true if this tool option applies to the given tool and tool phase. Not every option has switches to contribute for every tool and every compilation phase. This method allows a quick, inexpensive check to filter out potentially more expensive calls later on.

Parameters:
tool - the tool for which we're asking.
phase - the tool phase we're executing.
Returns:

addCommands

void addCommands(java.util.List<java.lang.String> commandList,
                 T tool,
                 ToolPhase phase)
Adds the tool switches repreesnted by this option to the list of switches. Some tool options may result in more than one switch being added to a tool invocation. Other tool options may result in different options being added in different phases (compilation vs. linking) of the build.

This method is called by the tool repeatedly with different values for the tool phase to account for these possibilities.

Parameters:
commandList - the list to which the tool switches represented by this option (if any) are added.
tool - the tool for which we're doing this.
phase - the tool phase in wihch we're doing this.

setIf

void setIf(java.lang.String condition)
Sets a condition that must be satisfied to execute the implementing task.

Parameters:
condition - a terp expression that must evaluate to a boolean value.

getIf

java.lang.String getIf()
Returns the condition that must be satidifed to execute the implementing task.

Returns:
the boolean expression.

setUnless

void setUnless(java.lang.String condition)
Sets a condition that must not be satisfied to execute the implementing task.

Parameters:
condition - a terp expression that must evaluate to a boolean value.

getUnless

java.lang.String getUnless()
Returns the condition that must not be satidifed to execute the implementing task.

Returns:
the boolean expression.

satisfies

boolean satisfies(TerpContext ctx)
Returns true if both conditions are met within the given terp context.

Parameters:
ctx - the terp context in which the logical expressions are evaluated.
Returns:
true or false.

terp - the ANT Tasks
v1.3.304

Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.