Java Utililty Methods Java String Format

List of utility methods to do Java String Format

Description

The list of methods to do Java String Format are organized into topic(s).

Method

StringtoJavaCasing(final String pName)
to Java Casing
final char[] name = pName.toLowerCase().toCharArray();
name[0] = Character.toUpperCase(name[0]);
return new String(name);
StringtoJavaClassName(String str)
to Java Class Name
return toVariableName(str, true, true);
StringtoJavaConstantIdentifier(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) {
...
StringtoJavadocComment(String comment)
to Javadoc Comment
if (comment == null) {
    return "";
return "/** " + comment.replace("\n", " ") + " */\n";
StringtoJavaEnum(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();
...
StringtoJavaHex(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); 
...
StringtoJavaHexCharString(final char chr)
to Java Hex Char String
final String hexString = "0000" + Integer.toHexString(chr);
return "\\u" + hexString.substring(hexString.length() - 4);
StringtoJavaIdentifier(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));
...
StringtoJavaIdentifier(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
...
StringtoJavaIdentifier(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 {
...