org.ofbiz.entity.model
Class ModelUtil

java.lang.Object
  extended by org.ofbiz.entity.model.ModelUtil

public class ModelUtil
extends java.lang.Object

Generic Entity - General Utilities


Field Summary
static java.lang.String module
           
static java.lang.String vowelBag
           
 
Constructor Summary
ModelUtil()
           
 
Method Summary
static java.lang.String dbNameToClassName(java.lang.String columnName)
          Converts a database name to a Java class name.
static java.lang.String dbNameToVarName(java.lang.String columnName)
          Converts a database name to a Java variable name.
static java.lang.String induceFieldType(java.lang.String sqlTypeName, int length, int precision, ModelFieldTypeReader fieldTypeReader)
           
static java.lang.String javaNameToDbName(java.lang.String javaName)
          Converts a Java variable name to a database name.
static java.lang.String lowerFirstChar(java.lang.String string)
          Changes the first letter of the passed String to lower case.
static java.lang.String packageToPath(java.lang.String packageName)
          Converts a package name to a path by replacing all '.' characters with the File.separatorChar character.
static java.lang.String replaceString(java.lang.String mainString, java.lang.String oldString, java.lang.String newString)
          Replaces all occurances of oldString in mainString with newString
static java.lang.String shortenDbName(java.lang.String dbName, int desiredLength)
          Start by removing all vowels, then pull 1 letter at a time off the end of each _ separated segment, go until it is less than or equal to the desired length
static java.lang.String upperFirstChar(java.lang.String string)
          Changes the first letter of the passed String to upper case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

vowelBag

public static java.lang.String vowelBag
Constructor Detail

ModelUtil

public ModelUtil()
Method Detail

upperFirstChar

public static java.lang.String upperFirstChar(java.lang.String string)
Changes the first letter of the passed String to upper case.

Parameters:
string - The passed String
Returns:
A String with an upper case first letter

lowerFirstChar

public static java.lang.String lowerFirstChar(java.lang.String string)
Changes the first letter of the passed String to lower case.

Parameters:
string - The passed String
Returns:
A String with a lower case first letter

dbNameToClassName

public static java.lang.String dbNameToClassName(java.lang.String columnName)
Converts a database name to a Java class name. The naming conventions used to allow for this are as follows: a database name (table or column) is in all capital letters, and the words are separated by an underscore (for example: NEAT_ENTITY_NAME or RANDOM_FIELD_NAME); a Java name (ejb or field) is in all lower case letters, except the letter at the beginning of each word (for example: NeatEntityName or RandomFieldName). The convention of using a capital letter at the beginning of a class name in Java, or a lower-case letter for the beginning of a variable name in Java is also used along with the Java name convention above.

Parameters:
columnName - The database name
Returns:
The Java class name

dbNameToVarName

public static java.lang.String dbNameToVarName(java.lang.String columnName)
Converts a database name to a Java variable name. The naming conventions used to allow for this are as follows: a database name (table or column) is in all capital letters, and the words are separated by an underscore (for example: NEAT_ENTITY_NAME or RANDOM_FIELD_NAME); a Java name (ejb or field) is in all lower case letters, except the letter at the beginning of each word (for example: NeatEntityName or RandomFieldName). The convention of using a capital letter at the beginning of a class name in Java, or a lower-case letter for the beginning of a variable name in Java is also used along with the Java name convention above.

Parameters:
columnName - The database name
Returns:
The Java variable name

javaNameToDbName

public static java.lang.String javaNameToDbName(java.lang.String javaName)
Converts a Java variable name to a database name. The naming conventions used to allow for this are as follows: a database name (table or column) is in all capital letters, and the words are separated by an underscore (for example: NEAT_ENTITY_NAME or RANDOM_FIELD_NAME); a Java name (ejb or field) is in all lower case letters, except the letter at the beginning of each word (for example: NeatEntityName or RandomFieldName). The convention of using a capital letter at the beginning of a class name in Java, or a lower-case letter for the beginning of a variable name in Java is also used along with the Java name convention above.

Parameters:
javaName - The Java variable name
Returns:
The database name

shortenDbName

public static java.lang.String shortenDbName(java.lang.String dbName,
                                             int desiredLength)
Start by removing all vowels, then pull 1 letter at a time off the end of each _ separated segment, go until it is less than or equal to the desired length

Parameters:
dbName -
desiredLength -
Returns:
shortened String

packageToPath

public static java.lang.String packageToPath(java.lang.String packageName)
Converts a package name to a path by replacing all '.' characters with the File.separatorChar character. Is therefore platform independent.

Parameters:
packageName - The package name.
Returns:
The path name corresponding to the specified package name.

replaceString

public static java.lang.String replaceString(java.lang.String mainString,
                                             java.lang.String oldString,
                                             java.lang.String newString)
Replaces all occurances of oldString in mainString with newString

Parameters:
mainString - The original string
oldString - The string to replace
newString - The string to insert in place of the old
Returns:
mainString with all occurances of oldString replaced by newString

induceFieldType

public static java.lang.String induceFieldType(java.lang.String sqlTypeName,
                                               int length,
                                               int precision,
                                               ModelFieldTypeReader fieldTypeReader)