ijgen.generator.util
Class TemplateUtils

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

public class TemplateUtils
extends java.lang.Object

Author:
Detelin Zlatev Class containing a bunch of convenient utility methods that are used by generator. By default an instance of this class is passed to velocity context and its methods are exposed in the velocity templates.

Method Summary
 java.lang.String capitalizeFieldName(java.lang.String fieldName)
          Capitalizes field name passed as a parameter.
 java.lang.String getCamelCaseFromClassName(java.lang.String className)
          Gets a class name in camel case style.
 java.lang.String getCamelCaseGetterName(java.lang.String fieldName)
          Gets a name of the getter based on the field name passed as an argument.
 java.lang.String getCamelCaseSetterName(java.lang.String fieldName)
          Gets a name of the setter based on the field name passed as an argument.
 java.lang.String getClassWithoutPackage(java.lang.String fullPath)
           
 java.lang.String getDbFieldName(java.lang.String fieldName)
          Gets a database column name from field name specified as a parameter.
static TemplateUtils getInstance()
          Factory method responsible for providing an instance of class TemplateUtils.
 java.lang.String getJoinTableName(java.lang.String className, java.lang.String genericFieldName)
          Gets name of the join table based on the class name and the referenced field
 java.lang.String getRelationMappingString(FieldDefinition fieldDef, ClassDefinition classDefinition)
          Gets string for JPA annotation responsible for relation between the classDefinition and the relation info in fieldDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final TemplateUtils getInstance()
Factory method responsible for providing an instance of class TemplateUtils.

Returns:
TemplateUtils instance

getCamelCaseGetterName

public java.lang.String getCamelCaseGetterName(java.lang.String fieldName)
Gets a name of the getter based on the field name passed as an argument. Example: fieldName: fieldTest result: getFieldTest

Parameters:
fieldName - name for the field
Returns:
camel case style name for getter method for this name

getCamelCaseSetterName

public java.lang.String getCamelCaseSetterName(java.lang.String fieldName)
Gets a name of the setter based on the field name passed as an argument. Example: fieldName: fieldTest result: setFieldTest

Parameters:
fieldName - name for the field
Returns:
camel case style name for setter method for this name

getCamelCaseFromClassName

public java.lang.String getCamelCaseFromClassName(java.lang.String className)
Gets a class name in camel case style. Example: ClassNaame -> className

Parameters:
className - name of the class
Returns:
camel case of the class

getDbFieldName

public java.lang.String getDbFieldName(java.lang.String fieldName)
Gets a database column name from field name specified as a parameter. Example: fieldName -> field_name

Parameters:
fieldName - name for the field
Returns:
database field name

getRelationMappingString

public java.lang.String getRelationMappingString(FieldDefinition fieldDef,
                                                 ClassDefinition classDefinition)
Gets string for JPA annotation responsible for relation between the classDefinition and the relation info in fieldDef

Parameters:
fieldDef - field definition which holds the relation information
classDefinition - class definition that contains the fieldDef
Returns:
JPA annotation string representing the relation

getJoinTableName

public java.lang.String getJoinTableName(java.lang.String className,
                                         java.lang.String genericFieldName)
Gets name of the join table based on the class name and the referenced field

Parameters:
className -
genericFieldName -
Returns:

capitalizeFieldName

public java.lang.String capitalizeFieldName(java.lang.String fieldName)
Capitalizes field name passed as a parameter. Example: fieldName -> FieldName

Parameters:
fieldName - name of the field
Returns:
capitalized field name

getClassWithoutPackage

public java.lang.String getClassWithoutPackage(java.lang.String fullPath)
Parameters:
fullPath -
Returns:


Copyright © 2010 Detelin Zlatev. All Rights Reserved.