terp - the ANT Tasks
v1.3.304

com.codemesh.terp.ant.codegen
Class AbstractCodeGeneratorOption

java.lang.Object
  extended by com.codemesh.terp.ant.codegen.AbstractCodeGeneratorOption
All Implemented Interfaces:
CodeGeneratorOption, TerpAware, TerpContextHolder
Direct Known Subclasses:
CommandOption, ModelFileOption, ModelProperty

public abstract class AbstractCodeGeneratorOption
extends java.lang.Object
implements CodeGeneratorOption

The base class for code generator options.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.codemesh.terp.ant.TerpAware
TerpAware.Delegate
 
Constructor Summary
protected AbstractCodeGeneratorOption()
           
protected AbstractCodeGeneratorOption(org.apache.tools.ant.Project p)
           
 
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.
 TerpContext getContext()
          Returns the context maintained by this instance.
 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 satisfiesConditions()
          Returns true if both conditions are met.
 void setContext(TerpContext ctx)
          Sets the context maintained by this instance.
 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.codegen.CodeGeneratorOption
addToArguments
 

Constructor Detail

AbstractCodeGeneratorOption

protected AbstractCodeGeneratorOption()

AbstractCodeGeneratorOption

protected AbstractCodeGeneratorOption(org.apache.tools.ant.Project p)
Method Detail

setProject

public void setProject(org.apache.tools.ant.Project p)
Maintains the project with the option. Called by the compiler 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 TerpAware
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 TerpAware
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 TerpAware
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 TerpAware
Parameters:
condition - a terp expression that must evaluate to a boolean value.

satisfiesConditions

public boolean satisfiesConditions()
Returns true if both conditions are met.

Specified by:
satisfiesConditions in interface TerpAware
Returns:
true or false.

setContext

public void setContext(TerpContext ctx)
Sets the context maintained by this instance.

Specified by:
setContext in interface TerpContextHolder
Parameters:
ctx - the execution context.

getContext

public TerpContext getContext()
Returns the context maintained by this instance.

Specified by:
getContext in interface TerpContextHolder
Returns:
an execution context.

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.