ch.sahits.codegen.util
Class ConvenientCodegen

java.lang.Object
  extended by ch.sahits.codegen.util.ConvenientCodegen

public final class ConvenientCodegen
extends java.lang.Object

This class provides convenient methods for the code generation to convert different parts of a model.

Since:
2.1.0
Author:
Andi Hotz

Constructor Summary
ConvenientCodegen()
           
 
Method Summary
static java.lang.String camelCase(java.lang.String s, java.lang.String delimiter)
          Camel-case a string that is divided by the designated delimiter
static java.lang.String camelCaseLowerCaseFirst(java.lang.String s, java.lang.String delimiter)
          Camale-case a string that is divided by the designated delimiter with a lower case start.
static java.lang.String getBoxingClassParsingMethodName(java.lang.Class type)
          Retrieve the method name of the boxing class
static java.lang.String getBoxingClassShortName(java.lang.Class type)
          Retrieve the short name of the boxing class
static java.lang.String getClassShortName(DataBaseTableField dbtf)
          Extract the class name from the class declaration
static java.lang.String getSimpleClassName(java.lang.Class c)
          Retrieve the simple representation of a class
static java.lang.String getSimpleClassName(java.lang.String c)
          Retrieve the simple representation of a class
static boolean isBoxingType(java.lang.Class type)
          Check whether the type is of a primitive type that needs boxing such as byte, boolean, double, float, int, long, short, char
static boolean isPrimitiveClass(java.lang.Class c)
          Check whether the class belongs to the java.lang package
static boolean isPrimitiveClass(java.lang.String c)
          Check whether the class belongs to the java.lang package
static boolean isPrimitiveType(DataBaseTableField dbtf)
          Check weather the type is a primitive type, meaning a type defined in the package java.lang
static java.lang.String toLowerCaseFirst(java.lang.String s)
          Make the first letter of a string lower case
static java.lang.String toName(java.lang.String name, java.lang.String delimiter)
          Take a name and convert it to a convenient java name.
static java.lang.String toPackageDefinition(java.lang.String packageName)
          Convert the package name into a valid package definition.
static java.lang.String toUpperCaseFirst(java.lang.String s)
          Make the first letter of a string upper case
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvenientCodegen

public ConvenientCodegen()
Method Detail

toPackageDefinition

public static java.lang.String toPackageDefinition(java.lang.String packageName)
Convert the package name into a valid package definition. If the package name is empty or null an empty string is returned. The package definition ends with a double new line if the package is valid.

Parameters:
packageName - name of the package
Returns:
package declaration

getSimpleClassName

public static java.lang.String getSimpleClassName(java.lang.Class c)
Retrieve the simple representation of a class

Parameters:
c - class to be represented
Returns:
last part of the full class name behind the '.'

getSimpleClassName

public static java.lang.String getSimpleClassName(java.lang.String c)
Retrieve the simple representation of a class

Parameters:
c - name of the class
Returns:
last part of the full class name behind the '.'

toName

public static java.lang.String toName(java.lang.String name,
                                      java.lang.String delimiter)
Take a name and convert it to a convenient java name. The name may be divided into several parts by a delimiter.

The input string 'USER_NAME' with the delimiter '_' becomes 'userName'.
The input string 'get_USER_NAME' with the delimiter '_' becomes 'getUserName'.

Parameters:
name - to be converted
delimiter - string or null
Returns:
converted variable name

isPrimitiveClass

public static boolean isPrimitiveClass(java.lang.String c)
Check whether the class belongs to the java.lang package

Parameters:
c - name of the class
Returns:
true if the class resides in java.lang

isPrimitiveClass

public static boolean isPrimitiveClass(java.lang.Class c)
Check whether the class belongs to the java.lang package

Parameters:
c - class to be checked
Returns:
true if the class resides in java.lang

camelCase

public static java.lang.String camelCase(java.lang.String s,
                                         java.lang.String delimiter)
Camel-case a string that is divided by the designated delimiter

Parameters:
s - input string
delimiter - parting the words in the string
Returns:
camel-cased string

camelCaseLowerCaseFirst

public static java.lang.String camelCaseLowerCaseFirst(java.lang.String s,
                                                       java.lang.String delimiter)
Camale-case a string that is divided by the designated delimiter with a lower case start.

Parameters:
s - input string
delimiter - parting the words in the string
Returns:
camel-cased string

toLowerCaseFirst

public static java.lang.String toLowerCaseFirst(java.lang.String s)
Make the first letter of a string lower case

Parameters:
s - input String
Returns:
input-String with a lower-case first letter

toUpperCaseFirst

public static java.lang.String toUpperCaseFirst(java.lang.String s)
Make the first letter of a string upper case

Parameters:
s - input String
Returns:
input-String with a upper-case first letter

getClassShortName

public static java.lang.String getClassShortName(DataBaseTableField dbtf)
Extract the class name from the class declaration

Parameters:
dbtf - Field declaration
Returns:
name of the class

isPrimitiveType

public static boolean isPrimitiveType(DataBaseTableField dbtf)
Check weather the type is a primitive type, meaning a type defined in the package java.lang

Parameters:
dbtf - Field to be checked
Returns:
true if the type is primitive

isBoxingType

public static boolean isBoxingType(java.lang.Class type)
Check whether the type is of a primitive type that needs boxing such as byte, boolean, double, float, int, long, short, char

Parameters:
type - class type to be checked
Returns:
true if the type must be boxed
Since:
0.9.4

getBoxingClassShortName

public static java.lang.String getBoxingClassShortName(java.lang.Class type)
Retrieve the short name of the boxing class

Parameters:
type - class type of byte, boolean, double, float, int, long, short, char
Returns:
Boxing class short name or null if the type is not one of the above
Since:
0.9.4

getBoxingClassParsingMethodName

public static java.lang.String getBoxingClassParsingMethodName(java.lang.Class type)
Retrieve the method name of the boxing class

Parameters:
type - class type of byte, boolean, double, float, int, long, short, char
Returns:
Boxing class short name or null if the type is not one of the above
Since:
0.9.4