public static String toReadableLabel(String value) {
        StringBuilder ret = new StringBuilder();
        char lastChar = 'x';
        for (int i = 0; i < value.length(); i++) {
            char currentChar = value.charAt(i);
            // we are the begining of the output
            // or the last char was a space
            // then uppercase
            if ((i == 0 || lastChar == ' ') && !(isSeparator(currentChar))) {
                currentChar = Character.toUpperCase(currentChar);
            } else if (Character.isLowerCase(lastChar) && Character.isUpperCase(currentChar)) {
                // we switched case --> add a space
                ret.append(' ');
            } else if (isSeparator(currentChar)) {
                // we are on a _, this is a space
                currentChar = ' ';
            }

            if (!(lastChar == ' ' && currentChar == ' ')) {
                ret.append(currentChar);
                lastChar = currentChar;
            }
        }

        if (ret.toString().startsWith("Is ") || ret.toString().startsWith("Has ")) {
            ret.append('?');
        }

        return ret.toString();
    }
public static String toReadableLabel ( String value ) { StringBuilder ret = new StringBuilder ( ) ; char lastChar = 'x' ; for ( int i = 0 ; i < value . length ( ) ; i ++ ) { char currentChar = value . charAt ( i ) ; if ( ( i == 0 || lastChar == ' ' ) && ! ( isSeparator ( currentChar ) ) ) { currentChar = Character . toUpperCase ( currentChar ) ; } else if ( Character . isLowerCase ( lastChar ) && Character . isUpperCase ( currentChar ) ) { ret . append ( ' ' ) ; } else if ( isSeparator ( currentChar ) ) { currentChar = ' ' ; } if ( ! ( lastChar == ' ' && currentChar == ' ' ) ) { ret . append ( currentChar ) ; lastChar = currentChar ; } } if ( ret . toString ( ) . startsWith ( "Is " ) || ret . toString ( ) . startsWith ( "Has " ) ) { ret . append ( '?' ) ; } return ret . toString ( ) ; }
Convert strings such as bankAccountSummary to "Bank Account Summary"