List of utility methods to do Java String Format
String | toJavaMethodName(String sqlNotation) Convert name of format THIS_IS_A_NAME to thisIsAName For each letter: if not '_' then convert to lower case and add to output string if '_' then skip letter and add next letter to output string without converting to lower case StringBuilder dest = new StringBuilder(); char[] src = sqlNotation.toCharArray(); for (int i = 0; i < src.length; i++) { char c = src[i]; boolean isFirstChar = (i == 0) ? true : false; if (isFirstChar || c != '_') { dest.append(Character.toLowerCase(c)); } else { ... |
String | toJavaMethodName(String... words) to Java Method Name StringBuilder buffer = new StringBuilder(); for (String word : words) { try { buffer.append(word.substring(0, 1).toUpperCase()); buffer.append(word.substring(1).toLowerCase()); } catch (IndexOutOfBoundsException ignore) { return buffer.toString(); |
String | toJavaName(String name) Replace all illegal Java chars by '_'. if (name.length() > 0) { final StringBuffer result = new StringBuffer(); char ch = name.charAt(0); result.append(Character.isJavaIdentifierStart(ch) ? ch : '_'); final int n = name.length(); for (int i = 1; i < n; i++) { ch = name.charAt(i); result.append(Character.isJavaIdentifierPart(ch) ? ch : '_'); ... |
String | toJavaName(String name) to Java Name if (name != null && !"".equals(name)) { String rs = ""; name = name.toLowerCase(); String[] names = name.split("_"); for (String string : names) { rs += string.substring(0, 1).toUpperCase() + string.substring(1, string.length()); return rs; ... |
String | toJavaPackageName(String name) to Java Package Name if (name == null || name.isEmpty()) return "_"; String result = null; for (String part : name.split("\\.")) { if (result == null || result.isEmpty()) result = toJavaIdentifier(part); else result = result + "." + toJavaIdentifier(part); ... |
String | toJavaPath(String path) to Java Path String javaPath = null; if (path != null) { javaPath = path.replace("\\", "/"); return javaPath; |
String | toJavaPath(String path) to Java Path return path.replace('\\', '/'); |
String | toJavaPattern(String pattern) to Java Pattern StringBuilder result = new StringBuilder("^"); char metachar[] = { '$', '^', '[', ']', '(', ')', '{', '|', '+', '?', '.', '/' }; for (int i = 0; i < pattern.length(); i++) { char ch = pattern.charAt(i); boolean isMeta = false; for (char aMetachar : metachar) { if (ch == aMetachar) { result.append("\\").append(String.valueOf(ch)); ... |
String | toJavascriptArray(String[][] Vals) to Javascript Array StringBuilder Str = new StringBuilder(); return toJavascriptArray(Str, Vals).toString(); |
String | toJavaScriptEncode(String string) to Java Script Encode if (string == null) { return "null"; string = string.replaceAll("\"", "\\\\\""); string = string.replaceAll("\r", "\\\\r"); string = string.replaceAll("\n", "\\\\n"); return "\"" + string + "\""; |