xdoclet

Class TemplateSubTask

public class TemplateSubTask extends SubTask

Generic subtask for processing a user-supplied template. The template is specified in the templateFile configuration parameter. It operates in two modes: per class and single output.

Version: $Revision: 1.79 $

Author: Ara Abrahamian (ara_e@email.com)

UNKNOWN: Sep 25, 2001 name = "template" parent = "xdoclet.DocletTask" display-name = "Standard Subtask" name = "destinationFile" description = "The destination file name. If a {0} is found it's assumed that a * per class output generation is needed, so {0} is substituted with class name; otherwise a single file is * generated with the specified name." required = "Yes" name = "extent" description = "You can control the extent in which the type search occurs. Valid values * are: concrete-type , superclass and hierarchy ." required = "No. Default is \"hierarchy\""

Nested Class Summary
static classTemplateSubTask.ExtentTypes
static classTemplateSubTask.OfType
Applicable only to per class output generation.
Constructor Summary
TemplateSubTask()
Method Summary
voidaddOfType(TemplateSubTask.OfType ofType)
protected voidaddOfType(String ofType)
voidaddPackageSubstitution(PackageTagsHandler.PackageSubstitution ps)
Substitutes the package of the generated files.
voidcopyAttributesFrom(TemplateSubTask src)
Describe what the method does
protected voidengineFinished()
Describe what the method does
protected voidengineStarted()
Describe what the method does
voidexecute()
Describe what the method does
protected voidgenerateForClass(XClass clazz)
Processed template for clazz and generates output file for clazz.
booleangetAcceptAbstractClasses()
booleangetAcceptInterfaces()
StringgetDestinationFile()
Gets the DestinationFile attribute of the TemplateSubTask object
TemplateEnginegetEngine()
Gets the Engine attribute of the TemplateSubTask object
StringgetExtent()
Gets the Extent attribute of the TemplateSubTask object
protected StringgetGeneratedFileName(XClass clazz)
Returns the filename of the generated file for a class.
GenerationManagergetGenerationManager()
StringgetHavingClassTag()
Gets the HavingClassTag attribute of the TemplateSubTask object
String[]getOfType()
Gets the OfType attribute of the TemplateSubTask object
ArrayListgetPackageSubstitutions()
Gets the PackageSubstitutions attribute of the TemplateSubTask object
StringgetSubTaskClassName()
Gets the SubTaskClassName attribute of the TemplateSubTask object
URLgetTemplateURL()
Gets the TemplateURL attribute of the TemplateSubTask object
voidinit(XJavaDoc xJavaDoc)
Describe what the method does
booleanisPackageSubstitutionInheritanceSupported()
By default supports, but some subtasks may not support because global packageSubstitution is for public interfaces/classes, not good for impl classes.
booleanisPrefixWithPackageStructure()
Gets the PrefixWithPackageStructure attribute of the TemplateSubTask object
protected static StringjavaFile(String className)
Converts the fully qualified class name to a valid path with File.separator characters instead of "." characters and class name postfixed by a ".java".
protected booleanmatchesGenerationRules(XClass clazz)
Returns true if output not already generated for clazz, and is of the specified type and has the specified class tag; false otherwise.
protected booleanprocessInnerClasses()
Subclasses should override this method and return true if they want startProcessPerClass() to process inner classes too.
voidsetAcceptAbstractClasses(boolean acceptAbstractClasses)
Indicates whether or not to generate for abstract classes.
voidsetAcceptInterfaces(boolean acceptInterfaces)
Indicates whether or not to generate for interfaces.
voidsetDestinationFile(String destinationFile)
The destination file name.
voidsetEngine(TemplateEngine engine)
Sets the Engine attribute of the TemplateSubTask object
voidsetExtent(TemplateSubTask.ExtentTypes extent)
You can control the extent in which the type search occurs.
protected voidsetExtentValue(String extent)
Sets the ExtentValue attribute of the TemplateSubTask object
protected voidsetGenerationManager(GenerationManager gM)
Sets the GenerationManager attribute of the TemplateSubTask object
voidsetHavingClassTag(String havingClassTag)
Sets the HavingClassTag attribute of the TemplateSubTask object
voidsetOfType(String ofType)
voidsetPackageSubstitutionInheritanceSupported(boolean packageSubstitutionInheritanceSupported)
Indicates whether or not package substitution should be inherited
voidsetPackageSubstitutions(ArrayList packageSubstitutions)
Sets the PackageSubstitutions attribute of the TemplateSubTask object
voidsetPrefixWithPackageStructure(boolean prefixWithPackageStructure)
Indicates whether or not to prefix with package structure.
voidsetSubTaskClassName(String subTaskClassName)
Sets the SubTaskClassName attribute of the TemplateSubTask object
voidsetTemplateFile(File templateFile)
Sets the name of the template file to use for generation
voidsetTemplateURL(URL templateURL)
This method should be called to set a template file programmatically.
protected voidstartEngine(URL templateURL, File outputFile)
Describe what the method does
protected voidstartProcess()
Describe what the method does
protected voidstartProcessForAll()
protected voidstartProcessPerClass()
voidvalidateOptions()
Called to validate configuration parameters.

