List of utility methods to do Java String Format
String | toJavaCasing(final String pName) to Java Casing final char[] name = pName.toLowerCase().toCharArray(); name[0] = Character.toUpperCase(name[0]); return new String(name); |
String | toJavaClassName(String str) to Java Class Name return toVariableName(str, true, true);
|
String | toJavaConstantIdentifier(String name) to Java Constant Identifier StringBuilder s = new StringBuilder(); boolean funnyCharacter = false; for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if ((i == 0 && !Character.isJavaIdentifierStart(ch)) || (i > 0 && !Character.isJavaIdentifierPart(ch))) { funnyCharacter = true; } else if (funnyCharacter) { ... |
String | toJavadocComment(String comment) to Javadoc Comment if (comment == null) { return ""; return "/** " + comment.replace("\n", " ") + " */\n"; |
String | toJavaEnum(String inStr) to Java Enum if (inStr == null) { return (null); } else if (inStr.length() == 0) { return (inStr); inStr = inStr.replaceAll("\\.", ""); String[] terms = inStr.split("-"); StringBuffer sbuff = new StringBuffer(); ... |
String | toJavaHex(byte in[], int len) to Java Hex byte ch = 0x00; int i = 0; if (in == null || in.length <= 0) return null; String pseudo[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" }; StringBuffer out = new StringBuffer(len * 12); while (i < len) { ch = (byte) (in[i] & 0xF0); ... |
String | toJavaHexCharString(final char chr) to Java Hex Char String final String hexString = "0000" + Integer.toHexString(chr); return "\\u" + hexString.substring(hexString.length() - 4); |
String | toJavaIdentifier(String name) to Java Identifier StringBuilder s = new StringBuilder(); boolean capitalize = false; for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if ((i != 0 && !Character.isJavaIdentifierStart(ch)) || !Character.isJavaIdentifierPart(ch)) { capitalize = true; } else if (capitalize) { s.append(Character.toUpperCase(ch)); ... |
String | toJavaIdentifier(String name) to Java Identifier if (name == null || name.isEmpty()) return "_"; StringBuffer ncname = new StringBuffer(); int nameLength = name.length(); char c = name.charAt(0); if (Character.isJavaIdentifierStart(c)) ncname.append(c); else ... |
String | toJavaIdentifier(String nodeName, boolean boundary) to Java Identifier StringBuilder result = new StringBuilder(); for (char c : nodeName.toCharArray()) { if (c == '_') { boundary = true; } else if (boundary) { result.append(c); boundary = false; } else { ... |