List of utility methods to do String Camel Case To
String | camelCaseToDashes(String camelCaseString, int startIndex, String prefix) camel Case To Dashes StringBuilder dashName = new StringBuilder(prefix); for (int i = startIndex; i < camelCaseString.length(); i++) { char c = camelCaseString.charAt(i); if (Character.isUpperCase(c)) { if (dashName.length() > 0) dashName.append('-'); dashName.append(Character.toLowerCase(c)); } else { ... |
String | camelCaseToDashLowerName(String name) camel Case To Dash Lower Name return name.replaceAll("([A-Z])", "-$1").toLowerCase(); |
String | camelCaseToDashSeperated(String s) camel Case To Dash Seperated int len = s.length(); int pos = 1; while (pos < len) { if (Character.isUpperCase(s.charAt(pos))) { String firstword = s.substring(0, pos).toLowerCase(); String rest = camelCaseToDashSeperated(s.substring(pos)); return firstword + "-" + rest; pos++; return s.toLowerCase(); |
String | camelCaseToDotNotation(String string) camel Case To Dot Notation StringBuilder sb = new StringBuilder(); char last = 0; for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (Character.isUpperCase(c) && Character.isLowerCase(last)) { sb.append("."); last = c; ... |
String | camelCaseToEnum(String camelCase) Converts camelCaseStringsWithACRONYMS to CAMEL_CASE_STRINGS_WITH_ACRONYMS final String regex = "([a-z])([A-Z])"; final String replacement = "$1_$2"; return camelCase.replaceAll(regex, replacement).toUpperCase(); |
String | camelCaseToEnum(String name) camel Case To Enum StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); i++) { if ((i != 0) && Character.isUpperCase(name.charAt(i))) { sb.append('_'); sb.append(Character.toUpperCase(name.charAt(i))); return sb.toString(); ... |
String | camelCaseToHuman(String input) Turns a CamelCase String to a more human friendly string See TestStringUtils for specification. StringBuilder builder = new StringBuilder(); for (int i = 0; i < input.length(); i++) { char currentChar = input.charAt(i); if (i == 0) { builder.append(Character.toUpperCase(currentChar)); } else if (Character.isLowerCase(currentChar)) { builder.append(currentChar); } else if (Character.isUpperCase(currentChar)) { ... |
String | camelCaseToPhrase(String camelCase) camel Case To Phrase if (isEmpty(camelCase)) { return ""; String camelCaseSpaced = camelCase.replaceAll("([^A-Z])([A-Z])", "$1 $2"); return camelCaseSpaced.charAt(0) + camelCaseSpaced.substring(1).toLowerCase(); |
String | camelCaseToPretty(String camelCase) camel Case To Pretty if (camelCase == null || camelCase.length() == 0) return ""; StringBuilder prettyName = new StringBuilder(); String lastPart = null; for (String part : camelCase.split("(?=[A-Z0-9\\.#])")) { if (part.length() == 0) continue; char firstChar = part.charAt(0); ... |
String | camelCaseToSeparatedWords(String ccString, String separator) camel Case To Separated Words StringBuilder buffer = new StringBuilder(ccString); for (int i = ccString.length() - 1; i > 0; i--) if (Character.isUpperCase(ccString.charAt(i)) && Character.isLowerCase(ccString.charAt(i - 1))) buffer.insert(i, separator); return buffer.toString(); |