Constructor Detail

TemplateSubTask

public TemplateSubTask()

Method Detail

addOfType

public void addOfType(TemplateSubTask.OfType ofType)

addOfType

protected void addOfType(String ofType)

addPackageSubstitution

public void addPackageSubstitution(PackageTagsHandler.PackageSubstitution ps)
Substitutes the package of the generated files.

Parameters: ps The feature to be added to the Fileset attribute

copyAttributesFrom

public void copyAttributesFrom(TemplateSubTask src)
Describe what the method does

Parameters: src Describe what the parameter does

engineFinished

protected void engineFinished()
Describe what the method does

Throws: TemplateException Describe the exception

engineStarted

protected void engineStarted()
Describe what the method does

Throws: XDocletException Describe the exception

execute

public void execute()
Describe what the method does

Throws: XDocletException Describe the exception

generateForClass

protected void generateForClass(XClass clazz)
Processed template for clazz and generates output file for clazz.

Parameters: clazz Description of Parameter

Throws: XDocletException Description of Exception

getAcceptAbstractClasses

public boolean getAcceptAbstractClasses()

getAcceptInterfaces

public boolean getAcceptInterfaces()

getDestinationFile

public String getDestinationFile()
Gets the DestinationFile attribute of the TemplateSubTask object

Returns: The DestinationFile value

getEngine

public TemplateEngine getEngine()
Gets the Engine attribute of the TemplateSubTask object

Returns: The Engine value

getExtent

public String getExtent()
Gets the Extent attribute of the TemplateSubTask object

Returns: The Extent value

getGeneratedFileName

protected String getGeneratedFileName(XClass clazz)
Returns the filename of the generated file for a class. If the string "{0}" is present in the pattern, it will be substituted with the transformed class name.

Parameters: clazz the class being processed

Returns: the corresponding filename

Throws: XDocletException Description of Exception

getGenerationManager

public GenerationManager getGenerationManager()

getHavingClassTag

public String getHavingClassTag()
Gets the HavingClassTag attribute of the TemplateSubTask object

Returns: The HavingClassTag value

getOfType

public String[] getOfType()
Gets the OfType attribute of the TemplateSubTask object

Returns: The OfType value

getPackageSubstitutions

public ArrayList getPackageSubstitutions()
Gets the PackageSubstitutions attribute of the TemplateSubTask object

Returns: The PackageSubstitutions value

getSubTaskClassName

public String getSubTaskClassName()
Gets the SubTaskClassName attribute of the TemplateSubTask object

Returns: The SubTaskClassName value

getTemplateURL

public URL getTemplateURL()
Gets the TemplateURL attribute of the TemplateSubTask object

Returns: The TemplateURL value

init

public void init(XJavaDoc xJavaDoc)
Describe what the method does

Parameters: xJavaDoc

Throws: XDocletException Describe the exception

isPackageSubstitutionInheritanceSupported

public boolean isPackageSubstitutionInheritanceSupported()
By default supports, but some subtasks may not support because global packageSubstitution is for public interfaces/classes, not good for impl classes.

Returns: true

isPrefixWithPackageStructure

public boolean isPrefixWithPackageStructure()
Gets the PrefixWithPackageStructure attribute of the TemplateSubTask object

Returns: The PrefixWithPackageStructure value

javaFile

protected static String javaFile(String className)
Converts the fully qualified class name to a valid path with File.separator characters instead of "." characters and class name postfixed by a ".java".

Parameters: className class name

Returns: file path

