ijgen.generator.util
Class GeneratorUtils

java.lang.Object
  extended by ijgen.generator.util.GeneratorUtils

public class GeneratorUtils
extends java.lang.Object

Author:
Detelin Zlatev Utility methods used internally by the generator.

Constructor Summary
GeneratorUtils()
           
 
Method Summary
static java.lang.String constructFilePath(ClassDefinition classDefinition, java.lang.String outputDirectoryName, java.lang.String layer, java.lang.String fileFilter, java.lang.String extension, boolean addPackagePath)
          Constructs a fully qualified path to a file.
static java.lang.String constructFilePath(java.lang.String outputDirectoryName, java.lang.String layer, java.lang.String fileFilter, java.lang.String extension, boolean addPackagePath)
          Calls constructFilePath without class definition parameter.
static java.lang.String constructPathFromClassPackage(ClassDefinition classDefinition)
          Gets a directory structure from package name.
static void ensureDirectoryStructure(java.lang.String path)
          Ensures that directory structure specified by the path parameter exists.
static void loadFilesRecursively(java.io.File directory, java.util.List<java.io.File> result)
          Loads all the files that are present in a directory, recursively.
static org.apache.velocity.app.VelocityEngine prepareVelocityEngine(java.lang.String templatesPath)
          Gets an instance of VelocityEngine for the specified directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneratorUtils

public GeneratorUtils()
Method Detail

prepareVelocityEngine

public static org.apache.velocity.app.VelocityEngine prepareVelocityEngine(java.lang.String templatesPath)
                                                                    throws java.lang.Exception
Gets an instance of VelocityEngine for the specified directory.

Parameters:
templatesPath - path containing templates
Returns:
velocity engine
Throws:
java.lang.Exception - is some problem during initialization of engine occurs

constructFilePath

public static java.lang.String constructFilePath(ClassDefinition classDefinition,
                                                 java.lang.String outputDirectoryName,
                                                 java.lang.String layer,
                                                 java.lang.String fileFilter,
                                                 java.lang.String extension,
                                                 boolean addPackagePath)
Constructs a fully qualified path to a file.

Parameters:
classDefinition - class definition object used for generating artifact that has to be written to file
outputDirectoryName - output directory where the artifacts has to be produced
layer - layer / template name
fileFilter - extension of the template
extension - extension of the generated artifact
addPackagePath - specifies whether the package has to be appended to the directory structure
Returns:
full path to the file

constructFilePath

public static java.lang.String constructFilePath(java.lang.String outputDirectoryName,
                                                 java.lang.String layer,
                                                 java.lang.String fileFilter,
                                                 java.lang.String extension,
                                                 boolean addPackagePath)
Calls constructFilePath without class definition parameter.

Parameters:
outputDirectoryName - output directory where the artifacts has to be produced
layer - layer / template name
fileFilter - extension of the template
extension - extension of the generated artifact
addPackagePath - specifies whether the package has to be appended to the directory structure
Returns:
full path to the file

constructPathFromClassPackage

public static java.lang.String constructPathFromClassPackage(ClassDefinition classDefinition)
Gets a directory structure from package name. Example: abc.def.ijh -> abc/def/ijh

Parameters:
classDefinition - class definition containing the package name
Returns:
path to the directory

ensureDirectoryStructure

public static void ensureDirectoryStructure(java.lang.String path)
Ensures that directory structure specified by the path parameter exists. This is done by walking recursively through the path elements and creates new directory if missing.

Parameters:
path - directory path

loadFilesRecursively

public static void loadFilesRecursively(java.io.File directory,
                                        java.util.List<java.io.File> result)
Loads all the files that are present in a directory, recursively.

Parameters:
directory - directory that has to be scanned
result - result list in which the files has to be accumulated


Copyright © 2010 Detelin Zlatev. All Rights Reserved.