com.scooterframework.tools.common
Class GeneratorImpl

java.lang.Object
  extended by com.scooterframework.tools.common.GeneratorImpl
All Implemented Interfaces:
Generator
Direct Known Subclasses:
AbstractGenerator, ControllerApplicationGenerator, FileTransformerGenerator

public abstract class GeneratorImpl
extends java.lang.Object
implements Generator

The is the super class of all generator classes.


Field Summary
static java.lang.String DIRECTORY_NAME_SRC
           
static java.lang.String DIRECTORY_NAME_TEST
           
static java.lang.String FILE_EXTENSION_JAVA
           
static java.lang.String FILE_EXTENSION_JSP
           
static java.lang.String FILE_EXTENSION_PROPERTIES
           
static java.lang.String FILE_EXTENSION_YAML
           
static java.lang.String FUNCTIONAL_TEST
           
static java.lang.String linebreak
           
protected  java.lang.String templateFilePath
           
static java.lang.String UNIT_TEST
           
 
Fields inherited from interface com.scooterframework.tools.common.Generator
TEMPLATE_PARSER_Q, TEMPLATE_PARSER_ST, TEMPLATE_PARSER_TYPE
 
Constructor Summary
GeneratorImpl(java.util.Map<java.lang.String,java.lang.String> props)
           
GeneratorImpl(java.lang.String templateFilePath, java.util.Map<java.lang.String,java.lang.String> props)
           
 
Method Summary
static java.lang.String escape(java.lang.Object o)
           
 void generate()
          Generates code.
 void generate(boolean overwrite)
          Generates code with an option if to overwrite the existing code.
protected  void generate(java.lang.String templateContent, java.util.Map<java.lang.String,?> props, java.lang.String fullPathToOutputFile, boolean overwrite)
           
protected  void generate(java.lang.String templateContent, java.util.Map<java.lang.String,?> props, java.lang.String rootPath, java.lang.String relativePathToFile, java.lang.String outputFileName, boolean overwrite)
           
protected abstract  java.lang.String getOutputFileName()
           
protected  java.lang.String getProperty(java.lang.String key)
           
protected abstract  java.lang.String getRelativePathToOutputFile()
           
protected abstract  java.lang.String getRootPath()
           
protected  java.lang.String getTemplateContent()
           
protected  java.lang.String getTemplateFileContent(java.lang.String templateFilePath)
           
protected abstract  java.util.Map<java.lang.String,?> getTemplateProperties()
           
protected  boolean isEmpty(java.lang.String s)
           
protected  void log(java.lang.String s)
           
protected  java.lang.String[] processTemplateContent(java.lang.String templateContent, java.util.Map<java.lang.String,?> props)
           
protected  java.lang.String renderContent(java.lang.String originalContent, java.util.Map<java.lang.String,?> props)
           
protected  java.lang.String toString(java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_NAME_SRC

public static final java.lang.String DIRECTORY_NAME_SRC
See Also:
Constant Field Values

DIRECTORY_NAME_TEST

public static final java.lang.String DIRECTORY_NAME_TEST
See Also:
Constant Field Values

FILE_EXTENSION_JAVA

public static final java.lang.String FILE_EXTENSION_JAVA
See Also:
Constant Field Values

FILE_EXTENSION_JSP

public static final java.lang.String FILE_EXTENSION_JSP
See Also:
Constant Field Values

FILE_EXTENSION_PROPERTIES

public static final java.lang.String FILE_EXTENSION_PROPERTIES
See Also:
Constant Field Values

FILE_EXTENSION_YAML

public static final java.lang.String FILE_EXTENSION_YAML
See Also:
Constant Field Values

UNIT_TEST

public static final java.lang.String UNIT_TEST
See Also:
Constant Field Values

FUNCTIONAL_TEST

public static final java.lang.String FUNCTIONAL_TEST
See Also:
Constant Field Values

templateFilePath

protected java.lang.String templateFilePath

linebreak

public static final java.lang.String linebreak
Constructor Detail

GeneratorImpl

public GeneratorImpl(java.util.Map<java.lang.String,java.lang.String> props)

GeneratorImpl

public GeneratorImpl(java.lang.String templateFilePath,
                     java.util.Map<java.lang.String,java.lang.String> props)
Method Detail

getProperty

protected java.lang.String getProperty(java.lang.String key)

toString

protected java.lang.String toString(java.lang.Object o)

getTemplateFileContent

protected java.lang.String getTemplateFileContent(java.lang.String templateFilePath)

generate

public void generate()
Generates code. If the code is already generated, overwrite it.

Specified by:
generate in interface Generator

generate

public void generate(boolean overwrite)
Generates code with an option if to overwrite the existing code.

Specified by:
generate in interface Generator
Parameters:
overwrite -

getTemplateContent

protected java.lang.String getTemplateContent()

getTemplateProperties

protected abstract java.util.Map<java.lang.String,?> getTemplateProperties()

getRootPath

protected abstract java.lang.String getRootPath()

getRelativePathToOutputFile

protected abstract java.lang.String getRelativePathToOutputFile()

getOutputFileName

protected abstract java.lang.String getOutputFileName()

generate

protected void generate(java.lang.String templateContent,
                        java.util.Map<java.lang.String,?> props,
                        java.lang.String rootPath,
                        java.lang.String relativePathToFile,
                        java.lang.String outputFileName,
                        boolean overwrite)

generate

protected void generate(java.lang.String templateContent,
                        java.util.Map<java.lang.String,?> props,
                        java.lang.String fullPathToOutputFile,
                        boolean overwrite)

processTemplateContent

protected java.lang.String[] processTemplateContent(java.lang.String templateContent,
                                                    java.util.Map<java.lang.String,?> props)

renderContent

protected java.lang.String renderContent(java.lang.String originalContent,
                                         java.util.Map<java.lang.String,?> props)

log

protected void log(java.lang.String s)

isEmpty

protected boolean isEmpty(java.lang.String s)

escape

public static java.lang.String escape(java.lang.Object o)