public static String toClassName ( String str ) { StringBuilder rtn = new StringBuilder ( ) ; String [ ] arr = str . split ( "[\\\\|//]" ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] . length ( ) == 0 ) continue ; if ( rtn . length ( ) != 0 ) rtn . append ( ' ' ) ; char [ ] chars = arr [ i ] . toCharArray ( ) ; long changes = 0 ; for ( int y = 0 ; y < chars . length ; y ++ ) { char c = chars [ y ] ; if ( y == 0 && ( c >= ' ' && c <= ' ' ) ) rtn . append ( "_" + c ) ; else if ( ( c >= ' ' && c <= ' ' ) || ( c >= ' ' && c <= ' ' ) || ( c >= ' ' && c <= ' ' ) ) rtn . append ( c ) ; else { rtn . append ( ' ' ) ; changes += ( c * ( i + 1 ) ) ; } } if ( changes > 0 ) rtn . append ( changes ) ; } return rtn . toString ( ) ; }
translate a string to a valid classname string