List of usage examples for org.apache.commons.lang StringUtils uncapitalize
public static String uncapitalize(String str)
Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .
From source file:org.betaconceptframework.astroboa.model.impl.item.ContentObjectProfileItem.java
private ContentObjectProfileItem() { cmsDefinitionItem = new ItemQNameImpl("", "", StringUtils.uncapitalize(this.name())); }
From source file:org.betaconceptframework.astroboa.test.AstroboaTestContext.java
public <T> T getBean(Class<T> type, String name) { if (StringUtils.isBlank(name)) { return (T) applicationContext.getBean(StringUtils.uncapitalize(type.getSimpleName())); } else {/*from ww w. j a v a 2 s .c o m*/ return (T) applicationContext.getBean(name); } }
From source file:org.braiden.fpm2.util.PropertyUtils.java
public static Map<String, Object> describe(Object bean) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Validate.notNull(bean);/*from w ww . j av a 2 s . c o m*/ Map<String, Object> result = new HashMap<String, Object>(); for (Method method : bean.getClass().getMethods()) { boolean isAccepted = Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length == 0 && !METHOD_GET_CLASS.equals(method.getName()); boolean isObjGetter = isAccepted && !Void.class.isAssignableFrom(method.getReturnType()) && method.getName().startsWith(GETTER_PREFIX); boolean isBooleanGetter = isAccepted && (Boolean.class.isAssignableFrom(method.getReturnType()) || boolean.class.isAssignableFrom(method.getReturnType())) && method.getName().startsWith(GETTER_BOOLEAN_PREFIX); if (isObjGetter || isBooleanGetter) { String propName = StringUtils .uncapitalize(isObjGetter ? method.getName().substring(GETTER_PREFIX.length()) : method.getName().substring(GETTER_BOOLEAN_PREFIX.length())); result.put(propName, method.invoke(bean)); } } return result; }
From source file:org.broadleafcommerce.common.util.UrlUtil.java
public static String generateUrlKey(String toConvert) { if (toConvert != null) { toConvert = toConvert.replaceAll(" ", "-"); if (toConvert.matches(".*?\\W.*?")) { //remove all non-word characters String result = toConvert.replaceAll("[^\\w-]+", ""); //uncapitalizes the first letter of the url key return StringUtils.uncapitalize(result); } else {//from ww w . java 2 s. c o m return StringUtils.uncapitalize(toConvert); } } return toConvert; }
From source file:org.carewebframework.ui.zk.RowComparator.java
/** * Derives the name of the getter method from the component id, following "JavaBean" * conventions. Supports traditional property "getters" as well as boolean getter methods (i.e. * isActive(), hasChildren()). If the id is mapped to a boolean getter, then your id should * begin with 'is' or 'has'.//from w w w .j av a 2s . c om * * @param component Component used to derive getter method. * @return Null if the component has no id or has a ZK-generated id. Otherwise, if the id is * prefixed with a standard getter prefix ("get", "has", "is"), it is assumed to be the * name of the getter method. Lacking such a prefix, a prefix of "get" is prepended to * the case-adjusted id to obtain the getter method. */ private static String getterMethod(Component component) { String id = component.getId(); if (id == null || id.isEmpty() || id.startsWith("z")) { return null; } String lc = id.toLowerCase(); if (lc.startsWith("is") || lc.startsWith("has") || lc.startsWith("get")) { return StringUtils.uncapitalize(id);//i.e. isActive, hasChildren } return "get".concat(StringUtils.capitalize(id));//i.e. getOrderStatus, getTitle }
From source file:org.carewebframework.ui.zk.ZKUtil.java
/** * Creates a dialog for the specified class. Autowires variables and forwards and applies the * onMove event listener to restrict movement to the browser view port. This makes several * assumptions. First, the zul page backed by the class must be named the same as the class with * a lowercase first character. Second, the zul page must be located in a subfolder named the * same as the fully qualified package name and located under the web folder. Third, the top * level component of the zul page must correspond to the specified class. For example, if the * class is org.carewebframework.sample.MyClass, the corresponding zul page must be * web/org/carewebframework/sample/myClass.zul and the top level component in the zul page must * be of the type myClass./* ww w . ja v a 2 s . co m*/ * * @param <T> Type * @param clazz Class backing the dialog. * @return Instance of the dialog. * @throws Exception if problem occurs creating dialog */ @SuppressWarnings("unchecked") public static <T extends Component> T createDialog(Class<T> clazz) throws Exception { String zul = getResourcePath(clazz) + StringUtils.uncapitalize(clazz.getSimpleName()) + ".zul"; T dialog = (T) ZKUtil.loadZulPage(zul, null); MoveEventListener.add(dialog); wireController(dialog); return dialog; }
From source file:org.chililog.server.common.AppProperties.java
/** * <p>//w w w .j a v a 2 s. c o m * Parses the properties into strongly typed class fields. * </p> * * <p> * Use reflection to simulate the likes of: <code>_appName = loadAppName(properties);</code> * </p> * * @param properties * Properties to parse * @throws Exception */ private void parseProperties(Properties properties) throws Exception { Class<AppProperties> cls = AppProperties.class; Field[] ff = cls.getDeclaredFields(); for (Field f : ff) { // Look for field names like APP_NAME String propertyNameFieldName = f.getName(); if (!propertyNameFieldName.matches("^[A-Z0-9_]+$")) { continue; } // Build cache field (_appName) and method (loadAppName) methods String baseName = WordUtils.capitalizeFully(propertyNameFieldName, new char[] { '_' }); baseName = baseName.replace("_", ""); String cacheMethodName = "load" + baseName; String cacheFieldName = "_" + StringUtils.uncapitalize(baseName); // If field not exist, then skip Field cacheField = null; try { cacheField = cls.getDeclaredField(cacheFieldName); } catch (NoSuchFieldException e) { continue; } // Get and set the value Method m = cls.getDeclaredMethod(cacheMethodName, Properties.class); Object cacheValue = m.invoke(null, properties); cacheField.set(this, cacheValue); } return; }
From source file:org.chililog.server.common.AppProperties.java
/** * Returns a string representation of the parsed properties */// w w w . j a v a 2 s.c om public String toString() { StringBuilder sb = new StringBuilder(); Class<AppProperties> cls = AppProperties.class; for (Field f : cls.getDeclaredFields()) { // Look for field names like APP_NAME String propertyNameFieldName = f.getName(); if (!propertyNameFieldName.matches("^[A-Z0-9_]+$")) { continue; } // Build cache field (_appName) and method (loadAppName) methods String baseName = WordUtils.capitalizeFully(propertyNameFieldName, new char[] { '_' }); baseName = baseName.replace("_", ""); String cacheFieldName = "_" + StringUtils.uncapitalize(baseName); // If field not exist, then skip Field cacheField = null; try { cacheField = cls.getDeclaredField(cacheFieldName); } catch (NoSuchFieldException e) { continue; } // Get the value try { Object o = cacheField.get(this); sb.append(f.get(null)); sb.append(" = "); sb.append(o == null ? "<not set>" : o.toString()); sb.append("\n"); } catch (Exception e) { sb.append("ERROR: Cannot load value for: " + propertyNameFieldName); } } return sb.toString(); }
From source file:org.chililog.server.common.BuildProperties.java
/** * <p>//from ww w.j a v a 2s . c o m * Parses the properties into strongly typed class fields. * </p> * * <p> * Use reflection to simulate the likes of: <code>_appName = loadAppName(properties);</code> * </p> * * @param properties * Properties to parse * @throws Exception */ private void parseProperties(Properties properties) throws Exception { Class<BuildProperties> cls = BuildProperties.class; Field[] ff = cls.getDeclaredFields(); for (Field f : ff) { // Look for field names like APP_NAME String propertyNameFieldName = f.getName(); if (!propertyNameFieldName.matches("^[A-Z0-9_]+$")) { continue; } // Build cache field (_appName) and method (loadAppName) methods String baseName = WordUtils.capitalizeFully(propertyNameFieldName, new char[] { '_' }); baseName = baseName.replace("_", ""); String cacheMethodName = "load" + baseName; String cacheFieldName = "_" + StringUtils.uncapitalize(baseName); // If field not exist, then skip Field cacheField = null; try { cacheField = cls.getDeclaredField(cacheFieldName); } catch (NoSuchFieldException e) { continue; } // Get and set the value Method m = cls.getDeclaredMethod(cacheMethodName, Properties.class); Object cacheValue = m.invoke(null, properties); cacheField.set(this, cacheValue); } return; }
From source file:org.chililog.server.common.BuildProperties.java
/** * Returns a string representation of the parsed properties *//*w w w . j av a2 s . co m*/ public String toString() { StringBuilder sb = new StringBuilder(); Class<BuildProperties> cls = BuildProperties.class; for (Field f : cls.getDeclaredFields()) { // Look for field names like APP_NAME String propertyNameFieldName = f.getName(); if (!propertyNameFieldName.matches("^[A-Z0-9_]+$")) { continue; } // Build cache field (_appName) and method (loadAppName) methods String baseName = WordUtils.capitalizeFully(propertyNameFieldName, new char[] { '_' }); baseName = baseName.replace("_", ""); String cacheFieldName = "_" + StringUtils.uncapitalize(baseName); // If field not exist, then skip Field cacheField = null; try { cacheField = cls.getDeclaredField(cacheFieldName); } catch (NoSuchFieldException e) { continue; } // Get the value try { Object o = cacheField.get(this); sb.append(f.get(null)); sb.append(" = "); sb.append(o == null ? "<not set>" : o.toString()); sb.append("\n"); } catch (Exception e) { sb.append("ERROR: Cannot load value for: " + propertyNameFieldName); } } return sb.toString(); }