@ Transformer public static String capitalizeWords ( Object o ) { if ( null == o ) return "" ; String source = o . toString ( ) ; char prevc = ' ' ; // first char of source is capitalized StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < source . length ( ) ; i ++ ) { char c = source . charAt ( i ) ; if ( c != ' ' && ! isDigitsOrAlphabetic ( prevc ) ) { sb . append ( Character . toUpperCase ( c ) ) ; } else { sb . append ( c ) ; } prevc = c ; } return sb . toString ( ) ; }
Capitalize the first character of every word of the specified object s string representation . Words are separated by space