public static String quoteNameIfNecessary ( String name ) { int len = name . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = name . charAt ( i ) ; if ( ! ( ( c >= ' ' && c <= ' ' ) || ( c >= ' ' && c <= ' ' ) || ( c == ' ' ) || ( c >= ' ' && c <= ' ' ) ) ) { return ' ' + quoteName ( name ) + ' ' ; } } return name ; }
Returns the name conservatively quoting it if there are any characters that are likely to cause trouble outside of a quoted string or returning it literally if it seems safe .