List of usage examples for org.apache.commons.lang3.text WordUtils capitalizeFully
public static String capitalizeFully(String str, final char... delimiters)
Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.
From source file:io.jeandavid.projects.vod.util.StringUtils.java
public static String camelize(String string) { return WordUtils.capitalizeFully(string, '_').replace(" ", ""); }
From source file:name.martingeisse.common.util.string.StringUtil.java
/** * Converts an underscored name to an upper-camel-case name like * this: "my_foo_bar" -> "MyFooBar"./*from ww w . j a v a2 s. co m*/ * @param s the string to convert * @return the upper camel case string */ public static String convertUnderscoresToUpperCamelCase(String s) { return StringUtils.remove(WordUtils.capitalizeFully(s, UNDERSCORE_ARRAY), '_'); }
From source file:name.martingeisse.common.util.string.StringUtil.java
/** * Converts an underscored name to an lower-camel-case name like * this: "my_foo_bar" -> "myFooBar"./* w w w . jav a 2 s. c o m*/ * @param s the string to convert * @return the lower camel case string */ public static String convertUnderscoresToLowerCamelCase(String s) { if (s.isEmpty()) { return s; } char firstCharacterLowerCase = Character.toLowerCase(s.charAt(0)); return firstCharacterLowerCase + StringUtils.remove(WordUtils.capitalizeFully(s, UNDERSCORE_ARRAY), '_').substring(1); }
From source file:com.threewks.thundr.bind.http.request.RequestHeaderBinder.java
String normaliseHeaderName(String header) { String capitalised = WordUtils.capitalizeFully(header, '-'); String withoutDashes = capitalised.replaceAll(StringPool.DASH, StringPool.EMPTY); return StringUtils.uncapitalize(withoutDashes); }
From source file:com.threewks.thundr.bigmetrics.controller.EventQueueControllerTest.java
@Test public void shouldCorrectlyFormatHeader() { // Check logic, by using Thundr code String originalHeader = "X-AppEngine-TaskName"; String parameterHeader = "xAppengineTaskname"; String capitalised = WordUtils.capitalizeFully(originalHeader, '-'); String withoutDashes = capitalised.replaceAll(StringPool.DASH, StringPool.EMPTY); String formattedHeader = StringUtils.uncapitalize(withoutDashes); assertThat(formattedHeader, is(parameterHeader)); }
From source file:de.escalon.hypermedia.hydra.serialize.JacksonHydraSerializer.java
private Map<String, Object> getTerms(Object bean, Class<?> mixInClass) throws IntrospectionException, IllegalAccessException, NoSuchFieldException { // define terms from package or type in context final Class<?> beanClass = bean.getClass(); Map<String, Object> termsMap = getAnnotatedTerms(beanClass.getPackage(), beanClass.getPackage().getName()); Map<String, Object> classTermsMap = getAnnotatedTerms(beanClass, beanClass.getName()); Map<String, Object> mixinTermsMap = getAnnotatedTerms(mixInClass, beanClass.getName()); // class terms override package terms termsMap.putAll(classTermsMap);/*www.j av a 2 s.co m*/ // mixin terms override class terms termsMap.putAll(mixinTermsMap); final Field[] fields = beanClass.getDeclaredFields(); for (Field field : fields) { final Expose fieldExpose = field.getAnnotation(Expose.class); if (Enum.class.isAssignableFrom(field.getType())) { Map<String, String> map = new LinkedHashMap<String, String>(); termsMap.put(field.getName(), map); if (fieldExpose != null) { map.put(AT_ID, fieldExpose.value()); } map.put(AT_TYPE, AT_VOCAB); final Enum value = (Enum) field.get(bean); final Expose enumValueExpose = getAnnotation(value.getClass().getField(value.name()), Expose.class); // TODO redefine actual enum value to exposed on enum value definition if (enumValueExpose != null) { termsMap.put(value.toString(), enumValueExpose.value()); } else { // might use upperToCamelCase if nothing is exposed final String camelCaseEnumValue = WordUtils .capitalizeFully(value.toString(), new char[] { '_' }).replaceAll("_", ""); termsMap.put(value.toString(), camelCaseEnumValue); } } else { if (fieldExpose != null) { termsMap.put(field.getName(), fieldExpose.value()); } } } // TODO do this recursively for nested beans and collect as long as // nested beans have same vocab // expose getters in context final BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { final Method method = propertyDescriptor.getReadMethod(); final Expose expose = method.getAnnotation(Expose.class); if (expose != null) { termsMap.put(propertyDescriptor.getName(), expose.value()); } } return termsMap; }
From source file:org.dmu.expertiserecognition.doiResults.java
public static String standardizeAuthorName(String name) { String newName = name.trim(); newName = deAccent(newName);// w w w .jav a2s . c o m newName = WordUtils.capitalizeFully(newName, new char[] { '.', ' ', '-', '\'' }); newName = newName.replaceAll("([A-Za-z0-9-']+)\\.([A-Za-z0-9-']+)", "$1. $2"); newName = newName.replaceAll("[ ]{2,}", " "); newName = newName.replaceAll("^(.*)([^\\.]) ([A-Z]\\.)$", "$3 $1$2"); String surname; String authInitials; if (Pattern.matches("^.*\\.$", newName)) { surname = newName.replaceAll("^([^ ]+) (.*)$", "$1"); authInitials = newName.replaceAll("^([^ ]+) (.*)$", "$2"); } else { surname = newName.replaceAll("^(.*) ([^ ]+)$", "$2"); authInitials = newName.replaceAll("^(.*) ([^ ]+)$", "$1"); } authInitials = WordUtils.initials(authInitials, new char[] { '.', ' ' }); byte[] authInitialsBytes = authInitials.getBytes(); int i; StringBuilder sb = new StringBuilder(); for (i = 0; i < authInitialsBytes.length; i++) { sb.append((char) authInitialsBytes[i]); sb.append(". "); } sb.append(surname); newName = sb.toString(); return newName; }
From source file:org.trimou.engine.config.ConfigurationProperties.java
/** * Build the property key for the given name and prefix parts. The name is * converted to CamelCase (using the specified delimiter; delimiters are * removed in the end).//w w w . ja v a2 s .c om * * @param propertyName * @param delimiter * @param prefixParts * @return the key */ public static String buildPropertyKey(String propertyName, String delimiter, String[] prefixParts) { StringBuilder key = new StringBuilder(); for (int i = 0; i < prefixParts.length; i++) { key.append(prefixParts[i]); key.append(Strings.DOT); } key.append(WordUtils.uncapitalize(StringUtils .replace(WordUtils.capitalizeFully(propertyName, delimiter.toCharArray()), delimiter, ""))); return key.toString(); }
From source file:org.zephyrsoft.util.StringTools.java
/** * Convert a string which is separated with underscores to camel case. Example: "UNDERSCORED_STRING_EXAMPLE" => * "underscoredStringExample"// w ww. ja v a 2s .c o m * * @param underscoredString * the underscore-separated string * @return the camel-cased string */ public static String underscoredToCamelCase(String underscoredString) { if (underscoredString == null || underscoredString.length() == 0) { return ""; } else { String ret = WordUtils.capitalizeFully(underscoredString, new char[] { '_' }).replaceAll("_", ""); ret = ret.substring(0, 1).toLowerCase(Locale.ENGLISH) + ret.substring(1); return ret; } }