com.taursys.tools
Class CodeGenerator

java.lang.Object
  extended bycom.taursys.tools.CodeGenerator

public class CodeGenerator
extends java.lang.Object

CodeGenerator is a singleton which generates code using Velocity

Version:
1.0
Author:
Marty Phelan

Field Summary
static java.lang.String TEMPLATES_PATH
           
 
Method Summary
 void generateCode(java.lang.String templateName, org.apache.velocity.context.Context context, java.lang.String srcPath, java.lang.String packageName, java.lang.String className)
          Generates the source code using the Velocity Engine and the template
static CodeGenerator getInstance()
          Gets the singleton instance of the CodeGenerator.
 void initialize()
          Initializes the CodeGenerator engine if not already initialized Initializes the internal VelocityEngine with this CodeGenerator's properties.
 void setProperties(java.util.Properties properties)
          Sets all properties used by this CodeGenerator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEMPLATES_PATH

public static final java.lang.String TEMPLATES_PATH
See Also:
Constant Field Values
Method Detail

setProperties

public void setProperties(java.util.Properties properties)
Sets all properties used by this CodeGenerator


getInstance

public static CodeGenerator getInstance()
Gets the singleton instance of the CodeGenerator.

Returns:
a singleton CodeGenerator

initialize

public void initialize()
                throws java.lang.Exception
Initializes the CodeGenerator engine if not already initialized Initializes the internal VelocityEngine with this CodeGenerator's properties. All the properties have default values. This method will simply return if this CodeGenerator is already initialized.

Throws:
java.lang.Exception - if problem initializing the engine

generateCode

public void generateCode(java.lang.String templateName,
                         org.apache.velocity.context.Context context,
                         java.lang.String srcPath,
                         java.lang.String packageName,
                         java.lang.String className)
                  throws java.lang.Exception
Generates the source code using the Velocity Engine and the template

Parameters:
templateName - to produce Java code
context - which contains data to merge into template
srcPath - is path where source should be stored
packageName - is java package name which whill be appended to srcPath
className - is java class name and file name
Throws:
java.lang.Exception - if problem creating file or running template


Copyright © 2007 Martin T Phelan. All Rights Reserved.