List of utility methods to do String Case Swap
String | swapCase(final String str) Swaps the case of a String using a word based algorithm. if (isEmpty(str)) { return str; final char[] buffer = str.toCharArray(); boolean whitespace = true; for (int i = 0; i < buffer.length; i++) { final char ch = buffer[i]; if (Character.isUpperCase(ch)) { ... |
String | swapCase(String str) Swaps the case of String. Properly looks after making sure the start of words are Titlecase and not Uppercase.
if (str == null) { return null; int sz = str.length(); StringBuilder buffer = new StringBuilder(sz); boolean whitespace = false; char ch; char tmp; ... |
String | swapCase(String str) Swaps the case of a String using a word based algorithm.
Whitespace is defined by Character#isWhitespace(char) . char[] buffer = str.toCharArray(); boolean whitespace = true; for (int i = 0; i < buffer.length; i++) { char ch = buffer[i]; if (Character.isUpperCase(ch)) { buffer[i] = Character.toLowerCase(ch); whitespace = false; } else if (Character.isTitleCase(ch)) { ... |
String | swapCase(String str) swap Case int strLen; if (str == null || (strLen = str.length()) == 0) { return str; StringBuilder buffer = new StringBuilder(strLen); char ch = 0; for (int i = 0; i < strLen; i++) { ch = str.charAt(i); ... |
String | swapCase(String str) Swaps the case of a String changing upper and title case to lower case, and lower case to upper case.
For a word based algorithm, see WordUtils#swapCase(String) . int strLen; if (str == null || (strLen = str.length()) == 0) { return str; StringBuffer buffer = new StringBuffer(strLen); char ch = 0; for (int i = 0; i < strLen; i++) { ch = str.charAt(i); ... |
String | swapCase(String str) swap Case int strLen; if ((str == null) || ((strLen = str.length()) == 0)) { return str; StringBuffer buffer = new StringBuffer(strLen); char ch = '\000'; for (int i = 0; i < strLen; i++) { ch = str.charAt(i); ... |
String | swapCase(String str) Swaps the case of a String using a word based algorithm. int strLen; if (str == null || (strLen = str.length()) == 0) { return str; StringBuilder buffer = new StringBuilder(strLen); boolean whitespace = true; char ch = 0; char tmp = 0; ... |
String | swapFirstLetterCase(String str) convert first letter to a big letter or a small letter. StringUtil.trim('Password') = 'password' StringUtil.trim('password') = 'Password' StringBuffer sbuf = new StringBuffer(str); sbuf.deleteCharAt(0); if (Character.isLowerCase(str.substring(0, 1).toCharArray()[0])) { sbuf.insert(0, str.substring(0, 1).toUpperCase()); } else { sbuf.insert(0, str.substring(0, 1).toLowerCase()); return sbuf.toString(); ... |