List of usage examples for org.springframework.util StringUtils capitalize
public static String capitalize(String str)
From source file:org.usergrid.benchmark.boostrap.Command.java
/** * @param args// w w w.j a va 2 s .c o m */ public static void main(String[] args) { if ((args == null) || (args.length < 1)) { System.out.println("No command specified"); return; } String command = args[0]; Class<?> clazz = null; try { clazz = Class.forName(command); } catch (ClassNotFoundException e) { } if (clazz == null) { try { clazz = Class.forName("org.usergrid.benchmark.commands." + command); } catch (ClassNotFoundException e) { } } if (clazz == null) { try { clazz = Class.forName("org.usergrid.benchmark.commands." + StringUtils.capitalize(command)); } catch (ClassNotFoundException e) { e.printStackTrace(); } } if (clazz == null) { System.out.println("Unable to find command"); return; } args = Arrays.copyOfRange(args, 1, args.length); try { if (ToolBase.class.isAssignableFrom(clazz)) { ToolBase tool = (ToolBase) clazz.newInstance(); tool.startTool(args); } else { MethodUtils.invokeStaticMethod(clazz, "main", (Object) args); } } catch (NoSuchMethodException e) { System.out.println("Unable to invoke command"); e.printStackTrace(); } catch (IllegalAccessException e) { System.out.println("Unable to invoke command"); e.printStackTrace(); } catch (InvocationTargetException e) { System.out.println("Error while invoking command"); e.printStackTrace(); } catch (InstantiationException e) { System.out.println("Error while instantiating tool object"); e.printStackTrace(); } }
From source file:com.github.hibatis.ReflectionUtils.java
/** * Getter.//from w w w . j ava 2s. com */ public static Object invokeGetterMethod(Object obj, String propertyName) { String getterMethodName = "get" + StringUtils.capitalize(propertyName); return invokeMethod(obj, getterMethodName, new Class[] {}, new Object[] {}); }
From source file:org.shept.util.StringUtilsExtended.java
public static String getReadAccessor(String name) { if (hasText(name)) { return "get" + StringUtils.capitalize(name); }// w ww .j a va 2 s. c o m return name; }
From source file:com.lpm.fanger.commons.util.Reflections.java
/** * Getter./*from w w w.j ava 2s. c o m*/ * ???.??. */ public static Object invokeGetter(Object obj, String propertyName) { Object object = obj; for (String name : StringUtils.split(propertyName, ".")) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } return object; }
From source file:com.github.hibatis.ReflectionUtils.java
/** * Setter./*from w w w .j ava2 s . c om*/ * * @param propertyType Setter,valueClass. */ public static void invokeSetterMethod(Object obj, String propertyName, Object value, Class<?> propertyType) { Class<?> type = propertyType != null ? propertyType : value.getClass(); String setterMethodName = "set" + StringUtils.capitalize(propertyName); invokeMethod(obj, setterMethodName, new Class[] { type }, new Object[] { value }); }
From source file:org.smigo.user.Language.java
public static Map<String, String> getLanguagesForDisplay(Enumeration<Locale> locales, Locale additionalLocale) { SortedMap<String, String> ret = new TreeMap<>(); for (Language t : Language.values()) { ret.put(t.locale.toString(), StringUtils.capitalize(t.locale.getDisplayName(t.locale))); }/*from w w w. j a v a 2 s. c o m*/ while (locales.hasMoreElements()) { Locale locale = locales.nextElement(); ret.put(locale.toString(), StringUtils.capitalize(locale.getDisplayName(locale))); } ret.put(additionalLocale.toString(), StringUtils.capitalize(additionalLocale.getDisplayName(additionalLocale))); return ret; }
From source file:org.shept.persistence.provider.hibernate.HibernateUtils_old.java
public static Serializable getIdValue(HibernateDaoSupport dao, Object model) { String idStr = getIdentifierPropertyName(dao, model); // TODO use BeanWrapper instead ? Method idMth = ReflectionUtils.findMethod(model.getClass(), "get" + StringUtils.capitalize(idStr)); Serializable idxObj = (Serializable) ReflectionUtils.invokeMethod(idMth, model); return idxObj; }
From source file:org.yamj.common.type.ExitType.java
/** * Get an output string of the exit values * * @return/* w w w .j a va2 s .c o m*/ */ public static String getDescriptions() { final StringBuilder sb = new StringBuilder("Exit codes: \n"); for (ExitType et : ExitType.values()) { sb.append(" "); sb.append(et.getReturn()); sb.append(" = "); sb.append(StringUtils.capitalize(StringUtils.replace(et.toString(), "_", " ").toLowerCase())); sb.append("\n"); } return sb.toString(); }
From source file:com.example.session.app.validation.ConfirmValidator.java
@Override public void initialize(Confirm constraintAnnotation) { field = constraintAnnotation.field(); confirmField = "confirm" + StringUtils.capitalize(field); message = constraintAnnotation.message(); }
From source file:com.maiseries.core.bank.web.common.util.Reflections.java
/** * Setter, ??? ???.??./* www . j a v a 2 s . co m*/ */ public static void invokeSetter(Object obj, String propertyName, Object value) { Object object = obj; String[] names = StringUtils.split(propertyName, "."); for (int i = 0; i < names.length; i++) { if (i < names.length - 1) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } else { String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); invokeMethodByName(object, setterMethodName, new Object[] { value }); } } }