public static String proper ( EvaluationContext ctx , Object text ) { String _text = Conversions . toString ( text , ctx ) . toLowerCase ( ) ; if ( ! StringUtils . isEmpty ( _text ) ) { char [ ] buffer = _text . toCharArray ( ) ; boolean capitalizeNext = true ; for ( int i = 0 ; i < buffer . length ; ++ i ) { char ch = buffer [ i ] ; if ( ! Character . isAlphabetic ( ch ) ) { capitalizeNext = true ; } else if ( capitalizeNext ) { buffer [ i ] = Character . toTitleCase ( ch ) ; capitalizeNext = false ; } } return new String ( buffer ) ; } else { return _text ; } }
Capitalizes the first letter of every word in a text string