terp - the ANT Tasks
v1.3.304

com.codemesh.terp.ant.devpartner
Class AbstractToolOption<T extends Tool>

java.lang.Object
  extended by com.codemesh.terp.ant.devpartner.AbstractToolOption<T>
All Implemented Interfaces:
ToolOption<T>
Direct Known Subclasses:
BatchFileOption, BooleanToolOption, ConfigFileOption, DirectoryToolOption, ExecutableOption, OutOption, XmlFileOption

public abstract class AbstractToolOption<T extends Tool>
extends java.lang.Object
implements ToolOption<T>

The base class for most concrete tool options.


Constructor Summary
AbstractToolOption()
           
 
Method Summary
protected  java.lang.String expand(java.lang.String str, java.lang.String propName, TerpContext ctx)
          A utility method that expands the given string in the given context.
protected  java.lang.String expand(java.lang.String str, TerpContext ctx)
          A utility method that expands teh given string in the given context.
 java.lang.String getIf()
          Returns the condition that must be satidifed to execute the implementing task.
 org.apache.tools.ant.Project getProject()
          Returns the ANT project this option belongs to.
 java.lang.String getUnless()
          Returns the condition that must not be satidifed to execute the implementing task.
protected  java.lang.String quoteIfNecessary(java.lang.String str)
          Quotes strings containing spaces, leaves other strings alone.
 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 setProject(org.apache.tools.ant.Project p)
          Maintains the project with the option.
 void setUnless(java.lang.String condition)
          Sets a condition that must not be satisfied to execute the implementing task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.codemesh.terp.ant.devpartner.ToolOption
addCommands, appliesTo
 

Constructor Detail

AbstractToolOption

public AbstractToolOption()
Method Detail

setProject

public void setProject(org.apache.tools.ant.Project p)
Maintains the project with the option. Called by the tool task.

Parameters:
p - the ANT project.

getProject

public org.apache.tools.ant.Project getProject()
Returns the ANT project this option belongs to.

Returns:
the owning ANT project.

getIf

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

Specified by:
getIf in interface ToolOption<T extends Tool>
Returns:
the boolean expression.

setIf

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

Specified by:
setIf in interface ToolOption<T extends Tool>
Parameters:
condition - a terp expression that must evaluate to a boolean value.

getUnless

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

Specified by:
getUnless in interface ToolOption<T extends Tool>
Returns:
the boolean expression.

setUnless

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

Specified by:
setUnless in interface ToolOption<T extends Tool>
Parameters:
condition - a terp expression that must evaluate to a boolean value.

satisfies

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

Specified by:
satisfies in interface ToolOption<T extends Tool>
Parameters:
ctx - the terp context in which the logical expressions are evaluated.
Returns:
true or false.

expand

protected java.lang.String expand(java.lang.String str,
                                  TerpContext ctx)
A utility method that expands teh given string in the given context.

Parameters:
str - the given string, interpreted as an embedded terp template string.
ctx - the context in which to evaluate the template string.
Returns:
the resulting string value.

expand

protected java.lang.String expand(java.lang.String str,
                                  java.lang.String propName,
                                  TerpContext ctx)
A utility method that expands the given string in the given context.

Parameters:
str - the given string, interpreted as an embedded terp template string.
propName - the property name for which we're performing this operation. The name is used to provide additional context if an error occurs during template expansion.
ctx - the context in which to evaluate the template string.
Returns:
the resulting string value.

quoteIfNecessary

protected java.lang.String quoteIfNecessary(java.lang.String str)
Quotes strings containing spaces, leaves other strings alone.

Parameters:
str - the input string.
Returns:
a potentially quoted string.

terp - the ANT Tasks
v1.3.304

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