private String toJavaName ( String name ) { StringBuilder stb = new StringBuilder ( ) ; char [ ] namechars = name . toCharArray ( ) ; if ( ! Character . isJavaIdentifierStart ( namechars [ 0 ] ) ) { stb . append ( "__" ) ; } else { stb . append ( namechars [ 0 ] ) ; } for ( int i = 1 ; i < namechars . length ; i ++ ) { if ( ! Character . isJavaIdentifierPart ( namechars [ i ] ) ) { stb . append ( "__" ) ; } else { stb . append ( namechars [ i ] ) ; } } return stb . toString ( ) ; }
Turns the name into a valid simplified Java Identifier .