org.sf.codejen
Interface Template

All Known Implementing Classes:
DefaultTemplate, FreeMarkerTemplate, TemplateAdapter

public interface Template

Interface for template definition.

Author:
Shane Ng

Method Summary
 void addPostProcessor(TemplateProcessor processor)
          Adds the post processor of the source code.
 boolean apply(Object model)
          Applies the data model to the template.
 List<File> getGeneratedFileList()
          Gets a list of generated files for post processor to process.
 String getName()
          Gets the name of the template.
 boolean isUndoable()
          Indicates if undo is implemented.
 void setFileNameGenerator(FileNameGenerator generator)
          Sets the FileNameGenerator for generating file names for one-to-many code generation.
 void setModelExtractor(ModelExtractor extractor)
          Sets the ModelExtractor for one-to-many code generation.
 void undo()
          Undos the code generation. i.e.
 

Method Detail

getName

String getName()
Gets the name of the template.

Returns:
the name of the template.

apply

boolean apply(Object model)
              throws TemplateException
Applies the data model to the template.

Parameters:
model -
Returns:
false when nothing can be generated; otherwise true.
Throws:
TemplateException - if any error is encoutered during the code generation. Code Generator should use Throwable.getCause() to access the wrapped exception.

addPostProcessor

void addPostProcessor(TemplateProcessor processor)
Adds the post processor of the source code.

Parameters:
processor - processing the output.

setModelExtractor

void setModelExtractor(ModelExtractor extractor)
Sets the ModelExtractor for one-to-many code generation.

Parameters:
extractor - extractor to extract the model.

setFileNameGenerator

void setFileNameGenerator(FileNameGenerator generator)
Sets the FileNameGenerator for generating file names for one-to-many code generation.

Parameters:
generator - the file name generator.

undo

void undo()
Undos the code generation. i.e. Delete the generated files.


isUndoable

boolean isUndoable()
Indicates if undo is implemented.

Returns:
true if the template is undoable; false, otherwise.

getGeneratedFileList

List<File> getGeneratedFileList()
Gets a list of generated files for post processor to process.

Returns:
a list of generated files.