Package org.apache.ofbiz.entity.model
Class ModelUtil
java.lang.Object
org.apache.ofbiz.entity.model.ModelUtil
Generic Entity - General Utilities
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
dbNameToClassName
(String columnName) Converts a database name to a Java class name.static String
dbNameToVarName
(String columnName) Converts a database name to a Java variable name.static String
induceFieldType
(String sqlTypeName, int length, int precision, ModelFieldTypeReader fieldTypeReader) static boolean
isPotentialLocalizedField
(ModelEntity modelEntity, String fieldName) Check is a ModelEntity have a default resource associate to resolve localized value When the ModelEntity is a ModelViewEntity, check with the field to resolve the related entitystatic boolean
isPotentialLocalizedFields
(ModelEntity modelEntity, List<String> fieldNames) Check is a ModelEntity have a default resource associate to resolve localized value When the ModelEntity is a ModelViewEntity, check with the list fields to resolve these related entitiesstatic String
javaNameToDbName
(String javaName) Converts a Java variable name to a database name.static String
lowerFirstChar
(String string) Changes the first letter of the passed String to lower case.static String
packageToPath
(String packageName) Converts a package name to a path by replacing all '.' characters with the File.separatorChar character.static String
replaceString
(String mainString, String oldString, String newString) Replaces all occurances of oldString in mainString with newStringstatic String
shortenDbName
(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 lengthstatic String
upperFirstChar
(String string) Changes the first letter of the passed String to upper case.
-
Method Details
-
upperFirstChar
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
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
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
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
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
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
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
Replaces all occurances of oldString in mainString with newString- Parameters:
mainString
- The original stringoldString
- The string to replacenewString
- The string to insert in place of the old- Returns:
- mainString with all occurances of oldString replaced by newString
-
induceFieldType
public static String induceFieldType(String sqlTypeName, int length, int precision, ModelFieldTypeReader fieldTypeReader) -
isPotentialLocalizedField
Check is a ModelEntity have a default resource associate to resolve localized value When the ModelEntity is a ModelViewEntity, check with the field to resolve the related entity- Parameters:
modelEntity
-fieldName
-- Returns:
-
isPotentialLocalizedFields
Check is a ModelEntity have a default resource associate to resolve localized value When the ModelEntity is a ModelViewEntity, check with the list fields to resolve these related entities- Parameters:
modelEntity
-fieldNames
-- Returns:
-