List of usage examples for org.apache.commons.lang StringUtils capitalize
public static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:org.apache.torque.engine.database.model.JavaNameGenerator.java
/** * Converts a database schema name to java object name. * First, it removes all characters before the last occurence of * .<code>SCHEMA_SEPARATOR_CHAR</code>. Then, in a second step, removes * <code>STD_SEPARATOR_CHAR</code>, capitilizes first letter of * name and each letter after the <code>STD_SEPERATOR</code>, * and converts the rest of the letters to lowercase. * * @param schemaName name to be converted. * @return converted name.//w w w . jav a2 s.c o m * @see org.apache.torque.engine.database.model.NameGenerator * @see #underscoreOmitSchemaMethod(String) */ protected String underscoreOmitSchemaMethod(String schemaName) { // take only part after last dot int lastDotPos = schemaName.lastIndexOf(SCHEMA_SEPARATOR_CHAR); if (lastDotPos != -1) { schemaName = schemaName.substring(lastDotPos + 1); } StringBuffer name = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = ((String) tok.nextElement()).toLowerCase(); name.append(StringUtils.capitalize(namePart)); } return name.toString(); }
From source file:org.apache.torque.engine.database.model.JavaNameGenerator.java
/** * Converts a database schema name to java object name. Operates * same as underscoreMethod but does not convert anything to * lowercase./*from w ww .jav a 2 s . co m*/ * * @param schemaName name to be converted. * @return converted name. * @see org.apache.torque.engine.database.model.NameGenerator * @see #underscoreMethod(String) */ protected String javanameMethod(String schemaName) { StringBuffer name = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); name.append(StringUtils.capitalize(namePart)); } // remove the SCHEMA_SEPARATOR_CHARs and capitalize // the tokens schemaName = name.toString(); name = new StringBuffer(); tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); name.append(StringUtils.capitalize(namePart)); } return name.toString(); }
From source file:org.apache.torque.generator.configuration.outlet.ReflectionOutletSaxHandlerFactory.java
/** * Returns the fully qualified class name of the handler class * for a given type./*w ww . j av a 2s . com*/ * * @param type the type to determine the handler for. * * @return the fully qualified class name, not null. */ protected String getFullyQualifiedHandlerClassName(String type) { String saxHandlerClassName = StringUtils.capitalize(type) + SAX_HANDLER_CLASSNAME_SUFFIX; String fullyQualifiedSaxHandlerName = saxHandlerPackage + "." + saxHandlerClassName; return fullyQualifiedSaxHandlerName; }
From source file:org.apache.torque.map.DatabaseMap.java
/** * Converts a database schema name to java object name. Operates * same as underscoreMethod but does not convert anything to * lowercase. This must match the javaNameMethod in the * JavaNameGenerator class in Generator code. * * @param schemaName name to be converted. * * @return converted name.// ww w . j a va2s.com */ protected String javanameMethod(String schemaName) { StringBuffer result = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); result.append(StringUtils.capitalize(namePart)); } // remove the SCHEMA_SEPARATOR_CHARs and capitalize // the tokens schemaName = result.toString(); result = new StringBuffer(); tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); result.append(StringUtils.capitalize(namePart)); } return result.toString(); }
From source file:org.apache.torque.map.TableMap.java
/** * Removes the PREFIX, removes the underscores and makes * first letter caps.//from w ww . ja v a2 s . c o m * * SCARAB_FOO_BAR becomes FooBar. * * @param data A String. * @return A String with data processed. */ public final String removeUnderScores(String data) { String tmp = null; StringBuffer out = new StringBuffer(); if (hasPrefix(data)) { tmp = removePrefix(data); } else { tmp = data; } StringTokenizer st = new StringTokenizer(tmp, "_"); while (st.hasMoreTokens()) { String element = ((String) st.nextElement()).toLowerCase(); out.append(StringUtils.capitalize(element)); } return out.toString(); }
From source file:org.apache.torque.task.TorqueDataModelTask.java
/** * Override Texen's context properties to map the * torque.xxx properties (including defaults set by the * org/apache/torque/defaults.properties) to just xxx. * * <p>// w ww . ja v a 2s . co m * Also, move xxx.yyy properties to xxxYyy as Velocity * doesn't like the xxx.yyy syntax. * </p> * * @param file the file to read the properties from */ public void setContextProperties(String file) { super.setContextProperties(file); // Map the torque.xxx elements from the env to the contextProperties Hashtable env = super.getProject().getProperties(); for (Iterator i = env.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); if (key.startsWith("torque.")) { String newKey = key.substring("torque.".length()); int j = newKey.indexOf("."); while (j != -1) { newKey = newKey.substring(0, j) + StringUtils.capitalize(newKey.substring(j + 1)); j = newKey.indexOf("."); } contextProperties.setProperty(newKey, entry.getValue()); } } }
From source file:org.apache.torque.templates.transformer.om.FieldHelper.java
/** * Returns the name of the getter method for a field. * "get" is used as prefix, except if the option * <code>USE_IS_FOR_GETTERS_OPTION_NAME</code> is set to true and * the field type is "boolean", in which case "is" is used as prefix. * * @param fieldName the name of the field, not null. * @param fieldType the type of the field, not null. * @param controllerState the current controller state, not null. * * @return the getter method name, not null. *//*from w w w. ja v a 2 s. c o m*/ public static String getGetterName(String fieldName, String fieldType, ControllerState controllerState) { String getterName; if (controllerState.getBooleanOption(TemplateOptionName.OM_USE_IS_FOR_BOOLEAN_GETTERS) && JavaType.BOOLEAN_PRIMITIVE.getClassName().equals(fieldType)) { getterName = IS + StringUtils.capitalize(fieldName); } else { getterName = GET + StringUtils.capitalize(fieldName); } return getterName; }
From source file:org.apache.torque.templates.transformer.om.FieldHelper.java
/** * Returns the name of the setter method for a field. * Uses "set" as prefix.//from ww w . j a v a 2s . co m * * @param fieldName the name of the field, not null. * * @return the setter method name, not null. */ public static String getSetterName(String fieldName) { String setterName = SET + StringUtils.capitalize(fieldName); return setterName; }
From source file:org.apache.torque.templates.transformer.om.FieldHelper.java
/** * Returns the name of the adder method for a field. * * @param fieldName the name of the field, not null. * @param controllerState the current controller state, not null. * * @return the adder method name, not null. *//*from ww w . j a v a 2 s. c om*/ public static String getAdderName(String fieldName, ControllerState controllerState) { String adderName = controllerState.getOption(TemplateOptionName.OM_ADDER_PREFIX) + StringUtils.capitalize(fieldName) + controllerState.getOption(TemplateOptionName.OM_ADDER_SUFFIX); return adderName; }