List of utility methods to do Java String Format
String | convertToJavaClassname(final String classname, final Map convert To Java Classname if (classname == null) { return null; final StringBuilder sb = new StringBuilder(); final CharacterIterator iter = new StringCharacterIterator(classname); char c = iter.first(); if (c == CharacterIterator.DONE) { return null; ... | ||||||||||||
String | convertToJavaIdentity(String original, boolean firstCharacterUpperCase, boolean normalize) convert To Java Identity String normalized = normalize ? normalize(original) : original; StringBuilder sb = new StringBuilder(normalized.length()); boolean nextUpper = false; for (char c : normalized.toCharArray()) { if (sb.length() == 0) { if (Character.isJavaIdentifierStart(c)) { c = firstCharacterUpperCase ? Character.toUpperCase(c) : Character.toLowerCase(c); sb.append(c); ... | ||||||||||||
String | convertToJavaUnicode(String input, Character start1, Character end1, Character start2, Character end2) Convert international characters to hex-encoded unicode format (\\u....) internat. if (start1 == null || end1 == null) return input; StringBuilder out = new StringBuilder(input.length()); String hex; char ch; if (start2 == null || end2 == null) { start2 = start1; end2 = end1; ... | ||||||||||||
String | toJava(CharSequence str) to Java if (str == null) return "null"; int len = str.length(); StringBuilder buf = new StringBuilder(len + 10); buf.append("\""); for (int i = 0; i < len; i++) { char c = str.charAt(i); switch (c) { ... | ||||||||||||
String | toJava(final double[] doubles) to Java final StringBuilder builder = new StringBuilder(20 + doubles.length * 20); toJava(doubles, builder); return builder.toString(); | ||||||||||||
String | toJava(String name) to Java String out = ""; boolean nextUpper = false; for (int i = 0; i < name.length(); i++) { char next = name.charAt(i); if (next == '-') { nextUpper = true; } else { if (nextUpper) { ... | ||||||||||||
String | toJava(String text) Transforms special characters in characters understandable for java The following characters are replaced with corresponding character entities :
return text.replace("<", "<").replace(">", ">").replace(""", "\"").replace("'", "\'") .replace("&", "&"); | ||||||||||||
String | toJAVA(String unicode) to JAVA String output = ""; char[] charArray = unicode.toCharArray(); for (int i = 0; i < charArray.length; ++i) { char a = charArray[i]; if ((int) a > 255) { output += "\\u" + Integer.toHexString((int) a); } else { output += a; ... | ||||||||||||
String | toJavaBeanPropertyName(String prop) Whenever a property name starts with a single lowercase letter, the actual java bean property starts with an upper case letter. if (prop != null && prop.length() >= 2) { if (Character.isLowerCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) { StringBuilder fixedProp = new StringBuilder(prop.substring(0, 1).toUpperCase()); fixedProp.append(prop.substring(1)); return fixedProp.toString(); return prop; ... | ||||||||||||
boolean | toJavaBool(byte goBool) to Java Bool return goBool == 1;
|