private static boolean needsQuote ( String value ) { if ( null == value ) return true ; int len = value . length ( ) ; if ( 0 == len ) { return true ; } if ( ' ' == value . charAt ( 0 ) ) { if ( ' ' == value . charAt ( len - 1 ) ) { // already wrapped with quotes return false ; } // we now know this has a quote (special char) in it, so return now return true ; } for ( int i = 0 ; i < len ; i ++ ) { char c = value . charAt ( i ) ; if ( c < 0x20 || c >= 0x7f || TSPECIALS . indexOf ( c ) != - 1 ) { return true ; } } return false ; }
Return true iff the string contains special characters that need to be quoted .