private void appendEscapedNonAlphaNumericChars ( String str , boolean escapeDot , StringBuilder result ) { char [ ] chars = str . toCharArray ( ) ; for ( int i = 0 ; i < chars . length ; i ++ ) { char ch = chars [ i ] ; if ( Character . isLetter ( ch ) || Character . isDigit ( ch ) || ch == ' ' ) { result . append ( ch ) ; } else if ( ch == ' ' ) { result . append ( escapeDot ? ' ' : ch ) ; } else if ( ch == ' ' && ( ( i == 0 ) || ( i == chars . length - 1 ) ) ) { // ignore starting and ending '"' that are used to quote() objectname's values (see ObjectName.value()) } else { result . append ( ' ' ) ; } } }
Escape all non a - z A - Z 0 - 9 and - with a _ .