Package org.openbravo.base.model
Class NamingUtil
- java.lang.Object
-
- org.openbravo.base.model.NamingUtil
-
public class NamingUtil extends Object
The NamingUtil class is used to create names for theproperties
of theentities
.- Author:
- iperdomo, mtaal
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENTITY_NAME_CONSTANT
static char[]
ILLEGAL_ENTITY_NAME_CHARS
static String
PROPERTY_CONSTANT_PREFIX
-
Constructor Summary
Constructors Constructor Description NamingUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
doesNameContainNonNormalCharacters(String name)
Checks a name for non-normal characters.static boolean
doesNameHaveIllegalChars(String name)
Checks if a name of a table contains illegal chars.static String
formatAsPropertyName(String name)
Formats the given String as a property name which implies camel casing the characters after "_" and " ", removing illegal characters and lower casing the first character.static String
getEntityName(Class<?> clz)
Returns the value of the ENTITY_NAME constant in the passed class.static String
getStaticPropertyName(Class<?> clz, String propertyName)
Generated entity classes have String constants to denote their property name.
-
-
-
Field Detail
-
ILLEGAL_ENTITY_NAME_CHARS
public static final char[] ILLEGAL_ENTITY_NAME_CHARS
-
ENTITY_NAME_CONSTANT
public static final String ENTITY_NAME_CONSTANT
- See Also:
- Constant Field Values
-
PROPERTY_CONSTANT_PREFIX
public static final String PROPERTY_CONSTANT_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
doesNameHaveIllegalChars
public static boolean doesNameHaveIllegalChars(String name)
Checks if a name of a table contains illegal chars.- Parameters:
name
- the name to check- Returns:
- true if the name contains a char from the
ILLEGAL_ENTITY_NAME_CHARS
).
-
doesNameContainNonNormalCharacters
public static boolean doesNameContainNonNormalCharacters(String name)
Checks a name for non-normal characters. Non-normal is everything from a to z, A to Z, 0 to 9 and _.- Parameters:
name
- the name to check- Returns:
- true if the name contains illegal chars, false otherwise
-
getEntityName
public static String getEntityName(Class<?> clz)
Returns the value of the ENTITY_NAME constant in the passed class.- Parameters:
clz
- the entity class- Returns:
- the ENTITY_NAME constant
-
getStaticPropertyName
public static String getStaticPropertyName(Class<?> clz, String propertyName)
Generated entity classes have String constants to denote their property name. It has a performance benefit if the String constant is used because then HashMap get operations are faster (as equals also tests on object equality). This method tries to retrieve the String constant from the passed class. The clz parameter maybe null (happens for dynamic entities). In this case the passed propertyName is returned.- Parameters:
clz
- the entity class, maybe null, in which case propertyName is returnedpropertyName
- the propertyName to search for in the class- Returns:
- the String constant or the passed propertyName
-
formatAsPropertyName
public static String formatAsPropertyName(String name)
Formats the given String as a property name which implies camel casing the characters after "_" and " ", removing illegal characters and lower casing the first character.- Parameters:
name
- The name to be formatted- Returns:
- the provided name formatted as a property name
-
-