matchesGenerationRules

protected boolean matchesGenerationRules(XClass clazz)
Returns true if output not already generated for clazz, and is of the specified type and has the specified class tag; false otherwise. If returned false, no output file is generated for clazz.

Parameters: clazz Description of Parameter

Returns: Description of the Returned Value

Throws: XDocletException Description of Exception

processInnerClasses

protected boolean processInnerClasses()
Subclasses should override this method and return true if they want startProcessPerClass() to process inner classes too.

Returns:

setAcceptAbstractClasses

public void setAcceptAbstractClasses(boolean acceptAbstractClasses)
Indicates whether or not to generate for abstract classes.

Parameters: acceptAbstractClasses

UNKNOWN: "No, default is 'true'"

setAcceptInterfaces

public void setAcceptInterfaces(boolean acceptInterfaces)
Indicates whether or not to generate for interfaces.

Parameters: acceptInterfaces

UNKNOWN: "No, default is 'true'"

setDestinationFile

public void setDestinationFile(String destinationFile)
The destination file name. If a {0} is found it's assumed that a per class output generation is needed, so {0} is substituted with class name; otherwise a single file is generated with the specified name.

Parameters: destinationFile The new DestinationFile value

UNKNOWN: No,defaultis determinedbythis task.

setEngine

public void setEngine(TemplateEngine engine)
Sets the Engine attribute of the TemplateSubTask object

Parameters: engine The new Engine value

UNKNOWN:

setExtent

public void setExtent(TemplateSubTask.ExtentTypes extent)
You can control the extent in which the type search occurs. Valid values are: There's no distinction between a class and an interface.

Parameters: extent The new Extent value

UNKNOWN:

setExtentValue

protected void setExtentValue(String extent)
Sets the ExtentValue attribute of the TemplateSubTask object

Parameters: extent The new ExtentValue value

setGenerationManager

protected void setGenerationManager(GenerationManager gM)
Sets the GenerationManager attribute of the TemplateSubTask object

Parameters: gM The new GenerationManager value

setHavingClassTag

public void setHavingClassTag(String havingClassTag)
Sets the HavingClassTag attribute of the TemplateSubTask object

Parameters: havingClassTag The new HavingClassTag value

setOfType

public void setOfType(String ofType)

setPackageSubstitutionInheritanceSupported

public void setPackageSubstitutionInheritanceSupported(boolean packageSubstitutionInheritanceSupported)
Indicates whether or not package substitution should be inherited

Parameters: packageSubstitutionInheritanceSupported The new PackageSubstitutionInheritanceSupported value

UNKNOWN: "No, default is 'true'"

setPackageSubstitutions

public void setPackageSubstitutions(ArrayList packageSubstitutions)
Sets the PackageSubstitutions attribute of the TemplateSubTask object

Parameters: packageSubstitutions The new PackageSubstitutions value

setPrefixWithPackageStructure

public void setPrefixWithPackageStructure(boolean prefixWithPackageStructure)
Indicates whether or not to prefix with package structure.

Parameters: prefixWithPackageStructure The new PrefixWithPackageStructure value

UNKNOWN: "No, default is 'true'"

setSubTaskClassName

public void setSubTaskClassName(String subTaskClassName)
Sets the SubTaskClassName attribute of the TemplateSubTask object

Parameters: subTaskClassName The new SubTaskClassName value

UNKNOWN:

setTemplateFile

public void setTemplateFile(File templateFile)
Sets the name of the template file to use for generation

Parameters: templateFile the file name (real file!) of the template

Throws: XDocletException

UNKNOWN: No,defaultis determinedbythis task.

setTemplateURL

public void setTemplateURL(URL templateURL)
This method should be called to set a template file programmatically. The URL is typically obtained with a getClass().getResource( templateName )

Parameters: templateURL

UNKNOWN:

startEngine

protected final void startEngine(URL templateURL, File outputFile)
Describe what the method does

Parameters: templateURL Describe what the parameter does outputFile Describe what the parameter does

Throws: TemplateException Describe the exception

startProcess

protected void startProcess()
Describe what the method does

Throws: XDocletException Describe the exception

startProcessForAll

protected void startProcessForAll()

startProcessPerClass

protected void startProcessPerClass()

validateOptions

public void validateOptions()
Called to validate configuration parameters.

Throws: XDocletException Description of Exception