public static String canonicalize ( String str ) { if ( str == null ) return null ; int length = str . length ( ) ; char ch ; StringBuffer buf = new StringBuffer ( length ) ; for ( int i = 0 ; i < length ; i ++ ) { ch = str . charAt ( i ) ; if ( ch == ' ' ) continue ; buf . append ( Character . toLowerCase ( ch ) ) ; } return buf . toString ( ) ; }
Canonicalizes a string by removing any underscores and moving all characters to lowercase .