Enhydra 5.1 API

org.enhydra.tool.codegen
Class TemplateDrivenGenerator

java.lang.Object
  |
  +--org.enhydra.tool.codegen.TemplateDrivenGenerator
All Implemented Interfaces:
Constants, java.util.EventListener, Generator, TemplateListener
Direct Known Subclasses:
ProjectGenerator

public abstract class TemplateDrivenGenerator
extends java.lang.Object
implements Generator, TemplateListener, Constants

A partial implementation of the Generator interface that works with template files. The predefined generators are based on this class.


Field Summary
static java.util.ResourceBundle res
           
 
Fields inherited from interface org.enhydra.tool.codegen.Constants
CLIENT_SUFFIX, CONTENT_HTML, CONTENT_WML, DIR_AT_PACKAGE_DIR_AT, DIR_INPUT, DIR_LIB, DIR_MEDIA, DIR_OUTPUT, DIR_PRESENTATION, DIR_RESOURCES, DIR_SRC, DIR_TEMPLATE, DIR_TOOL, FILE_BUILD_XML, FILE_ENHYDRA_JAR, FILE_MAKEFILE, FILE_README_HTML, FILE_RUN_BAT_IN, FILE_RUN_IN, SYS_JAVA_VENDOR, SYS_JAVA_VERSION, SYS_USER_HOME, TAB4, TYPE_BAT, TYPE_CONF, TYPE_HTML, TYPE_IN, TYPE_JAVA, TYPE_MK, TYPE_TEMPLATE, TYPE_WML, TYPE_XML, XMLC_DEFAULT, XMLC_SUFFIX
 
Constructor Summary
TemplateDrivenGenerator()
           
 
Method Summary
abstract  TemplateFilter createCopyFilter(TemplateTool tool)
           
abstract  Replacement[] createReplacementsForDirectory(PathHandle path)
           
abstract  TemplateFilter createTemplateFilter(TemplateTool tool)
           
 java.io.File[] generate()
          Generate application files from a set of templates.
abstract  java.lang.String getDestination()
           
protected  java.lang.String[] getInputIncludes()
           
 OptionSet getOptionSet()
          Get generator option set
 java.util.Properties getProperties()
          Get properties used to customize CodeGen.
 ReplacementSet getReplacementSet()
          Get the replacement operations to run against the templates.
 Template getTemplateRoot()
          Get the location of the template files.
abstract  void initReplacementSet()
           
 boolean isEcho()
           
 boolean isOverwrite()
           
 boolean isSwing()
           
 void setEcho(boolean b)
           
 void setOptionSet(OptionSet set)
           
 void setOverwrite(boolean b)
           
 void setProperties(java.util.Properties p)
          Set CodeGen customization properties.
 void setReplacementSet(ReplacementSet replacementSet)
          Set the replacement operations to run against the templates.
 void setSwing(boolean b)
           
 void storeProperties()
          Method declaration
 java.lang.String toString()
          Use the display name for the string representation of this class so that a list model can map directly into generators.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.enhydra.tool.codegen.Generator
getAddinSteps, getCommandName, getDescription, getDisplayName, getShellSteps, getWizardPanels, getWizardTitle, setAddinSteps, setShellSteps
 
Methods inherited from interface org.enhydra.tool.common.event.TemplateListener
onTemplate
 

Field Detail

res

public static java.util.ResourceBundle res
Constructor Detail

TemplateDrivenGenerator

public TemplateDrivenGenerator()
Method Detail

createTemplateFilter

public abstract TemplateFilter createTemplateFilter(TemplateTool tool)
                                             throws GeneratorException
GeneratorException

createCopyFilter

public abstract TemplateFilter createCopyFilter(TemplateTool tool)
                                         throws GeneratorException
GeneratorException

getDestination

public abstract java.lang.String getDestination()
                                         throws GeneratorException
GeneratorException

initReplacementSet

public abstract void initReplacementSet()
                                 throws GeneratorException
GeneratorException

createReplacementsForDirectory

public abstract Replacement[] createReplacementsForDirectory(PathHandle path)
                                                      throws GeneratorException
GeneratorException

toString

public java.lang.String toString()
Use the display name for the string representation of this class so that a list model can map directly into generators.

Overrides:
toString in class java.lang.Object
Returns:
The display name.

getProperties

public java.util.Properties getProperties()
Get properties used to customize CodeGen. This may contain information on the template directory location and persisted generation options.

Specified by:
getProperties in interface Generator
Returns:
Properties passed from the CodeGen class.

setProperties

public void setProperties(java.util.Properties p)
                   throws GeneratorException
Set CodeGen customization properties. The CodeGen class calls this method after it instantiates a generator class.

Specified by:
setProperties in interface Generator
Parameters:
p - Properties passed from the CodeGen class.
GeneratorException

getTemplateRoot

public Template getTemplateRoot()
Get the location of the template files.


isOverwrite

public boolean isOverwrite()

setOverwrite

public void setOverwrite(boolean b)

isEcho

public boolean isEcho()
Specified by:
isEcho in interface Generator

setEcho

public void setEcho(boolean b)
Specified by:
setEcho in interface Generator

isSwing

public boolean isSwing()
Specified by:
isSwing in interface Generator

setSwing

public void setSwing(boolean b)
Specified by:
setSwing in interface Generator

getReplacementSet

public ReplacementSet getReplacementSet()
Get the replacement operations to run against the templates. If this is null or has a zero length, no replacements are performed during generate().


setReplacementSet

public void setReplacementSet(ReplacementSet replacementSet)
Set the replacement operations to run against the templates. If this is not called, called prior to generate(), no replacements are performed.


getOptionSet

public OptionSet getOptionSet()
Get generator option set

Specified by:
getOptionSet in interface Generator
Returns:
An option set that you can use to read and write generator options.

setOptionSet

public void setOptionSet(OptionSet set)

generate

public java.io.File[] generate()
                        throws GeneratorException
Generate application files from a set of templates. This implementation of the generate method uses the replacements array to perform a search and replace on generated file names as well as there contents.

Specified by:
generate in interface Generator
Returns:
An array of the files that were generated.
Throws:
GenerationException - Thrown if unable to generate all the files. Note that generation will fail if the template directory has not been set.
GeneratorException - Thrown if all the files could not be generated without error.

storeProperties

public void storeProperties()
Method declaration


getInputIncludes

protected java.lang.String[] getInputIncludes()

Enhydra 5.1 API